@o3r/testing 12.4.2 → 12.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/core/angular/angular-materials/autocomplete-material.js +9 -20
  2. package/core/angular/angular-materials/autocomplete-material.js.map +1 -1
  3. package/core/angular/angular-materials/index.js +1 -1
  4. package/core/angular/angular-materials/select-material.js +42 -91
  5. package/core/angular/angular-materials/select-material.js.map +1 -1
  6. package/core/angular/angular-materials/slider-material.js +8 -11
  7. package/core/angular/angular-materials/slider-material.js.map +1 -1
  8. package/core/angular/component-fixture.js +68 -148
  9. package/core/angular/component-fixture.js.map +1 -1
  10. package/core/angular/element.js +44 -50
  11. package/core/angular/element.js.map +1 -1
  12. package/core/angular/elements/checkbox-element.js +12 -16
  13. package/core/angular/elements/checkbox-element.js.map +1 -1
  14. package/core/angular/elements/index.js +1 -1
  15. package/core/angular/elements/radio-element.js +12 -16
  16. package/core/angular/elements/radio-element.js.map +1 -1
  17. package/core/angular/elements/select-element.js +28 -49
  18. package/core/angular/elements/select-element.js.map +1 -1
  19. package/core/angular/elements/slider-element.js +38 -42
  20. package/core/angular/elements/slider-element.js.map +1 -1
  21. package/core/angular/group.js +9 -14
  22. package/core/angular/group.js.map +1 -1
  23. package/core/angular/groups/index.js +1 -1
  24. package/core/angular/groups/radio-group.js +25 -62
  25. package/core/angular/groups/radio-group.js.map +1 -1
  26. package/core/angular/index.js +1 -1
  27. package/core/angular/page-fixture.js +8 -11
  28. package/core/angular/page-fixture.js.map +1 -1
  29. package/core/angular-materials/autocomplete-material.js +8 -11
  30. package/core/angular-materials/autocomplete-material.js.map +1 -1
  31. package/core/angular-materials/index.js +1 -1
  32. package/core/angular-materials/select-material.js +12 -15
  33. package/core/angular-materials/select-material.js.map +1 -1
  34. package/core/angular-materials/slider-material.js +5 -8
  35. package/core/angular-materials/slider-material.js.map +1 -1
  36. package/core/component-fixture.js +28 -33
  37. package/core/component-fixture.js.map +1 -1
  38. package/core/element.js +24 -26
  39. package/core/element.js.map +1 -1
  40. package/core/elements/checkbox-element.js +12 -16
  41. package/core/elements/checkbox-element.js.map +1 -1
  42. package/core/elements/index.js +1 -1
  43. package/core/elements/radio-element.js +12 -16
  44. package/core/elements/radio-element.js.map +1 -1
  45. package/core/elements/select-element.js +10 -13
  46. package/core/elements/select-element.js.map +1 -1
  47. package/core/elements/slider-element.js +5 -8
  48. package/core/elements/slider-element.js.map +1 -1
  49. package/core/group.js +9 -15
  50. package/core/group.js.map +1 -1
  51. package/core/groups/index.js +1 -1
  52. package/core/groups/radio-group.js +8 -11
  53. package/core/groups/radio-group.js.map +1 -1
  54. package/core/helpers.js +11 -16
  55. package/core/helpers.js.map +1 -1
  56. package/core/index.js +1 -1
  57. package/core/page-fixture.js +8 -11
  58. package/core/page-fixture.js.map +1 -1
  59. package/core/playwright/angular-materials/autocomplete-material.js +26 -56
  60. package/core/playwright/angular-materials/autocomplete-material.js.map +1 -1
  61. package/core/playwright/angular-materials/index.js +1 -1
  62. package/core/playwright/angular-materials/select-material.js +48 -110
  63. package/core/playwright/angular-materials/select-material.js.map +1 -1
  64. package/core/playwright/angular-materials/slider-material.js +7 -10
  65. package/core/playwright/angular-materials/slider-material.js.map +1 -1
  66. package/core/playwright/component-fixture.js +88 -173
  67. package/core/playwright/component-fixture.js.map +1 -1
  68. package/core/playwright/element.js +38 -90
  69. package/core/playwright/element.js.map +1 -1
  70. package/core/playwright/elements/checkbox-element.js +49 -94
  71. package/core/playwright/elements/checkbox-element.js.map +1 -1
  72. package/core/playwright/elements/index.js +1 -1
  73. package/core/playwright/elements/radio-element.js +18 -34
  74. package/core/playwright/elements/radio-element.js.map +1 -1
  75. package/core/playwright/elements/select-element.js +14 -21
  76. package/core/playwright/elements/select-element.js.map +1 -1
  77. package/core/playwright/elements/slider-element.js +78 -157
  78. package/core/playwright/elements/slider-element.js.map +1 -1
  79. package/core/playwright/group.js +9 -14
  80. package/core/playwright/group.js.map +1 -1
  81. package/core/playwright/groups/index.js +1 -1
  82. package/core/playwright/groups/radio-group.js +27 -64
  83. package/core/playwright/groups/radio-group.js.map +1 -1
  84. package/core/playwright/index.js +1 -1
  85. package/core/playwright/page-fixture.js +8 -18
  86. package/core/playwright/page-fixture.js.map +1 -1
  87. package/core/protractor/angular-materials/autocomplete-material.js +12 -26
  88. package/core/protractor/angular-materials/autocomplete-material.js.map +1 -1
  89. package/core/protractor/angular-materials/index.js +1 -1
  90. package/core/protractor/angular-materials/select-material.js +45 -97
  91. package/core/protractor/angular-materials/select-material.js.map +1 -1
  92. package/core/protractor/component-fixture.js +89 -200
  93. package/core/protractor/component-fixture.js.map +1 -1
  94. package/core/protractor/element.js +46 -118
  95. package/core/protractor/element.js.map +1 -1
  96. package/core/protractor/elements/checkbox-element.js +18 -40
  97. package/core/protractor/elements/checkbox-element.js.map +1 -1
  98. package/core/protractor/elements/index.js +1 -1
  99. package/core/protractor/elements/radio-element.js +20 -42
  100. package/core/protractor/elements/radio-element.js.map +1 -1
  101. package/core/protractor/elements/select-element.js +16 -37
  102. package/core/protractor/elements/select-element.js.map +1 -1
  103. package/core/protractor/group.js +9 -14
  104. package/core/protractor/group.js.map +1 -1
  105. package/core/protractor/groups/index.js +1 -1
  106. package/core/protractor/groups/radio-group.js +29 -66
  107. package/core/protractor/groups/radio-group.js.map +1 -1
  108. package/core/protractor/index.js +1 -1
  109. package/core/protractor/page-fixture.js +9 -12
  110. package/core/protractor/page-fixture.js.map +1 -1
  111. package/core/protractor/utils.js +1 -1
  112. package/core/protractor/utils.js.map +1 -1
  113. package/errors/fixture-usage-error.js +5 -10
  114. package/errors/fixture-usage-error.js.map +1 -1
  115. package/errors/index.js +1 -1
  116. package/errors/transpilation-purpose-only.js +5 -10
  117. package/errors/transpilation-purpose-only.js.map +1 -1
  118. package/kassette/index.js +1 -1
  119. package/kassette/update-dates-in-mocks.js +66 -85
  120. package/kassette/update-dates-in-mocks.js.map +1 -1
  121. package/localization/index.js +1 -1
  122. package/localization/localization-mock.js +38 -60
  123. package/localization/localization-mock.js.map +1 -1
  124. package/mocks/index.js +1 -1
  125. package/mocks/mock-component-generator.js +54 -53
  126. package/mocks/mock-component-generator.js.map +1 -1
  127. package/package.json +11 -11
  128. package/public_api.js +1 -1
  129. package/schematics/ng-add/index.d.ts.map +1 -1
  130. package/schematics/ng-add/index.js +3 -5
  131. package/schematics/ng-add/index.js.map +1 -1
  132. package/schematics/ng-add/playwright/index.d.ts.map +1 -1
  133. package/schematics/ng-add/playwright/index.js +3 -4
  134. package/schematics/ng-add/playwright/index.js.map +1 -1
  135. package/store/index.js +1 -1
  136. package/store/testable-select.js +13 -13
  137. package/store/testable-select.js.map +1 -1
  138. package/tools/index.js +1 -1
  139. package/tools/path-replacement/index.js +1 -1
  140. package/tools/path-replacement/path-replacement.js +24 -19
  141. package/tools/path-replacement/path-replacement.js.map +1 -1
  142. package/tools/protractor/fetch-manager/index.js +1 -1
  143. package/tools/protractor/fetch-manager/utils.js +15 -51
  144. package/tools/protractor/fetch-manager/utils.js.map +1 -1
  145. package/tools/protractor/index.js +1 -1
  146. package/tools/protractor/post-message-interceptor/index.js +1 -1
  147. package/tools/protractor/post-message-interceptor/post-message-interceptor.js +30 -103
  148. package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
  149. package/visual-test/index.js +1 -1
  150. package/visual-test/utils.js +18 -7
  151. package/visual-test/utils.js.map +1 -1
  152. package/visual-test/visual-test.js +29 -34
  153. package/visual-test/visual-test.js.map +1 -1
  154. package/visual-testing-reporter/index.d.ts.map +1 -1
  155. package/visual-testing-reporter/index.js +37 -40
  156. package/visual-testing-reporter/index.js.map +1 -1
