@o3r/testing 10.0.0-next.8 → 11.0.0-next.0
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/README.md +1 -1
- package/core/angular/component-fixture.d.ts +0 -15
- package/core/angular/component-fixture.d.ts.map +1 -1
- package/core/angular/component-fixture.js +11 -20
- package/core/angular/component-fixture.js.map +1 -1
- package/core/angular/element.d.ts +0 -1
- package/core/angular/element.d.ts.map +1 -1
- package/core/angular/element.js +0 -1
- package/core/angular/element.js.map +1 -1
- package/core/angular-materials/autocomplete-material.d.ts +0 -1
- package/core/angular-materials/autocomplete-material.d.ts.map +1 -1
- package/core/angular-materials/autocomplete-material.js +0 -1
- package/core/angular-materials/autocomplete-material.js.map +1 -1
- package/core/angular-materials/select-material.d.ts +0 -7
- package/core/angular-materials/select-material.d.ts.map +1 -1
- package/core/angular-materials/select-material.js +0 -9
- package/core/angular-materials/select-material.js.map +1 -1
- package/core/component-fixture.d.ts +20 -12
- package/core/component-fixture.d.ts.map +1 -1
- package/core/component-fixture.js +18 -5
- package/core/component-fixture.js.map +1 -1
- package/core/elements/checkbox-element.d.ts +0 -1
- package/core/elements/checkbox-element.d.ts.map +1 -1
- package/core/elements/checkbox-element.js.map +1 -1
- package/core/elements/radio-element.d.ts +0 -1
- package/core/elements/radio-element.d.ts.map +1 -1
- package/core/elements/radio-element.js.map +1 -1
- package/core/elements/select-element.d.ts +0 -2
- package/core/elements/select-element.d.ts.map +1 -1
- package/core/elements/select-element.js +0 -2
- package/core/elements/select-element.js.map +1 -1
- package/core/helpers.d.ts +0 -2
- package/core/helpers.d.ts.map +1 -1
- package/core/helpers.js +0 -2
- package/core/helpers.js.map +1 -1
- package/core/page-fixture.d.ts +0 -1
- package/core/page-fixture.d.ts.map +1 -1
- package/core/page-fixture.js +0 -1
- package/core/page-fixture.js.map +1 -1
- package/core/playwright/component-fixture.d.ts +0 -15
- package/core/playwright/component-fixture.d.ts.map +1 -1
- package/core/playwright/component-fixture.js +14 -24
- package/core/playwright/component-fixture.js.map +1 -1
- package/core/playwright/element.d.ts +0 -2
- package/core/playwright/element.d.ts.map +1 -1
- package/core/playwright/element.js +0 -1
- package/core/playwright/element.js.map +1 -1
- package/core/protractor/component-fixture.d.ts +0 -15
- package/core/protractor/component-fixture.d.ts.map +1 -1
- package/core/protractor/component-fixture.js +11 -21
- package/core/protractor/component-fixture.js.map +1 -1
- package/core/protractor/utils.d.ts +0 -1
- package/core/protractor/utils.d.ts.map +1 -1
- package/core/protractor/utils.js +0 -1
- package/core/protractor/utils.js.map +1 -1
- package/kassette/update-dates-in-mocks.d.ts +0 -3
- package/kassette/update-dates-in-mocks.d.ts.map +1 -1
- package/kassette/update-dates-in-mocks.js +10 -6
- package/kassette/update-dates-in-mocks.js.map +1 -1
- package/localization/localization-mock.d.ts +0 -1
- package/localization/localization-mock.d.ts.map +1 -1
- package/localization/localization-mock.js +4 -3
- package/localization/localization-mock.js.map +1 -1
- package/mocks/mock-component-generator.d.ts +5 -4
- package/mocks/mock-component-generator.d.ts.map +1 -1
- package/mocks/mock-component-generator.js +5 -9
- package/mocks/mock-component-generator.js.map +1 -1
- package/package.json +65 -54
- package/schematics/add-functions-to-fixture/index.js +1 -1
- package/schematics/add-functions-to-fixture/index.js.map +1 -1
- package/schematics/add-functions-to-fixture/schema.json +1 -1
- package/schematics/fixture-to-component/index.d.ts.map +1 -1
- package/schematics/fixture-to-component/index.js +1 -1
- package/schematics/fixture-to-component/index.js.map +1 -1
- package/schematics/fixture-to-component/schema.json +1 -1
- package/schematics/ng-add/fixture/index.d.ts +2 -1
- package/schematics/ng-add/fixture/index.d.ts.map +1 -1
- package/schematics/ng-add/fixture/index.js +43 -16
- package/schematics/ng-add/fixture/index.js.map +1 -1
- package/schematics/ng-add/index.d.ts +0 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +17 -18
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/playwright/index.d.ts +0 -1
- package/schematics/ng-add/playwright/index.d.ts.map +1 -1
- package/schematics/ng-add/playwright/index.js +1 -2
- package/schematics/ng-add/playwright/index.js.map +1 -1
- package/schematics/ng-add/schema.json +2 -2
- package/schematics/ng-add/templates/project/jest.config.js.template +1 -1
- package/schematics/ng-add/templates/workspace/jest.config.js.template +1 -1
- package/schematics/ng-add/templates/workspace/jest.config.ut.js.template +53 -41
- package/schematics/playwright/sanity/index.d.ts +0 -1
- package/schematics/playwright/sanity/index.d.ts.map +1 -1
- package/schematics/playwright/sanity/index.js +2 -4
- package/schematics/playwright/sanity/index.js.map +1 -1
- package/schematics/playwright/sanity/schema.json +1 -1
- package/schematics/playwright/scenario/index.d.ts +0 -1
- package/schematics/playwright/scenario/index.d.ts.map +1 -1
- package/schematics/playwright/scenario/index.js +2 -4
- package/schematics/playwright/scenario/index.js.map +1 -1
- package/schematics/playwright/scenario/schema.json +1 -1
- package/store/testable-select.d.ts +0 -3
- package/store/testable-select.d.ts.map +1 -1
- package/store/testable-select.js +0 -6
- package/store/testable-select.js.map +1 -1
- package/store/typings.d.ts +0 -1
- package/store/typings.d.ts.map +1 -1
- package/store/typings.js +0 -1
- package/store/typings.js.map +1 -1
- package/tools/path-replacement/path-replacement.d.ts +0 -1
- package/tools/path-replacement/path-replacement.d.ts.map +1 -1
- package/tools/path-replacement/path-replacement.js +0 -1
- package/tools/path-replacement/path-replacement.js.map +1 -1
- package/tools/protractor/fetch-manager/_fetch-manager.js +0 -1
- package/tools/protractor/fetch-manager/_fetch-manager.js.map +1 -1
- package/tools/protractor/post-message-interceptor/_post-message-interceptor.js +0 -4
- package/tools/protractor/post-message-interceptor/_post-message-interceptor.js.map +1 -1
- package/tools/protractor/post-message-interceptor/post-message-interceptor.d.ts +0 -4
- package/tools/protractor/post-message-interceptor/post-message-interceptor.d.ts.map +1 -1
- package/tools/protractor/post-message-interceptor/post-message-interceptor.js +0 -4
- package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
- package/visual-test/utils.d.ts +0 -2
- package/visual-test/utils.d.ts.map +1 -1
- package/visual-test/utils.js +0 -2
- package/visual-test/utils.js.map +1 -1
- package/visual-test/visual-test.d.ts +1 -5
- package/visual-test/visual-test.d.ts.map +1 -1
- package/visual-test/visual-test.js +1 -5
- package/visual-test/visual-test.js.map +1 -1
|
@@ -3,7 +3,6 @@ import { ElementProfile } from '../element';
|
|
|
3
3
|
export { ElementProfile } from '../element';
|
|
4
4
|
/**
|
|
5
5
|
* Playwright type for source element
|
|
6
|
-
*
|
|
7
6
|
* @param element is the DOM element
|
|
8
7
|
* @param page is the tab in the browser where the test is run
|
|
9
8
|
*/
|
|
@@ -13,7 +12,6 @@ export type PlaywrightSourceElement = {
|
|
|
13
12
|
};
|
|
14
13
|
/**
|
|
15
14
|
* Remove text formatting (endline etc.) and return the content.
|
|
16
|
-
*
|
|
17
15
|
* @param innerText
|
|
18
16
|
*/
|
|
19
17
|
export declare function getPlainText(innerText: string): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AAEH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,sBAE7C;AAED;;GAEG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C,+BAA+B;IACxB,aAAa,EAAE,uBAAuB,CAAC;gBAElC,aAAa,EAAE,uBAAuB,GAAG,UAAU;IAM/D,kBAAkB;IACX,OAAO;IAId,kBAAkB;IACL,YAAY;IAIzB,kBAAkB;IACX,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIlD,kBAAkB;IACX,SAAS;IAIhB,kBAAkB;IACL,QAAQ;IAUrB,kBAAkB;IACL,QAAQ,CAAC,KAAK,EAAE,MAAM;IASnC,kBAAkB;IACL,UAAU;IAavB,kBAAkB;IACX,KAAK;IAIZ,kBAAkB;IACX,SAAS;IAIhB,kBAAkB;IACL,YAAY,CAAC,aAAa,EAAE,MAAM;CAIhD;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,cAAc,IAAI,KAAK,aAAa,EAAE,uBAAuB,GAAG,UAAU,KAAK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/core/playwright/element.ts"],"names":[],"mappings":";;;;AAgBA;;;GAGG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACzG,CAAC;AAFD,oCAEC;AAED;;GAEG;AACH;IAIE,oBAAY,aAAmD;QAC7D,IAAI,CAAC,aAAa,GAAG,aAAa,YAAY,UAAU;YACt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hFY,gCAAU","sourcesContent":["import type {Locator, Page} from '@playwright/test';\nimport {ElementProfile} from '../element';\n\nexport {ElementProfile} from '../element';\n\n/**\n * Playwright type for source element\n * @param element is the DOM element\n * @param page is the tab in the browser where the test is run\n */\n\nexport type PlaywrightSourceElement = {\n element: Locator;\n page: Page;\n};\n\n/**\n * Remove text formatting (endline etc.) and return the content.\n * @param innerText\n */\nexport function getPlainText(innerText: string) {\n return innerText ? innerText.replace(/(?:\\r\\n|\\r|\\n)/g, ' ').replace(/\\s\\s+/g, ' ').trim() : undefined;\n}\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rElement implements ElementProfile {\n /** Playwright sourceElement */\n public sourceElement: PlaywrightSourceElement;\n\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n this.sourceElement = sourceElement instanceof O3rElement\n ? {element: sourceElement.sourceElement.element, page: sourceElement.sourceElement.page}\n : sourceElement;\n }\n\n /** @inheritdoc */\n public getText() {\n return this.sourceElement.element.innerText();\n }\n\n /** @inheritdoc */\n public async getPlainText() {\n return getPlainText(await this.getText());\n }\n\n /** @inheritdoc */\n public getInnerHTML(): Promise<string | undefined> {\n return this.sourceElement.element.innerHTML();\n }\n\n /** @inheritdoc */\n public mouseOver() {\n return this.sourceElement.element.hover();\n }\n\n /** @inheritdoc */\n public async getValue() {\n try {\n return await this.sourceElement.element.inputValue();\n } catch (error) {\n console.warn('Failed to retrieve input value');\n const valueByAttribute = await this.sourceElement.element.getAttribute('value');\n return valueByAttribute !== null ? valueByAttribute : undefined;\n }\n }\n\n /** @inheritdoc */\n public async setValue(input: string) {\n // Clears the value in the field\n await this.clearValue();\n\n await this.sourceElement.element.fill(input);\n\n await this.sourceElement.element.press('Tab');\n }\n\n /** @inheritdoc */\n public async clearValue() {\n const currentValue = await this.getValue();\n\n if (currentValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < currentValue.length; i++) {\n // ensure backspace deletes the value\n await this.sourceElement.element.press('ArrowRight');\n await this.sourceElement.element.press('Backspace');\n }\n }\n }\n\n /** @inheritdoc */\n public click() {\n return this.sourceElement.element.click();\n }\n\n /** @inheritdoc */\n public isVisible() {\n return this.sourceElement.element.isVisible();\n }\n\n /** @inheritdoc */\n public async getAttribute(attributeName: string) {\n const attribute = await this.sourceElement.element.getAttribute(attributeName);\n return attribute !== null ? attribute : undefined;\n }\n}\n\n/**\n * Constructor of a O3rElement\n */\nexport type O3rElementConstructor<T extends ElementProfile> = new (sourceElement: PlaywrightSourceElement | O3rElement) => T;\n"]}
|
|
@@ -13,14 +13,12 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
|
|
|
13
13
|
/**
|
|
14
14
|
* Root element of this fixture. Optional in a Protractor.
|
|
15
15
|
* All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.
|
|
16
|
-
*
|
|
17
16
|
* @param rootElement
|
|
18
17
|
*/
|
|
19
18
|
constructor(rootElement?: V);
|
|
20
19
|
/**
|
|
21
20
|
* Throws an exception if the element is undefined.
|
|
22
21
|
* Otherwise returns the element.
|
|
23
|
-
*
|
|
24
22
|
* @param elemnt ElementProfile to test
|
|
25
23
|
* @param _timeout specific timeout that will throw when reach
|
|
26
24
|
*/
|
|
@@ -28,22 +26,12 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
|
|
|
28
26
|
/**
|
|
29
27
|
* Throws an exception if the element is undefined.
|
|
30
28
|
* Otherwise returns the element.
|
|
31
|
-
*
|
|
32
|
-
* @param elemnt ElementProfile to test
|
|
33
|
-
* @deprecated use {@link Promise} only as {@link throwOnUndefined} parameter or use {@link throwOnUndefinedElement} instead. Will be removed in v10
|
|
34
|
-
*/
|
|
35
|
-
protected throwOnUndefined<T extends O3rElement>(elemnt?: T): T;
|
|
36
|
-
/**
|
|
37
|
-
* Throws an exception if the element is undefined.
|
|
38
|
-
* Otherwise returns the element.
|
|
39
|
-
*
|
|
40
29
|
* @param elemnt ElementProfile to test
|
|
41
30
|
* @param timeout specific timeout that will throw when reach
|
|
42
31
|
*/
|
|
43
32
|
protected throwOnUndefined<T extends O3rElement>(elemnt: Promise<T | undefined>, timeout?: number): Promise<T>;
|
|
44
33
|
/**
|
|
45
34
|
* Get the element associated to the selector if present
|
|
46
|
-
*
|
|
47
35
|
* @param selector Selector to access the element
|
|
48
36
|
* @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
49
37
|
* @param options Options supported
|
|
@@ -58,7 +46,6 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
|
|
|
58
46
|
}): Promise<O3rElement | undefined>;
|
|
59
47
|
/**
|
|
60
48
|
* Get text from the element associated to the given selector, or undefined if the element is not found or not visible
|
|
61
|
-
*
|
|
62
49
|
* @param selector Selector to access the element
|
|
63
50
|
* @param options Options supported
|
|
64
51
|
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
@@ -74,7 +61,6 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
|
|
|
74
61
|
}): Promise<string | undefined>;
|
|
75
62
|
/**
|
|
76
63
|
* Check if the element associated to the given selector is visible
|
|
77
|
-
*
|
|
78
64
|
* @param selector Selector to access the element
|
|
79
65
|
* @param options Options supported
|
|
80
66
|
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
@@ -90,7 +76,6 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
|
|
|
90
76
|
}): Promise<boolean>;
|
|
91
77
|
/**
|
|
92
78
|
* Click on the element associated to the given selector if it exists and is visible
|
|
93
|
-
*
|
|
94
79
|
* @param selector Selector to access the element
|
|
95
80
|
* @param options Options supported
|
|
96
81
|
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-fixture.d.ts","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,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,SAAS,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAyB9L,kBAAkB;IACX,UAAU;IAIjB,kBAAkB;IACX,gBAAgB,IAAI,OAAO,CAAC;QAAC,CAAC,aAAa,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAAA;KAAC,CAAC;IAIxF,kBAAkB;IACL,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAIpF"}
|
|
@@ -15,7 +15,6 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
|
15
15
|
/**
|
|
16
16
|
* Root element of this fixture. Optional in a Protractor.
|
|
17
17
|
* All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.
|
|
18
|
-
*
|
|
19
18
|
* @param rootElement
|
|
20
19
|
*/
|
|
21
20
|
function O3rComponentFixture(rootElement) {
|
|
@@ -24,7 +23,6 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
|
24
23
|
/**
|
|
25
24
|
* Throws an exception if the element is undefined.
|
|
26
25
|
* Otherwise returns the element.
|
|
27
|
-
*
|
|
28
26
|
* @param elemnt ElementProfile to test
|
|
29
27
|
* @param _timeout specific timeout that will throw when reach
|
|
30
28
|
*/
|
|
@@ -37,30 +35,25 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
|
37
35
|
/**
|
|
38
36
|
* Throws an exception if the element is undefined.
|
|
39
37
|
* Otherwise returns the element.
|
|
40
|
-
*
|
|
41
38
|
* @param elemnt ElementProfile to test
|
|
42
39
|
* @param timeout specific timeout that will throw when reach
|
|
43
|
-
* @deprecated use {@link Promise} only as {@link throwOnUndefined} parameter or use {@link throwOnUndefinedElement} instead. Will be removed in v10
|
|
44
40
|
*/
|
|
45
41
|
O3rComponentFixture.prototype.throwOnUndefined = function (elemnt, timeout) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return el;
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var _this = this;
|
|
44
|
+
return tslib_1.__generator(this, function (_a) {
|
|
45
|
+
return [2 /*return*/, (0, helpers_1.withTimeout)(elemnt, timeout)
|
|
46
|
+
.then(function (el) {
|
|
47
|
+
if (!el) {
|
|
48
|
+
throw new Error('Element not found in ' + _this.constructor.name);
|
|
49
|
+
}
|
|
50
|
+
return el;
|
|
51
|
+
})];
|
|
57
52
|
});
|
|
58
|
-
}
|
|
59
|
-
return elemnt;
|
|
53
|
+
});
|
|
60
54
|
};
|
|
61
55
|
/**
|
|
62
56
|
* Get the element associated to the selector if present
|
|
63
|
-
*
|
|
64
57
|
* @param selector Selector to access the element
|
|
65
58
|
* @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
66
59
|
* @param options Options supported
|
|
@@ -95,7 +88,6 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
|
95
88
|
};
|
|
96
89
|
/**
|
|
97
90
|
* Get text from the element associated to the given selector, or undefined if the element is not found or not visible
|
|
98
|
-
*
|
|
99
91
|
* @param selector Selector to access the element
|
|
100
92
|
* @param options Options supported
|
|
101
93
|
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
@@ -130,7 +122,6 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
|
130
122
|
};
|
|
131
123
|
/**
|
|
132
124
|
* Check if the element associated to the given selector is visible
|
|
133
|
-
*
|
|
134
125
|
* @param selector Selector to access the element
|
|
135
126
|
* @param options Options supported
|
|
136
127
|
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
@@ -160,7 +151,6 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
|
160
151
|
};
|
|
161
152
|
/**
|
|
162
153
|
* Click on the element associated to the given selector if it exists and is visible
|
|
163
|
-
*
|
|
164
154
|
* @param selector Selector to access the element
|
|
165
155
|
* @param options Options supported
|
|
166
156
|
* @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,yCAAiE;AACjE,4CAAuD;AAGvD,sCAAoD;AACpD,qCAA8D;AAE9D,iCAAyC;AAIzC;;GAEG;AACH;IAME;;;;;OAKG;IACH,6BAAY,WAAe;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACO,qDAAuB,GAAjC,UAAwD,MAAU,EAAE,QAAiB;QACnF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClE;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAkBD;;;;;;;OAOG;IACO,8CAAgB,GAA1B,UAAiD,MAAmC,EAAE,OAAgB;QAAtG,iBAcC;QAbC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClE;QACD,IAAI,IAAA,mBAAS,EAAC,MAAM,CAAC,EAAE;YACrB,OAAO,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC;iBAChC,IAAI,CAAC,UAAC,EAAE;gBACP,IAAI,CAAC,EAAE,EAAE;oBACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;iBAClE;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;SACN;QACD,OAAO,MAAM,CAA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C,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAU,CAAC,IAAI,CAAC,CAAC,EAA1D,CAA0D,CAAC,EAA7E,CAA6E,CAAC,CAAC;wBAChG,qBAAM,IAAA,sBAAc,EAAC,SAAS,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;6BAE5C,SAAS,EAAT,wBAAS;wBACL,KAAK,GAAG,IAAI,SAAS,CAAC,QAAe,CAAC,CAAC;wBAC7B,qBAAM,KAAK,CAAC,YAAY,EAAE,EAAA;;wBAApC,OAAO,GAAG,SAA0B;wBAE1C,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;yBACvD;wBACD,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;4BAGhC,sBAAO,QAAQ,EAAC;;;;KACjB;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;IACL,6CAAe,GAA5B,UAA6B,QAAgB,EAAE,QAAiB;;;;;;wBACxD,aAAa,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;wBAChE,qBAAM,CAAC,aAAa,IAAI,oBAAO,CAAC,CAAC,gBAAgB,CAAC,eAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAA;4BAA5E,sBAAO,CAAC,CAAC,SAAmE,CAAC,EAAC;;;;KAC/E;IACH,0BAAC;AAAD,CAAC,AA/OD,IA+OC;AA/OY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { browser, By, element, ElementFinder } from 'protractor';\nimport { FixtureUsageError } from '../../errors/index';\n\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { isPromise, withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\nimport { convertPromise } from './utils';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement?: V;\n\n /**\n * Root element of this fixture. Optional in a Protractor.\n * All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.\n *\n * @param rootElement\n */\n constructor(rootElement?: V) {\n this.rootElement = rootElement;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n *\n * @param elemnt ElementProfile to test\n * @param _timeout specific timeout that will throw when reach\n */\n protected throwOnUndefinedElement<T extends O3rElement>(elemnt?: T, _timeout?: number): Promise<T> {\n if (!elemnt) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return Promise.resolve(elemnt);\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n *\n * @param elemnt ElementProfile to test\n * @deprecated use {@link Promise} only as {@link throwOnUndefined} parameter or use {@link throwOnUndefinedElement} instead. Will be removed in v10\n */\n protected throwOnUndefined<T extends O3rElement>(elemnt?: T): T;\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n *\n * @param elemnt ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(elemnt: Promise<T | undefined>, timeout?: number): Promise<T>;\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n *\n * @param elemnt ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n * @deprecated use {@link Promise} only as {@link throwOnUndefined} parameter or use {@link throwOnUndefinedElement} instead. Will be removed in v10\n */\n protected throwOnUndefined<T extends O3rElement>(elemnt?: Promise<T | undefined> | T, timeout?: number): Promise<T> | T {\n if (!elemnt) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n if (isPromise(elemnt)) {\n return withTimeout(elemnt, timeout)\n .then((el) => {\n if (!el) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return el;\n });\n }\n return elemnt;\n }\n\n\n /**\n * Get the element associated to the selector if present\n *\n * @param selector Selector to access the element\n * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options Options supported\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async queryWithOptions(\n selector: string,\n elementConstructor?: O3rElementConstructor<O3rElement>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<O3rElement | undefined> {\n let queryElement: O3rElement | undefined;\n if (options.index !== undefined) {\n queryElement = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n queryElement = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(queryElement, options.timeout);\n }\n return queryElement;\n }\n\n /**\n * Get text from the element associated to the given selector, or undefined if the element is not found or not visible\n *\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async getText<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const getTextElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!getTextElement || !await getTextElement.isVisible()) {\n return;\n }\n return await getTextElement.getText();\n }\n\n /**\n * Check if the element associated to the given selector is visible\n *\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async isVisible<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<boolean> {\n const isVisibleElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n return !!isVisibleElement && await isVisibleElement.isVisible();\n }\n\n /**\n * Click on the element associated to the given selector if it exists and is visible\n *\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async click<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<void> {\n const clickElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!!clickElement && await clickElement.isVisible()) {\n await clickElement.click();\n }\n }\n\n /** @inheritdoc */\n public async query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const cssSelector = By.css(selector);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const isElPresent = await (sourceElement! || browser).isElementPresent(cssSelector);\n if (!isElPresent) {\n console.warn(`No component matching ${selector} found`);\n return;\n }\n const queriedElement = sourceElement ? sourceElement.element(cssSelector) : element(cssSelector);\n return returnType ? new returnType(queriedElement) : new O3rElement(queriedElement);\n }\n\n /** @inheritdoc */\n public async queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const item = (sourceElement || element).all(By.css(selector)).get(index);\n if (!(await item.isPresent())) {\n console.warn(`No component matching ${selector}:nth(${index}) found`);\n return;\n }\n return new (returnType || O3rElement)(item);\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n _timeout?: number\n ): Promise<(T | O3rElement)[] | K> {\n const pElements = (this.rootElement ? this.rootElement.sourceElement.all(By.css(selector)) : element.all(By.css(selector)))\n .filter((item) => typeof item !== 'undefined')\n .then((elf: ElementFinder[]) => elf.map((item) => (returnType ? new returnType(item) : new O3rElement(item))));\n const elements = await convertPromise(pElements);\n\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return Promise.resolve(group);\n }\n\n return elements;\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.rootElement;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{[componentName: string]: ComponentFixtureProfile[]}> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public async queryNotPresent(selector: string, _timeout?: number): Promise<boolean> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n return !(await (sourceElement || browser).isElementPresent(By.css(selector)));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,yCAAiE;AACjE,4CAAuD;AAGvD,sCAAyC;AACzC,qCAA8D;AAE9D,iCAAyC;AAIzC;;GAEG;AACH;IAME;;;;OAIG;IACH,6BAAY,WAAe;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,qDAAuB,GAAjC,UAAwD,MAAU,EAAE,QAAiB;QACnF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClE;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,8CAAgB,GAAhC,UAAuD,MAA8B,EAAE,OAAgB;;;;gBACrG,sBAAO,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC;yBAChC,IAAI,CAAC,UAAC,EAAE;wBACP,IAAI,CAAC,EAAE,EAAE;4BACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;yBAClE;wBACD,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,EAAC;;;KACN;IAGD;;;;;;;;OAQG;IACa,8CAAgB,GAAhC,UACE,QAAgB,EAChB,kBAAsD,EACtD,OAIM;QAJN,wBAAA,EAAA,YAIM;;;;;;6BAGF,CAAA,OAAO,CAAC,KAAK,KAAK,SAAS,CAAA,EAA3B,wBAA2B;wBACd,qBAAM,IAAI,CAAC,QAAQ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E5C,SAAS,EAAT,wBAAS;wBACL,KAAK,GAAG,IAAI,SAAS,CAAC,QAAe,CAAC,CAAC;wBAC7B,qBAAM,KAAK,CAAC,YAAY,EAAE,EAAA;;wBAApC,OAAO,GAAG,SAA0B;wBAE1C,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;yBACvD;wBACD,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;4BAGhC,sBAAO,QAAQ,EAAC;;;;KACjB;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;IACL,6CAAe,GAA5B,UAA6B,QAAgB,EAAE,QAAiB;;;;;;wBACxD,aAAa,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;wBAChE,qBAAM,CAAC,aAAa,IAAI,oBAAO,CAAC,CAAC,gBAAgB,CAAC,eAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAA;4BAA5E,sBAAO,CAAC,CAAC,SAAmE,CAAC,EAAC;;;;KAC/E;IACH,0BAAC;AAAD,CAAC,AAjND,IAiNC;AAjNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { browser, By, element, ElementFinder } from 'protractor';\nimport { FixtureUsageError } from '../../errors/index';\n\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\nimport { convertPromise } from './utils';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement?: V;\n\n /**\n * Root element of this fixture. Optional in a Protractor.\n * All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.\n * @param rootElement\n */\n constructor(rootElement?: V) {\n this.rootElement = rootElement;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param elemnt ElementProfile to test\n * @param _timeout specific timeout that will throw when reach\n */\n protected throwOnUndefinedElement<T extends O3rElement>(elemnt?: T, _timeout?: number): Promise<T> {\n if (!elemnt) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return Promise.resolve(elemnt);\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param elemnt ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(elemnt: Promise<T | undefined>, timeout?: number): Promise<T> {\n return withTimeout(elemnt, timeout)\n .then((el) => {\n if (!el) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return el;\n });\n }\n\n\n /**\n * Get the element associated to the selector if present\n * @param selector Selector to access the element\n * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options Options supported\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async queryWithOptions(\n selector: string,\n elementConstructor?: O3rElementConstructor<O3rElement>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<O3rElement | undefined> {\n let queryElement: O3rElement | undefined;\n if (options.index !== undefined) {\n queryElement = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n queryElement = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(queryElement, options.timeout);\n }\n return queryElement;\n }\n\n /**\n * Get text from the element associated to the given selector, or undefined if the element is not found or not visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async getText<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const getTextElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!getTextElement || !await getTextElement.isVisible()) {\n return;\n }\n return await getTextElement.getText();\n }\n\n /**\n * Check if the element associated to the given selector is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async isVisible<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<boolean> {\n const isVisibleElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n return !!isVisibleElement && await isVisibleElement.isVisible();\n }\n\n /**\n * Click on the element associated to the given selector if it exists and is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async click<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<void> {\n const clickElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!!clickElement && await clickElement.isVisible()) {\n await clickElement.click();\n }\n }\n\n /** @inheritdoc */\n public async query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const cssSelector = By.css(selector);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const isElPresent = await (sourceElement! || browser).isElementPresent(cssSelector);\n if (!isElPresent) {\n console.warn(`No component matching ${selector} found`);\n return;\n }\n const queriedElement = sourceElement ? sourceElement.element(cssSelector) : element(cssSelector);\n return returnType ? new returnType(queriedElement) : new O3rElement(queriedElement);\n }\n\n /** @inheritdoc */\n public async queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const item = (sourceElement || element).all(By.css(selector)).get(index);\n if (!(await item.isPresent())) {\n console.warn(`No component matching ${selector}:nth(${index}) found`);\n return;\n }\n return new (returnType || O3rElement)(item);\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n _timeout?: number\n ): Promise<(T | O3rElement)[] | K> {\n const pElements = (this.rootElement ? this.rootElement.sourceElement.all(By.css(selector)) : element.all(By.css(selector)))\n .filter((item) => typeof item !== 'undefined')\n .then((elf: ElementFinder[]) => elf.map((item) => (returnType ? new returnType(item) : new O3rElement(item))));\n const elements = await convertPromise(pElements);\n\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return Promise.resolve(group);\n }\n\n return elements;\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.rootElement;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{[componentName: string]: ComponentFixtureProfile[]}> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public async queryNotPresent(selector: string, _timeout?: number): Promise<boolean> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n return !(await (sourceElement || browser).isElementPresent(By.css(selector)));\n }\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { promise as pPromise } from 'protractor';
|
|
2
2
|
/**
|
|
3
3
|
* Converts a webdriver promise to ES6 promise so the rest of the framework handles ES6 promises only
|
|
4
|
-
*
|
|
5
4
|
* @param promise
|
|
6
5
|
*/
|
|
7
6
|
export declare function convertPromise<T>(promise: pPromise.Promise<T>): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/protractor/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/protractor/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,cAE7D"}
|
package/core/protractor/utils.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.convertPromise = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Converts a webdriver promise to ES6 promise so the rest of the framework handles ES6 promises only
|
|
6
|
-
*
|
|
7
6
|
* @param promise
|
|
8
7
|
*/
|
|
9
8
|
function convertPromise(promise) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/protractor/utils.ts"],"names":[],"mappings":";;;AAEA
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/protractor/utils.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;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;AAFD,wCAEC","sourcesContent":["import {promise as pPromise} from 'protractor';\n\n/**\n * Converts a webdriver promise to ES6 promise so the rest of the framework handles ES6 promises only\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"]}
|
|
@@ -20,13 +20,11 @@ export interface UpdateDatesInMocksOptions {
|
|
|
20
20
|
converter: {
|
|
21
21
|
/**
|
|
22
22
|
* Converter from Temporal to string
|
|
23
|
-
*
|
|
24
23
|
* @param input
|
|
25
24
|
*/
|
|
26
25
|
fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;
|
|
27
26
|
/**
|
|
28
27
|
* Converter from string to Temporal
|
|
29
|
-
*
|
|
30
28
|
* @param input
|
|
31
29
|
*/
|
|
32
30
|
toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;
|
|
@@ -34,7 +32,6 @@ export interface UpdateDatesInMocksOptions {
|
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* Update mock checksum and response body to keep using the same mocks every day with updated dates
|
|
37
|
-
*
|
|
38
35
|
* @param mock the mock instance provided by the hook method of Kassette
|
|
39
36
|
* @param inputOptions default options will extract ISO strings and use 'day-offset' mode
|
|
40
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-dates-in-mocks.d.ts","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,EAAE,KAAK,GAAG,YAAY,GAAG,kBAAkB,CAAC;IAChD;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE;QACT
|
|
1
|
+
{"version":3,"file":"update-dates-in-mocks.d.ts","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,EAAE,KAAK,GAAG,YAAY,GAAG,kBAAkB,CAAC;IAChD;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE;QACT;;;WAGG;QACH,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,SAAS,KAAK,MAAM,CAAC;QACzE;;;WAGG;QACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC;KACxE,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,GAAE,OAAO,CAAC,yBAAyB,CAAM,iBAsE1G"}
|
|
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var temporal_polyfill_1 = require("temporal-polyfill");
|
|
6
6
|
/**
|
|
7
7
|
* Update mock checksum and response body to keep using the same mocks every day with updated dates
|
|
8
|
-
*
|
|
9
8
|
* @param mock the mock instance provided by the hook method of Kassette
|
|
10
9
|
* @param inputOptions default options will extract ISO strings and use 'day-offset' mode
|
|
11
10
|
*/
|
|
@@ -30,12 +29,15 @@ function updateDatesInMocks(mock, inputOptions) {
|
|
|
30
29
|
todayTime = temporal_polyfill_1.Temporal.Now.plainDateISO();
|
|
31
30
|
replaceDatesInInput = function (input) {
|
|
32
31
|
switch (options.mode) {
|
|
33
|
-
case 'any':
|
|
32
|
+
case 'any': {
|
|
34
33
|
return input.replace(options.extractor, '<any>');
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
case 'day-offset': {
|
|
36
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
|
-
|
|
37
|
+
}
|
|
38
|
+
case 'same-day-of-week': {
|
|
38
39
|
return input.replace(options.extractor, function (match) { return "<day ".concat(options.converter.toDate(match).dayOfWeek, " next week>"); });
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
return input;
|
|
41
43
|
};
|
|
@@ -70,10 +72,12 @@ function updateDatesInMocks(mock, inputOptions) {
|
|
|
70
72
|
replaceDatesInOutput = function (output) {
|
|
71
73
|
switch (options.mode) {
|
|
72
74
|
case 'any':
|
|
73
|
-
case 'day-offset':
|
|
75
|
+
case 'day-offset': {
|
|
74
76
|
return output.replace(options.extractor, function (match) { return options.converter.fromDate(options.converter.toDate(match).add(timeOffset_1)); });
|
|
75
|
-
|
|
77
|
+
}
|
|
78
|
+
case 'same-day-of-week': {
|
|
76
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
|
+
}
|
|
77
81
|
}
|
|
78
82
|
return output;
|
|
79
83
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;;;AACA,uDAA2C;
|
|
1
|
+
{"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;;;AACA,uDAA2C;AAiC3C;;;;GAIG;AACH,SAAsB,kBAAkB,CAAC,IAAW,EAAE,YAAqD;;IAArD,6BAAA,EAAA,iBAAqD;;;;;;oBACnG,eAAe,GAAG,qBAAqB,CAAC,MAAM,CAAC;oBAC/C,OAAO,sBACX,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,6BAA6B,EACxC,SAAS,EAAE;4BACT,QAAQ,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,EAA7C,CAA6C;4BACjE,MAAM,EAAE,UAAC,KAAK;gCACZ,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gCAC1D,OAAO,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC;oCACrC,4BAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,UAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,cAAI,KAAK,CAAC,OAAO,CAAC,u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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: UpdateDatesInMocksOptions = {\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 };\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"]}
|
|
@@ -14,7 +14,6 @@ export interface MockTranslations {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Function to get the list of modules required to test component using Localization module
|
|
17
|
-
*
|
|
18
17
|
* @param localizationConfiguration Localization configuration
|
|
19
18
|
* @param translations Translations to use
|
|
20
19
|
* @param translationCompilerProvider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localization-mock.d.ts","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAkB,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAA6B,MAAM,mBAAmB,CAAC;AAU7G,qBACa,iBAAkB,YAAW,aAAa;IAC9C,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED,qBAIa,2BAA2B;WACxB,OAAO,IAAI,mBAAmB,CAAC,2BAA2B,CAAC;CAM1E;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED
|
|
1
|
+
{"version":3,"file":"localization-mock.d.ts","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAkB,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAA6B,MAAM,mBAAmB,CAAC;AAU7G,qBACa,iBAAkB,YAAW,aAAa;IAC9C,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED,qBAIa,2BAA2B;WACxB,OAAO,IAAI,mBAAmB,CAAC,2BAA2B,CAAC;CAM1E;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,yBAAyB,GAAE,OAAO,CAAC,yBAAyB,CAAoC,EAChG,YAAY,GAAE,gBAAqB,EACnC,2BAA2B,CAAC,EAAE,QAAQ,EACtC,QAAQ,UAAQ,GACf,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,CAc3C"}
|
|
@@ -12,7 +12,7 @@ var defaultLocalizationConfiguration = {
|
|
|
12
12
|
endPointUrl: '',
|
|
13
13
|
fallbackLanguage: 'en'
|
|
14
14
|
};
|
|
15
|
-
var TranslatePipeMock =
|
|
15
|
+
var TranslatePipeMock = /** @class */ (function () {
|
|
16
16
|
function TranslatePipeMock() {
|
|
17
17
|
}
|
|
18
18
|
TranslatePipeMock.prototype.transform = function () {
|
|
@@ -27,7 +27,8 @@ var TranslatePipeMock = exports.TranslatePipeMock = /** @class */ (function () {
|
|
|
27
27
|
], TranslatePipeMock);
|
|
28
28
|
return TranslatePipeMock;
|
|
29
29
|
}());
|
|
30
|
-
|
|
30
|
+
exports.TranslatePipeMock = TranslatePipeMock;
|
|
31
|
+
var LocalizationDependencyMocks = /** @class */ (function () {
|
|
31
32
|
function LocalizationDependencyMocks() {
|
|
32
33
|
}
|
|
33
34
|
LocalizationDependencyMocks_1 = LocalizationDependencyMocks;
|
|
@@ -46,9 +47,9 @@ var LocalizationDependencyMocks = exports.LocalizationDependencyMocks = /** @cla
|
|
|
46
47
|
], LocalizationDependencyMocks);
|
|
47
48
|
return LocalizationDependencyMocks;
|
|
48
49
|
}());
|
|
50
|
+
exports.LocalizationDependencyMocks = LocalizationDependencyMocks;
|
|
49
51
|
/**
|
|
50
52
|
* Function to get the list of modules required to test component using Localization module
|
|
51
|
-
*
|
|
52
53
|
* @param localizationConfiguration Localization configuration
|
|
53
54
|
* @param translations Translations to use
|
|
54
55
|
* @param translationCompilerProvider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localization-mock.js","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":";;;;AAAA,sCAA6F;AAC7F,4CAAuE;AACvE,kDAA6G;AAC7G,6BAA0B;AAE1B,IAAM,gCAAgC,GAAuC;IAC3E,gBAA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,AAJD,IAIC;AAJY,8CAAiB;AAU9B;IAAA;IAOA,CAAC;oCAPY,2BAA2B;IACxB,mCAAO,GAArB;QACE,OAAO;YACL,QAAQ,EAAE,6BAA2B;YACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,wCAAyB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;SACjF,CAAC;IACJ,CAAC;;IANU,2BAA2B;QAJvC,IAAA,eAAQ,EAAC;YACR,YAAY,EAAE,CAAC,iBAAiB,CAAC;YACjC,OAAO,EAAE,CAAC,iBAAiB,CAAC;SAC7B,CAAC;OACW,2BAA2B,CAOvC;IAAD,kCAAC;CAAA,AAPD,IAOC;AAPY,kEAA2B;AAgBxC;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,yBAAgG,EAChG,YAAmC,EACnC,2BAAsC,EACtC,QAAgB;IAHhB,0CAAA,EAAA,4DAAgG;IAChG,6BAAA,EAAA,iBAAmC;IAEnC,yBAAA,EAAA,gBAAgB;IAEhB;QACE,iCAAkB,CAAC,OAAO,CAAC,cAAM,OAAA,yBAAyB,EAAzB,CAAyB,CAAC;QAC3D,sBAAe,CAAC,OAAO,CAAC;YACtB,MAAM,EAAE;gBACN,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE;oBACR,cAAc,EAAE,UAAC,IAAY,IAAK,OAAA,IAAA,SAAE,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAtB,CAAsB;iBACzD;aACF;YACD,QAAQ,EAAE,2BAA2B;SACtC,CAAC;OACC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAC5D;AACJ,CAAC;AAnBD,wDAmBC","sourcesContent":["import { ModuleWithProviders, NgModule, Pipe, PipeTransform, Provider } from '@angular/core';\nimport { TranslateLoader, TranslateModule } from '@ngx-translate/core';\nimport { LocalizationConfiguration, LocalizationModule, LocalizationTranslatePipe } from '@o3r/localization';\nimport { of } from 'rxjs';\n\nconst defaultLocalizationConfiguration: Partial<LocalizationConfiguration> = {\n supportedLocales: ['en'],\n language: 'en',\n endPointUrl: '',\n fallbackLanguage: 'en'\n};\n\n@Pipe({ name: 'translate' })\nexport class TranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@NgModule({\n declarations: [TranslatePipeMock],\n exports: [TranslatePipeMock]\n})\nexport class LocalizationDependencyMocks {\n public static forTest(): ModuleWithProviders<LocalizationDependencyMocks> {\n return {\n ngModule: LocalizationDependencyMocks,\n providers: [{ provide: LocalizationTranslatePipe, useClass: TranslatePipeMock }]\n };\n }\n}\n\n/** Mock to provide to the MockTranslation module */\nexport interface MockTranslations {\n [lang: string]: {\n [key: string]: any;\n };\n}\n\n/**\n * Function to get the list of modules required to test component using Localization module\n * @param localizationConfiguration Localization configuration\n * @param translations Translations to use\n * @param translationCompilerProvider\n * @param mockPipe Enable Translation pipe mocking\n * @returns List of modules to import in your TestBed\n */\nexport function mockTranslationModules(\n localizationConfiguration: Partial<LocalizationConfiguration> = defaultLocalizationConfiguration,\n translations: MockTranslations = {},\n translationCompilerProvider?: Provider,\n mockPipe = false\n): ModuleWithProviders<LocalizationModule>[] {\n return [\n LocalizationModule.forRoot(() => localizationConfiguration),\n TranslateModule.forRoot({\n loader: {\n provide: TranslateLoader,\n useValue: {\n getTranslation: (lang: string) => of(translations[lang])\n }\n },\n compiler: translationCompilerProvider\n }),\n ...(mockPipe ? [LocalizationDependencyMocks.forTest()] : [])\n ];\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Type } from '@angular/core';
|
|
2
2
|
/**
|
|
3
3
|
* Generate a mock class base on a component file
|
|
4
|
-
*
|
|
5
4
|
* @param componentPath Path to the component file to mock
|
|
6
5
|
* @param config Object containing the following configurations:
|
|
7
6
|
* template: should be provided if the template contain `<ng-content></ng-content>`
|
|
@@ -9,15 +8,17 @@ import { Type } from '@angular/core';
|
|
|
9
8
|
* @param config.template
|
|
10
9
|
* @param config.isControlValueAccessor
|
|
11
10
|
* @example
|
|
11
|
+
* ```typescript
|
|
12
12
|
* // hero.component.ts
|
|
13
|
-
*
|
|
13
|
+
* \@Component({selector: 'hero'})
|
|
14
14
|
* class HeroComponent {
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* \@Input() name: string;
|
|
16
|
+
* \@Output() doSomething: EventEmitter<void>
|
|
17
17
|
* }
|
|
18
18
|
*
|
|
19
19
|
* // mock generation
|
|
20
20
|
* class MockComponent extends generateMockComponent('hero.component.ts') {}
|
|
21
|
+
* ```
|
|
21
22
|
*/
|
|
22
23
|
export declare function generateMockComponent<T extends unknown = Record<string, unknown>>(componentPath: string, config?: {
|
|
23
24
|
template?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-component-generator.d.ts","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-component-generator.d.ts","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,IAAI,EAAE,MAAM,eAAe,CAAC;AAwG1E;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAuCnL"}
|