@o3r/testing 12.5.0-prerelease.34 → 12.5.0-prerelease.35
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.
- package/core/angular/angular-materials/autocomplete-material.js +9 -20
- package/core/angular/angular-materials/autocomplete-material.js.map +1 -1
- package/core/angular/angular-materials/index.js +1 -1
- package/core/angular/angular-materials/select-material.js +42 -91
- package/core/angular/angular-materials/select-material.js.map +1 -1
- package/core/angular/angular-materials/slider-material.js +8 -11
- package/core/angular/angular-materials/slider-material.js.map +1 -1
- package/core/angular/component-fixture.js +68 -148
- package/core/angular/component-fixture.js.map +1 -1
- package/core/angular/element.js +44 -50
- package/core/angular/element.js.map +1 -1
- package/core/angular/elements/checkbox-element.js +12 -16
- package/core/angular/elements/checkbox-element.js.map +1 -1
- package/core/angular/elements/index.js +1 -1
- package/core/angular/elements/radio-element.js +12 -16
- package/core/angular/elements/radio-element.js.map +1 -1
- package/core/angular/elements/select-element.js +28 -49
- package/core/angular/elements/select-element.js.map +1 -1
- package/core/angular/elements/slider-element.js +38 -42
- package/core/angular/elements/slider-element.js.map +1 -1
- package/core/angular/group.js +9 -14
- package/core/angular/group.js.map +1 -1
- package/core/angular/groups/index.js +1 -1
- package/core/angular/groups/radio-group.js +25 -62
- package/core/angular/groups/radio-group.js.map +1 -1
- package/core/angular/index.js +1 -1
- package/core/angular/page-fixture.js +8 -11
- package/core/angular/page-fixture.js.map +1 -1
- package/core/angular-materials/autocomplete-material.js +8 -11
- package/core/angular-materials/autocomplete-material.js.map +1 -1
- package/core/angular-materials/index.js +1 -1
- package/core/angular-materials/select-material.js +12 -15
- package/core/angular-materials/select-material.js.map +1 -1
- package/core/angular-materials/slider-material.js +5 -8
- package/core/angular-materials/slider-material.js.map +1 -1
- package/core/component-fixture.js +28 -33
- package/core/component-fixture.js.map +1 -1
- package/core/element.js +24 -26
- package/core/element.js.map +1 -1
- package/core/elements/checkbox-element.js +12 -16
- package/core/elements/checkbox-element.js.map +1 -1
- package/core/elements/index.js +1 -1
- package/core/elements/radio-element.js +12 -16
- package/core/elements/radio-element.js.map +1 -1
- package/core/elements/select-element.js +10 -13
- package/core/elements/select-element.js.map +1 -1
- package/core/elements/slider-element.js +5 -8
- package/core/elements/slider-element.js.map +1 -1
- package/core/group.js +9 -15
- package/core/group.js.map +1 -1
- package/core/groups/index.js +1 -1
- package/core/groups/radio-group.js +8 -11
- package/core/groups/radio-group.js.map +1 -1
- package/core/helpers.js +11 -16
- package/core/helpers.js.map +1 -1
- package/core/index.js +1 -1
- package/core/page-fixture.js +8 -11
- package/core/page-fixture.js.map +1 -1
- package/core/playwright/angular-materials/autocomplete-material.js +26 -56
- package/core/playwright/angular-materials/autocomplete-material.js.map +1 -1
- package/core/playwright/angular-materials/index.js +1 -1
- package/core/playwright/angular-materials/select-material.js +48 -110
- package/core/playwright/angular-materials/select-material.js.map +1 -1
- package/core/playwright/angular-materials/slider-material.js +7 -10
- package/core/playwright/angular-materials/slider-material.js.map +1 -1
- package/core/playwright/component-fixture.js +88 -173
- package/core/playwright/component-fixture.js.map +1 -1
- package/core/playwright/element.js +38 -90
- package/core/playwright/element.js.map +1 -1
- package/core/playwright/elements/checkbox-element.js +49 -94
- package/core/playwright/elements/checkbox-element.js.map +1 -1
- package/core/playwright/elements/index.js +1 -1
- package/core/playwright/elements/radio-element.js +18 -34
- package/core/playwright/elements/radio-element.js.map +1 -1
- package/core/playwright/elements/select-element.js +14 -21
- package/core/playwright/elements/select-element.js.map +1 -1
- package/core/playwright/elements/slider-element.js +78 -157
- package/core/playwright/elements/slider-element.js.map +1 -1
- package/core/playwright/group.js +9 -14
- package/core/playwright/group.js.map +1 -1
- package/core/playwright/groups/index.js +1 -1
- package/core/playwright/groups/radio-group.js +27 -64
- package/core/playwright/groups/radio-group.js.map +1 -1
- package/core/playwright/index.js +1 -1
- package/core/playwright/page-fixture.js +8 -18
- package/core/playwright/page-fixture.js.map +1 -1
- package/core/protractor/angular-materials/autocomplete-material.js +12 -26
- package/core/protractor/angular-materials/autocomplete-material.js.map +1 -1
- package/core/protractor/angular-materials/index.js +1 -1
- package/core/protractor/angular-materials/select-material.js +45 -97
- package/core/protractor/angular-materials/select-material.js.map +1 -1
- package/core/protractor/component-fixture.js +89 -200
- package/core/protractor/component-fixture.js.map +1 -1
- package/core/protractor/element.js +46 -118
- package/core/protractor/element.js.map +1 -1
- package/core/protractor/elements/checkbox-element.js +18 -40
- package/core/protractor/elements/checkbox-element.js.map +1 -1
- package/core/protractor/elements/index.js +1 -1
- package/core/protractor/elements/radio-element.js +20 -42
- package/core/protractor/elements/radio-element.js.map +1 -1
- package/core/protractor/elements/select-element.js +16 -37
- package/core/protractor/elements/select-element.js.map +1 -1
- package/core/protractor/group.js +9 -14
- package/core/protractor/group.js.map +1 -1
- package/core/protractor/groups/index.js +1 -1
- package/core/protractor/groups/radio-group.js +29 -66
- package/core/protractor/groups/radio-group.js.map +1 -1
- package/core/protractor/index.js +1 -1
- package/core/protractor/page-fixture.js +9 -12
- package/core/protractor/page-fixture.js.map +1 -1
- package/core/protractor/utils.js +1 -1
- package/core/protractor/utils.js.map +1 -1
- package/errors/fixture-usage-error.js +5 -10
- package/errors/fixture-usage-error.js.map +1 -1
- package/errors/index.js +1 -1
- package/errors/transpilation-purpose-only.js +5 -10
- package/errors/transpilation-purpose-only.js.map +1 -1
- package/kassette/index.js +1 -1
- package/kassette/update-dates-in-mocks.js +66 -85
- package/kassette/update-dates-in-mocks.js.map +1 -1
- package/localization/index.js +1 -1
- package/localization/localization-mock.js +38 -60
- package/localization/localization-mock.js.map +1 -1
- package/mocks/index.js +1 -1
- package/mocks/mock-component-generator.js +54 -53
- package/mocks/mock-component-generator.js.map +1 -1
- package/package.json +11 -11
- package/public_api.js +1 -1
- package/store/index.js +1 -1
- package/store/testable-select.js +13 -13
- package/store/testable-select.js.map +1 -1
- package/tools/index.js +1 -1
- package/tools/path-replacement/index.js +1 -1
- package/tools/path-replacement/path-replacement.js +24 -19
- package/tools/path-replacement/path-replacement.js.map +1 -1
- package/tools/protractor/fetch-manager/index.js +1 -1
- package/tools/protractor/fetch-manager/utils.js +15 -51
- package/tools/protractor/fetch-manager/utils.js.map +1 -1
- package/tools/protractor/index.js +1 -1
- package/tools/protractor/post-message-interceptor/index.js +1 -1
- package/tools/protractor/post-message-interceptor/post-message-interceptor.js +30 -103
- package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
- package/visual-test/index.js +1 -1
- package/visual-test/utils.js +18 -7
- package/visual-test/utils.js.map +1 -1
- package/visual-test/visual-test.js +29 -34
- package/visual-test/visual-test.js.map +1 -1
- package/visual-testing-reporter/index.d.ts.map +1 -1
- package/visual-testing-reporter/index.js +37 -40
- 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
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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":"
|
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"]}
|
package/core/protractor/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
return _super.call(this, rootElement) || this;
|
11
|
+
class O3rPageFixture extends component_fixture_1.O3rComponentFixture {
|
12
|
+
constructor(rootElement) {
|
13
|
+
super(rootElement);
|
16
14
|
}
|
17
|
-
|
15
|
+
getTitle() {
|
18
16
|
return (0, utils_1.convertPromise)(protractor_1.browser.getTitle());
|
19
|
-
}
|
20
|
-
|
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":"
|
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"]}
|
package/core/protractor/utils.js
CHANGED
@@ -7,6 +7,6 @@ exports.convertPromise = convertPromise;
|
|
7
7
|
* @param promise
|
8
8
|
*/
|
9
9
|
function convertPromise(promise) {
|
10
|
-
return new Promise(
|
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,
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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":"
|
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
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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":"
|
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,98 +1,79 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.updateDatesInMocks = updateDatesInMocks;
|
4
|
-
|
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(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
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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} 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"]}
|
package/localization/index.js
CHANGED