@@ -1,80 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.O3rRadioGroup = void 0;
4
- var tslib_1 = require("tslib");
5
- var group_1 = require("../group");
4
+ const group_1 = require("../group");
6
5
  /**
7
6
  * Group element to manage a radio group
8
7
  * @deprecated Will be removed in v13, please use Playwright instead
9
8
  */
10
- var O3rRadioGroup = /** @class */ (function (_super) {
11
- tslib_1.__extends(O3rRadioGroup, _super);
12
- function O3rRadioGroup(sourceElement) {
13
- return _super.call(this, sourceElement) || this;
9
+ class O3rRadioGroup extends group_1.O3rGroup {
10
+ constructor(sourceElement) {
11
+ super(sourceElement);
14
12
  }
15
13
  /** @inheritDoc */
16
- O3rRadioGroup.prototype.isValidGroup = function () {
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
18
- var name, _i, _a, item, itemName;
19
- return tslib_1.__generator(this, function (_b) {
20
- switch (_b.label) {
21
- case 0:
22
- name = '';
23
- _i = 0, _a = this.items;
24
- _b.label = 1;
25
- case 1:
26
- if (!(_i < _a.length)) return [3 /*break*/, 4];
27
- item = _a[_i];
28
- return [4 /*yield*/, item.getAttribute('name')];
29
- case 2:
30
- itemName = _b.sent();
31
- if (name !== '' && name !== itemName) {
32
- // eslint-disable-next-line no-console -- no other logger available
33
- console.warn("Items in this radio group are not consistent, incompatible input names found ".concat(name, " and ").concat(itemName || 'undefined'));
34
- return [2 /*return*/, false];
35
- }
36
- if (itemName !== undefined) {
37
- name = itemName;
38
- }
39
- _b.label = 3;
40
- case 3:
41
- _i++;
42
- return [3 /*break*/, 1];
43
- case 4: return [2 /*return*/, true];
44
- }
45
- });
46
- });
47
- };
14
+ async isValidGroup() {
15
+ let name = '';
16
+ for (const item of this.items) {
17
+ const itemName = await item.getAttribute('name');
18
+ if (name !== '' && name !== itemName) {
19
+ // eslint-disable-next-line no-console -- no other logger available
20
+ console.warn(`Items in this radio group are not consistent, incompatible input names found ${name} and ${itemName || 'undefined'}`);
21
+ return false;
22
+ }
23
+ if (itemName !== undefined) {
24
+ name = itemName;
25
+ }
26
+ }
27
+ return true;
28
+ }
48
29
  /**
49
30
  * Get the selected radio
50
31
  */
51
- O3rRadioGroup.prototype.getSelectedItem = function () {
52
- return tslib_1.__awaiter(this, void 0, void 0, function () {
53
- var _i, _a, item, isSelected;
54
- return tslib_1.__generator(this, function (_b) {
55
- switch (_b.label) {
56
- case 0:
57
- _i = 0, _a = this.items;
58
- _b.label = 1;
59
- case 1:
60
- if (!(_i < _a.length)) return [3 /*break*/, 4];
61
- item = _a[_i];
62
- return [4 /*yield*/, item.isChecked()];
63
- case 2:
64
- isSelected = _b.sent();
65
- if (isSelected) {
66
- return [2 /*return*/, item];
67
- }
68
- _b.label = 3;
69
- case 3:
70
- _i++;
71
- return [3 /*break*/, 1];
72
- case 4: return [2 /*return*/, undefined];
73
- }
74
- });
75
- });
76
- };
77
- return O3rRadioGroup;
78
- }(group_1.O3rGroup));
32
+ async getSelectedItem() {
33
+ for (const item of this.items) {
34
+ const isSelected = await item.isChecked();
35
+ if (isSelected) {
36
+ return item;
37
+ }
38
+ }
39
+ return undefined;
40
+ }
41
+ }
79
42
  exports.O3rRadioGroup = O3rRadioGroup;
80
43
  //# sourceMappingURL=radio-group.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../../src/core/protractor/groups/radio-group.ts"],"names":[],"mappings":";;;;AAMA,kCAEkB;AAElB;;;GAGG;AACH;IAAmC,yCAAyB;IAC1D,uBAAY,aAAgC;QAC1C,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,oCAAY,GAAzB;;;;;;wBACM,IAAI,GAAG,EAAE,CAAC;8BAEe,EAAV,KAAA,IAAI,CAAC,KAAK;;;6BAAV,CAAA,cAAU,CAAA;wBAAlB,IAAI;wBACI,qBAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAChD,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;4BACrC,mEAAmE;4BACnE,OAAO,CAAC,IAAI,CAAC,uFAAgF,IAAI,kBAAQ,QAAQ,IAAI,WAAW,CAAE,CAAC,CAAC;4BACpI,sBAAO,KAAK,EAAC;wBACf,CAAC;wBACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;4BAC3B,IAAI,GAAG,QAAQ,CAAC;wBAClB,CAAC;;;wBATgB,IAAU,CAAA;;4BAY7B,sBAAO,IAAI,EAAC;;;;KACb;IAED;;OAEG;IACU,uCAAe,GAA5B;;;;;;8BAC+B,EAAV,KAAA,IAAI,CAAC,KAAK;;;6BAAV,CAAA,cAAU,CAAA;wBAAlB,IAAI;wBACM,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAAnC,UAAU,GAAG,SAAsB;wBACzC,IAAI,UAAU,EAAE,CAAC;4BACf,sBAAO,IAAI,EAAC;wBACd,CAAC;;;wBAJgB,IAAU,CAAA;;4BAO7B,sBAAO,SAAS,EAAC;;;;KAClB;IACH,oBAAC;AAAD,CAAC,AArCD,CAAmC,gBAAQ,GAqC1C;AArCY,sCAAa","sourcesContent":["import {\n RadioGroupProfile,\n} from '../../groups/radio-group';\nimport {\n O3rRadioElement,\n} from '../elements/radio-element';\nimport {\n O3rGroup,\n} from '../group';\n\n/**\n * Group element to manage a radio group\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport class O3rRadioGroup extends O3rGroup<O3rRadioElement> implements RadioGroupProfile {\n constructor(sourceElement: O3rRadioElement[]) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async isValidGroup() {\n let name = '';\n\n for (const item of this.items) {\n const itemName = await item.getAttribute('name');\n if (name !== '' && name !== itemName) {\n // eslint-disable-next-line no-console -- no other logger available\n console.warn(`Items in this radio group are not consistent, incompatible input names found ${name} and ${itemName || 'undefined'}`);\n return false;\n }\n if (itemName !== undefined) {\n name = itemName;\n }\n }\n\n return true;\n }\n\n /**\n * Get the selected radio\n */\n public async getSelectedItem() {\n for (const item of this.items) {\n const isSelected = await item.isChecked();\n if (isSelected) {\n return item;\n }\n }\n\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../../src/core/protractor/groups/radio-group.ts"],"names":[],"mappings":";;;AAMA,oCAEkB;AAElB;;;GAGG;AACH,MAAa,aAAc,SAAQ,gBAAyB;IAC1D,YAAY,aAAgC;QAC1C,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,YAAY;QACvB,IAAI,IAAI,GAAG,EAAE,CAAC;QAEd,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,mEAAmE;gBACnE,OAAO,CAAC,IAAI,CAAC,gFAAgF,IAAI,QAAQ,QAAQ,IAAI,WAAW,EAAE,CAAC,CAAC;gBACpI,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,GAAG,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,eAAe;QAC1B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1C,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AArCD,sCAqCC","sourcesContent":["import {\n RadioGroupProfile,\n} from '../../groups/radio-group';\nimport {\n O3rRadioElement,\n} from '../elements/radio-element';\nimport {\n O3rGroup,\n} from '../group';\n\n/**\n * Group element to manage a radio group\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport class O3rRadioGroup extends O3rGroup<O3rRadioElement> implements RadioGroupProfile {\n constructor(sourceElement: O3rRadioElement[]) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async isValidGroup() {\n let name = '';\n\n for (const item of this.items) {\n const itemName = await item.getAttribute('name');\n if (name !== '' && name !== itemName) {\n // eslint-disable-next-line no-console -- no other logger available\n console.warn(`Items in this radio group are not consistent, incompatible input names found ${name} and ${itemName || 'undefined'}`);\n return false;\n }\n if (itemName !== undefined) {\n name = itemName;\n }\n }\n\n return true;\n }\n\n /**\n * Get the selected radio\n */\n public async getSelectedItem() {\n for (const item of this.items) {\n const isSelected = await item.isChecked();\n if (isSelected) {\n return item;\n }\n }\n\n return undefined;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./angular-materials"), exports);
5
5
  tslib_1.__exportStar(require("./component-fixture"), exports);
6
6
  tslib_1.__exportStar(require("./element"), exports);
@@ -1,23 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.O3rPageFixture = void 0;
4
- var tslib_1 = require("tslib");
5
- var protractor_1 = require("protractor");
6
- var component_fixture_1 = require("./component-fixture");
7
- var utils_1 = require("./utils");
4
+ const protractor_1 = require("protractor");
5
+ const component_fixture_1 = require("./component-fixture");
6
+ const utils_1 = require("./utils");
8
7
  /**
9
8
  * Implementation of the page fixture dedicated to protractor.
10
9
  * @deprecated Will be removed in v13, please use Playwright instead
11
10
  */
12
- var O3rPageFixture = /** @class */ (function (_super) {
13
- tslib_1.__extends(O3rPageFixture, _super);
14
- function O3rPageFixture(rootElement) {
15
- return _super.call(this, rootElement) || this;
11
+ class O3rPageFixture extends component_fixture_1.O3rComponentFixture {
12
+ constructor(rootElement) {
13
+ super(rootElement);
16
14
  }
17
- O3rPageFixture.prototype.getTitle = function () {
15
+ getTitle() {
18
16
  return (0, utils_1.convertPromise)(protractor_1.browser.getTitle());
19
- };
20
- return O3rPageFixture;
21
- }(component_fixture_1.O3rComponentFixture));
17
+ }
18
+ }
22
19
  exports.O3rPageFixture = O3rPageFixture;
23
20
  //# sourceMappingURL=page-fixture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/page-fixture.ts"],"names":[],"mappings":";;;;AAAA,yCAEoB;AAIpB,yDAE6B;AAI7B,iCAEiB;AAIjB;;;GAGG;AACH;IAAuE,0CAAsB;IAC3F,wBAAY,WAAe;QACzB,OAAA,MAAK,YAAC,WAAW,CAAC,SAAC;IACrB,CAAC;IAEM,iCAAQ,GAAf;QACE,OAAO,IAAA,sBAAc,EAAC,oBAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IACH,qBAAC;AAAD,CAAC,AARD,CAAuE,uCAAmB,GAQzF;AARY,wCAAc","sourcesContent":["import {\n browser,\n} from 'protractor';\nimport {\n PageFixtureProfile,\n} from '../page-fixture';\nimport {\n O3rComponentFixture,\n} from './component-fixture';\nimport {\n O3rElement,\n} from './element';\nimport {\n convertPromise,\n} from './utils';\n\nexport { PageFixtureProfile } from '../page-fixture';\n\n/**\n * Implementation of the page fixture dedicated to protractor.\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport class O3rPageFixture<V extends O3rElement = O3rElement> extends O3rComponentFixture<V> implements PageFixtureProfile<V> {\n constructor(rootElement?: V) {\n super(rootElement);\n }\n\n public getTitle() {\n return convertPromise(browser.getTitle());\n }\n}\n"]}
1
+ {"version":3,"file":"page-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/page-fixture.ts"],"names":[],"mappings":";;;AAAA,2CAEoB;AAIpB,2DAE6B;AAI7B,mCAEiB;AAIjB;;;GAGG;AACH,MAAa,cAAkD,SAAQ,uCAAsB;IAC3F,YAAY,WAAe;QACzB,KAAK,CAAC,WAAW,CAAC,CAAC;IACrB,CAAC;IAEM,QAAQ;QACb,OAAO,IAAA,sBAAc,EAAC,oBAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AARD,wCAQC","sourcesContent":["import {\n browser,\n} from 'protractor';\nimport {\n PageFixtureProfile,\n} from '../page-fixture';\nimport {\n O3rComponentFixture,\n} from './component-fixture';\nimport {\n O3rElement,\n} from './element';\nimport {\n convertPromise,\n} from './utils';\n\nexport { PageFixtureProfile } from '../page-fixture';\n\n/**\n * Implementation of the page fixture dedicated to protractor.\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport class O3rPageFixture<V extends O3rElement = O3rElement> extends O3rComponentFixture<V> implements PageFixtureProfile<V> {\n constructor(rootElement?: V) {\n super(rootElement);\n }\n\n public getTitle() {\n return convertPromise(browser.getTitle());\n }\n}\n"]}
@@ -7,6 +7,6 @@ exports.convertPromise = convertPromise;
7
7
  * @param promise
8
8
  */
9
9
  function convertPromise(promise) {
10
- return new Promise(function (resolve, reject) { return promise.then(resolve, reject); });
10
+ return new Promise((resolve, reject) => promise.then(resolve, reject));
11
11
  }
12
12
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/protractor/utils.ts"],"names":[],"mappings":";;AASA,wCAEC;AAPD;;;;GAIG;AACH,SAAgB,cAAc,CAAI,OAA4B;IAC5D,OAAO,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM,IAAK,OAAA,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAA7B,CAA6B,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import {\n promise as pPromise,\n} from 'protractor';\n\n/**\n * Converts a webdriver promise to ES6 promise so the rest of the framework handles ES6 promises only\n * @deprecated Will be removed in v13, please use Playwright instead\n * @param promise\n */\nexport function convertPromise<T>(promise: pPromise.Promise<T>) {\n return new Promise<T>((resolve, reject) => promise.then(resolve, reject));\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/protractor/utils.ts"],"names":[],"mappings":";;AASA,wCAEC;AAPD;;;;GAIG;AACH,SAAgB,cAAc,CAAI,OAA4B;IAC5D,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import {\n promise as pPromise,\n} from 'protractor';\n\n/**\n * Converts a webdriver promise to ES6 promise so the rest of the framework handles ES6 promises only\n * @deprecated Will be removed in v13, please use Playwright instead\n * @param promise\n */\nexport function convertPromise<T>(promise: pPromise.Promise<T>) {\n return new Promise<T>((resolve, reject) => promise.then(resolve, reject));\n}\n"]}
@@ -1,19 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FixtureUsageError = void 0;
4
- var tslib_1 = require("tslib");
5
4
  /**
6
5
  * Exception to indicate that a fixture is being used with invalid parameters.
7
6
  */
8
- var FixtureUsageError = /** @class */ (function (_super) {
9
- tslib_1.__extends(FixtureUsageError, _super);
10
- function FixtureUsageError(message) {
11
- if (message === void 0) { message = 'Fixture usage error'; }
12
- var _this = _super.call(this, message) || this;
13
- _this.name = 'FixtureUsageError';
14
- return _this;
7
+ class FixtureUsageError extends Error {
8
+ constructor(message = 'Fixture usage error') {
9
+ super(message);
10
+ this.name = 'FixtureUsageError';
15
11
  }
16
- return FixtureUsageError;
17
- }(Error));
12
+ }
18
13
  exports.FixtureUsageError = FixtureUsageError;
19
14
  //# sourceMappingURL=fixture-usage-error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixture-usage-error.js","sourceRoot":"","sources":["../../src/errors/fixture-usage-error.ts"],"names":[],"mappings":";;;;AAAA;;GAEG;AACH;IAAuC,6CAAK;IAC1C,2BAAY,OAA+B;QAA/B,wBAAA,EAAA,+BAA+B;QACzC,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QACf,KAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;;IAClC,CAAC;IACH,wBAAC;AAAD,CAAC,AALD,CAAuC,KAAK,GAK3C;AALY,8CAAiB","sourcesContent":["/**\n * Exception to indicate that a fixture is being used with invalid parameters.\n */\nexport class FixtureUsageError extends Error {\n constructor(message = 'Fixture usage error') {\n super(message);\n this.name = 'FixtureUsageError';\n }\n}\n"]}
1
+ {"version":3,"file":"fixture-usage-error.js","sourceRoot":"","sources":["../../src/errors/fixture-usage-error.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,GAAG,qBAAqB;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AALD,8CAKC","sourcesContent":["/**\n * Exception to indicate that a fixture is being used with invalid parameters.\n */\nexport class FixtureUsageError extends Error {\n constructor(message = 'Fixture usage error') {\n super(message);\n this.name = 'FixtureUsageError';\n }\n}\n"]}
package/errors/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./fixture-usage-error"), exports);
5
5
  tslib_1.__exportStar(require("./transpilation-purpose-only"), exports);
6
6
  //# sourceMappingURL=index.js.map
@@ -1,20 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TranspilationPurposeOnlyError = void 0;
4
- var tslib_1 = require("tslib");
5
4
  /**
6
5
  * Exception to indicate that the code run is for transpilation purpose only.
7
6
  * It should not be used during runtime process
8
7
  */
9
- var TranspilationPurposeOnlyError = /** @class */ (function (_super) {
10
- tslib_1.__extends(TranspilationPurposeOnlyError, _super);
11
- function TranspilationPurposeOnlyError(message) {
12
- if (message === void 0) { message = 'Transpilation purpose only'; }
13
- var _this = _super.call(this, message) || this;
14
- _this.name = 'TranspilationPurposeOnly';
15
- return _this;
8
+ class TranspilationPurposeOnlyError extends Error {
9
+ constructor(message = 'Transpilation purpose only') {
10
+ super(message);
11
+ this.name = 'TranspilationPurposeOnly';
16
12
  }
17
- return TranspilationPurposeOnlyError;
18
- }(Error));
13
+ }
19
14
  exports.TranspilationPurposeOnlyError = TranspilationPurposeOnlyError;
20
15
  //# sourceMappingURL=transpilation-purpose-only.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transpilation-purpose-only.js","sourceRoot":"","sources":["../../src/errors/transpilation-purpose-only.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH;IAAmD,yDAAK;IACtD,uCAAY,OAAsC;QAAtC,wBAAA,EAAA,sCAAsC;QAChD,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QACf,KAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;;IACzC,CAAC;IACH,oCAAC;AAAD,CAAC,AALD,CAAmD,KAAK,GAKvD;AALY,sEAA6B","sourcesContent":["/**\n * Exception to indicate that the code run is for transpilation purpose only.\n * It should not be used during runtime process\n */\nexport class TranspilationPurposeOnlyError extends Error {\n constructor(message = 'Transpilation purpose only') {\n super(message);\n this.name = 'TranspilationPurposeOnly';\n }\n}\n"]}
1
+ {"version":3,"file":"transpilation-purpose-only.js","sourceRoot":"","sources":["../../src/errors/transpilation-purpose-only.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,KAAK;IACtD,YAAY,OAAO,GAAG,4BAA4B;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AALD,sEAKC","sourcesContent":["/**\n * Exception to indicate that the code run is for transpilation purpose only.\n * It should not be used during runtime process\n */\nexport class TranspilationPurposeOnlyError extends Error {\n constructor(message = 'Transpilation purpose only') {\n super(message);\n this.name = 'TranspilationPurposeOnly';\n }\n}\n"]}
package/kassette/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./update-dates-in-mocks"), exports);
5
5
  //# sourceMappingURL=index.js.map
@@ -1,98 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateDatesInMocks = updateDatesInMocks;
4
- var tslib_1 = require("tslib");
5
- var temporal_polyfill_1 = require("temporal-polyfill");
4
+ const temporal_polyfill_1 = require("temporal-polyfill");
6
5
  /**
7
6
  * Update mock checksum and response body to keep using the same mocks every day with updated dates
8
7
  * @param mock the mock instance provided by the hook method of Kassette
9
8
  * @param inputOptions default options will extract ISO strings and use 'day-offset' mode
10
9
  */
11
- function updateDatesInMocks(mock_1) {
12
- return tslib_1.__awaiter(this, arguments, void 0, function (mock, inputOptions) {
13
- var plainDateLength, options, todayTime, replaceDatesInInput, checksum, _a, localPayload, referenceTime, timeOffset_1, replaceDatesInOutput, wrappedPayload;
14
- var _b, _c;
15
- if (inputOptions === void 0) { inputOptions = {}; }
16
- return tslib_1.__generator(this, function (_d) {
17
- switch (_d.label) {
18
- case 0:
19
- plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;
20
- options = tslib_1.__assign({ mode: 'day-offset', extractor: /\b(\d{4}-\d{2}-\d{2})[^"]*/g, converter: {
21
- fromDate: function (date) { return date.toString().substring(0, plainDateLength); },
22
- toDate: function (input) {
23
- input = input.replace(/\.\d+/, '').replace(/Z/, '+00:00');
24
- return input.length > plainDateLength
25
- ? temporal_polyfill_1.Temporal.ZonedDateTime.from("".concat(input.replace(/(\.\d+)/, ''), "[").concat(input.replace(/^.*(\+\d{2}:\d{2}).*$/, '$1') || '+00:00', "]"))
26
- : temporal_polyfill_1.Temporal.PlainDate.from(input);
27
- }
28
- } }, inputOptions);
29
- todayTime = temporal_polyfill_1.Temporal.Now.plainDateISO();
30
- replaceDatesInInput = function (input) {
31
- switch (options.mode) {
32
- case 'any': {
33
- return input.replace(options.extractor, '<any>');
34
- }
35
- case 'day-offset': {
36
- return input.replace(options.extractor, function (match) { return "<t+".concat(temporal_polyfill_1.Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString(), ">"); });
37
- }
38
- case 'same-day-of-week': {
39
- return input.replace(options.extractor, function (match) { return "<day ".concat(options.converter.toDate(match).dayOfWeek, " next week>"); });
40
- }
10
+ async function updateDatesInMocks(mock, inputOptions = {}) {
11
+ const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;
12
+ const options = {
13
+ mode: 'day-offset',
14
+ extractor: /\b(\d{4}-\d{2}-\d{2})[^"]*/g,
15
+ converter: {
16
+ fromDate: (date) => date.toString().substring(0, plainDateLength),
17
+ toDate: (input) => {
18
+ input = input.replace(/\.\d+/, '').replace(/Z/, '+00:00');
19
+ return input.length > plainDateLength
20
+ ? temporal_polyfill_1.Temporal.ZonedDateTime.from(`${input.replace(/(\.\d+)/, '')}[${input.replace(/^.*(\+\d{2}:\d{2}).*$/, '$1') || '+00:00'}]`)
21
+ : temporal_polyfill_1.Temporal.PlainDate.from(input);
22
+ }
23
+ },
24
+ ...inputOptions
25
+ };
26
+ const todayTime = temporal_polyfill_1.Temporal.Now.plainDateISO();
27
+ // Update request
28
+ const replaceDatesInInput = (input) => {
29
+ switch (options.mode) {
30
+ case 'any': {
31
+ return input.replace(options.extractor, '<any>');
32
+ }
33
+ case 'day-offset': {
34
+ return input.replace(options.extractor, (match) => `<t+${temporal_polyfill_1.Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);
35
+ }
36
+ case 'same-day-of-week': {
37
+ return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);
38
+ }
39
+ }
40
+ return input;
41
+ };
42
+ const checksum = await mock.checksum({
43
+ headers: false,
44
+ body: { filter: (body) => replaceDatesInInput(body.toString()) },
45
+ query: { filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)])) },
46
+ customData: { updateDatesMode: options.mode }
47
+ });
48
+ mock.setLocalPath([mock.localPath, checksum]);
49
+ // Update response
50
+ if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {
51
+ const localPayload = (await mock.readLocalPayload())?.payload;
52
+ if (localPayload && localPayload.data.creationDateTime) {
53
+ const referenceTime = temporal_polyfill_1.Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));
54
+ const timeOffset = temporal_polyfill_1.Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });
55
+ if (timeOffset.days !== 0) {
56
+ mock.setMode('manual');
57
+ const replaceDatesInOutput = (output) => {
58
+ switch (options.mode) {
59
+ case 'any':
60
+ case 'day-offset': {
61
+ return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));
41
62
  }
42
- return input;
43
- };
44
- return [4 /*yield*/, mock.checksum({
45
- headers: false,
46
- body: { filter: function (body) { return replaceDatesInInput(body.toString()); } },
47
- query: { filter: function (params) { return Object.fromEntries(Object.entries(params).map(function (_a) {
48
- var key = _a[0], value = _a[1];
49
- return [key, replaceDatesInInput(value)];
50
- })); } },
51
- customData: { updateDatesMode: options.mode }
52
- })];
53
- case 1:
54
- checksum = _d.sent();
55
- mock.setLocalPath([mock.localPath, checksum]);
56
- _a = /get|post/.test(mock.request.method);
57
- if (!_a) return [3 /*break*/, 3];
58
- return [4 /*yield*/, mock.hasLocalMock()];
59
- case 2:
60
- _a = (_d.sent());
61
- _d.label = 3;
62
- case 3:
63
- if (!_a) return [3 /*break*/, 6];
64
- return [4 /*yield*/, mock.readLocalPayload()];
65
- case 4:
66
- localPayload = (_b = (_d.sent())) === null || _b === void 0 ? void 0 : _b.payload;
67
- if (!(localPayload && localPayload.data.creationDateTime)) return [3 /*break*/, 6];
68
- referenceTime = temporal_polyfill_1.Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));
69
- timeOffset_1 = temporal_polyfill_1.Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });
70
- if (!(timeOffset_1.days !== 0)) return [3 /*break*/, 6];
71
- mock.setMode('manual');
72
- replaceDatesInOutput = function (output) {
73
- switch (options.mode) {
74
- case 'any':
75
- case 'day-offset': {
76
- return output.replace(options.extractor, function (match) { return options.converter.fromDate(options.converter.toDate(match).add(timeOffset_1)); });
77
- }
78
- case 'same-day-of-week': {
79
- return output.replace(options.extractor, function (match) { return options.converter.fromDate(options.converter.toDate(match).add("P".concat(Math.ceil(timeOffset_1.days / 7), "W"))); });
80
- }
63
+ case 'same-day-of-week': {
64
+ return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));
81
65
  }
82
- return output;
83
- };
84
- wrappedPayload = mock.createPayload({
85
- data: localPayload.data,
86
- body: replaceDatesInOutput(((_c = localPayload.body) === null || _c === void 0 ? void 0 : _c.toString()) || '')
87
- });
88
- mock.fillResponseFromPayload(wrappedPayload);
89
- return [4 /*yield*/, mock.sendResponse()];
90
- case 5:
91
- _d.sent();
92
- _d.label = 6;
93
- case 6: return [2 /*return*/];
66
+ }
67
+ return output;
68
+ };
69
+ const wrappedPayload = mock.createPayload({
70
+ data: localPayload.data,
71
+ body: replaceDatesInOutput(localPayload.body?.toString() || '')
72
+ });
73
+ mock.fillResponseFromPayload(wrappedPayload);
74
+ await mock.sendResponse();
94
75
  }
95
- });
96
- });
76
+ }
77
+ }
97
78
  }
98
79
  //# sourceMappingURL=update-dates-in-mocks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;AA2CA,gDAsEC;;AA9GD,uDAE2B;AAiC3B;;;;GAIG;AACH,SAAsB,kBAAkB;gEAAC,I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,UAAC,KAAK,IAAK,OAAA,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,CAAC,YAAU,CAAC,IAAI,GAAG,CAAC,CAAC,MAAG,CAAC,CAAC,EAAtG,CAAsG,CAAC,CAAC;4BAC9J,CAAC;wBACH,CAAC;wBACD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC;oBACI,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;wBACxC,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,IAAI,EAAE,oBAAoB,CAAC,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC;qBAChE,CAAC,CAAC;oBACH,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;oBAC7C,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;oBAAzB,SAAyB,CAAC;;;;;;CAIjC","sourcesContent":["import type {\n IMock,\n} from '@amadeus-it-group/kassette';\nimport {\n Temporal,\n} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options = {\n mode: 'day-offset',\n extractor: /\\b(\\d{4}-\\d{2}-\\d{2})[^\"]*/g,\n converter: {\n fromDate: (date) => date.toString().substring(0, plainDateLength),\n toDate: (input) => {\n input = input.replace(/\\.\\d+/, '').replace(/Z/, '+00:00');\n return input.length > plainDateLength\n ? Temporal.ZonedDateTime.from(`${input.replace(/(\\.\\d+)/, '')}[${input.replace(/^.*(\\+\\d{2}:\\d{2}).*$/, '$1') || '+00:00'}]`)\n : Temporal.PlainDate.from(input);\n }\n },\n ...inputOptions\n } as const satisfies UpdateDatesInMocksOptions;\n const todayTime = Temporal.Now.plainDateISO();\n\n // Update request\n const replaceDatesInInput = (input: string): string => {\n switch (options.mode) {\n case 'any': {\n return input.replace(options.extractor, '<any>');\n }\n case 'day-offset': {\n return input.replace(options.extractor, (match) => `<t+${Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);\n }\n case 'same-day-of-week': {\n return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);\n }\n }\n return input;\n };\n const checksum = await mock.checksum({\n headers: false,\n body: { filter: (body) => replaceDatesInInput(body.toString()) },\n query: { filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)])) },\n customData: { updateDatesMode: options.mode }\n });\n mock.setLocalPath([mock.localPath, checksum]);\n\n // Update response\n if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {\n const localPayload = (await mock.readLocalPayload())?.payload;\n if (localPayload && localPayload.data.creationDateTime) {\n const referenceTime = Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));\n const timeOffset = Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });\n if (timeOffset.days !== 0) {\n mock.setMode('manual');\n const replaceDatesInOutput = (output: string): string => {\n switch (options.mode) {\n case 'any':\n case 'day-offset': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));\n }\n case 'same-day-of-week': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));\n }\n }\n return output;\n };\n const wrappedPayload = mock.createPayload({\n data: localPayload.data,\n body: replaceDatesInOutput(localPayload.body?.toString() || '')\n });\n mock.fillResponseFromPayload(wrappedPayload);\n await mock.sendResponse();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;AA2CA,gDAsEC;AA9GD,yDAE2B;AAiC3B;;;;GAIG;AACI,KAAK,UAAU,kBAAkB,CAAC,IAAW,EAAE,eAAmD,EAAE;IACzG,MAAM,eAAe,GAAG,qBAAqB,CAAC,MAAM,CAAC;IACrD,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE,6BAA6B;QACxC,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC;YACjE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAC1D,OAAO,KAAK,CAAC,MAAM,GAAG,eAAe;oBACnC,CAAC,CAAC,4BAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,SA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';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options = {\n mode: 'day-offset',\n extractor: /\\b(\\d{4}-\\d{2}-\\d{2})[^\"]*/g,\n converter: {\n fromDate: (date) => date.toString().substring(0, plainDateLength),\n toDate: (input) => {\n input = input.replace(/\\.\\d+/, '').replace(/Z/, '+00:00');\n return input.length > plainDateLength\n ? Temporal.ZonedDateTime.from(`${input.replace(/(\\.\\d+)/, '')}[${input.replace(/^.*(\\+\\d{2}:\\d{2}).*$/, '$1') || '+00:00'}]`)\n : Temporal.PlainDate.from(input);\n }\n },\n ...inputOptions\n } as const satisfies UpdateDatesInMocksOptions;\n const todayTime = Temporal.Now.plainDateISO();\n\n // Update request\n const replaceDatesInInput = (input: string): string => {\n switch (options.mode) {\n case 'any': {\n return input.replace(options.extractor, '<any>');\n }\n case 'day-offset': {\n return input.replace(options.extractor, (match) => `<t+${Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);\n }\n case 'same-day-of-week': {\n return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);\n }\n }\n return input;\n };\n const checksum = await mock.checksum({\n headers: false,\n body: { filter: (body) => replaceDatesInInput(body.toString()) },\n query: { filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)])) },\n customData: { updateDatesMode: options.mode }\n });\n mock.setLocalPath([mock.localPath, checksum]);\n\n // Update response\n if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {\n const localPayload = (await mock.readLocalPayload())?.payload;\n if (localPayload && localPayload.data.creationDateTime) {\n const referenceTime = Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));\n const timeOffset = Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });\n if (timeOffset.days !== 0) {\n mock.setMode('manual');\n const replaceDatesInOutput = (output: string): string => {\n switch (options.mode) {\n case 'any':\n case 'day-offset': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));\n }\n case 'same-day-of-week': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));\n }\n }\n return output;\n };\n const wrappedPayload = mock.createPayload({\n data: localPayload.data,\n body: replaceDatesInOutput(localPayload.body?.toString() || '')\n });\n mock.fillResponseFromPayload(wrappedPayload);\n await mock.sendResponse();\n }\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./localization-mock"), exports);
5
5
  //# sourceMappingURL=index.js.map