@o3r/testing 13.0.0-next.26 → 13.0.0-next.28
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/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 +16 -15
- package/public_api.js +1 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +4 -6
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/playwright/index.d.ts.map +1 -1
- package/schematics/ng-add/playwright/index.js +3 -4
- package/schematics/ng-add/playwright/index.js.map +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 -20
- package/tools/path-replacement/path-replacement.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,124 +1,62 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.MatSelect = void 0;
|
4
|
-
|
5
|
-
var element_1 = require("../element");
|
4
|
+
const element_1 = require("../element");
|
6
5
|
/**
|
7
6
|
* Implementation dedicated to Playwright.
|
8
7
|
*/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
return _super.call(this, sourceElement) || this;
|
8
|
+
class MatSelect extends element_1.O3rElement {
|
9
|
+
constructor(sourceElement) {
|
10
|
+
super(sourceElement);
|
13
11
|
}
|
14
12
|
/** @inheritdoc */
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return [4 /*yield*/, options.count()];
|
29
|
-
case 3:
|
30
|
-
if ((_a.sent()) >= index + 1) {
|
31
|
-
selectedOption = { element: options.nth(index), page: this.sourceElement.page };
|
32
|
-
option = new element_1.O3rElement(selectedOption);
|
33
|
-
return [2 /*return*/, option.click()];
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
return [2 /*return*/, Promise.reject(new Error("Option with index ".concat(index, " not found in select element.")))];
|
37
|
-
}
|
38
|
-
return [2 /*return*/];
|
39
|
-
}
|
40
|
-
});
|
41
|
-
});
|
42
|
-
};
|
13
|
+
async selectByIndex(index, timeout = 5000) {
|
14
|
+
await this.click();
|
15
|
+
const options = this.sourceElement.page.locator('mat-option');
|
16
|
+
await options.first().waitFor({ state: 'attached', timeout });
|
17
|
+
if ((await options.count()) >= index + 1) {
|
18
|
+
const selectedOption = { element: options.nth(index), page: this.sourceElement.page };
|
19
|
+
const option = new element_1.O3rElement(selectedOption);
|
20
|
+
return option.click();
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
return Promise.reject(new Error(`Option with index ${index} not found in select element.`));
|
24
|
+
}
|
25
|
+
}
|
43
26
|
/** @inheritdoc */
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
case 3:
|
59
|
-
optionsCount = _a.sent();
|
60
|
-
i = 0;
|
61
|
-
_a.label = 4;
|
62
|
-
case 4:
|
63
|
-
if (!(i < optionsCount)) return [3 /*break*/, 7];
|
64
|
-
selectedOption = { element: options.nth(i), page: this.sourceElement.page };
|
65
|
-
option = new element_1.O3rElement(selectedOption);
|
66
|
-
return [4 /*yield*/, option.getAttribute('ng-reflect-value')];
|
67
|
-
case 5:
|
68
|
-
if ((_a.sent()) === value) {
|
69
|
-
return [2 /*return*/, option.click()];
|
70
|
-
}
|
71
|
-
_a.label = 6;
|
72
|
-
case 6:
|
73
|
-
i++;
|
74
|
-
return [3 /*break*/, 4];
|
75
|
-
case 7: return [2 /*return*/, Promise.reject(new Error("Option with value ".concat(value, " not found in select element.")))];
|
76
|
-
}
|
77
|
-
});
|
78
|
-
});
|
79
|
-
};
|
27
|
+
async selectByValue(value, timeout = 5000) {
|
28
|
+
await this.click();
|
29
|
+
const options = this.sourceElement.page.locator('mat-option');
|
30
|
+
await options.first().waitFor({ state: 'attached', timeout });
|
31
|
+
const optionsCount = await options.count();
|
32
|
+
for (let i = 0; i < optionsCount; i++) {
|
33
|
+
const selectedOption = { element: options.nth(i), page: this.sourceElement.page };
|
34
|
+
const option = new element_1.O3rElement(selectedOption);
|
35
|
+
if (await option.getAttribute('ng-reflect-value') === value) {
|
36
|
+
return option.click();
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return Promise.reject(new Error(`Option with value ${value} not found in select element.`));
|
40
|
+
}
|
80
41
|
/** @inheritdoc */
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
case 3:
|
96
|
-
optionsCount = _a.sent();
|
97
|
-
i = 0;
|
98
|
-
_a.label = 4;
|
99
|
-
case 4:
|
100
|
-
if (!(i < optionsCount)) return [3 /*break*/, 7];
|
101
|
-
selectedOption = { element: options.nth(i), page: this.sourceElement.page };
|
102
|
-
option = new element_1.O3rElement(selectedOption);
|
103
|
-
return [4 /*yield*/, option.getText()];
|
104
|
-
case 5:
|
105
|
-
if ((_a.sent()) === label) {
|
106
|
-
return [2 /*return*/, option.click()];
|
107
|
-
}
|
108
|
-
_a.label = 6;
|
109
|
-
case 6:
|
110
|
-
i++;
|
111
|
-
return [3 /*break*/, 4];
|
112
|
-
case 7: return [2 /*return*/, Promise.reject(new Error("Option with label ".concat(label, " not found in select element.")))];
|
113
|
-
}
|
114
|
-
});
|
115
|
-
});
|
116
|
-
};
|
42
|
+
async selectByLabel(label, timeout = 5000) {
|
43
|
+
await this.click();
|
44
|
+
const options = this.sourceElement.page.locator('mat-option');
|
45
|
+
await options.first().waitFor({ state: 'attached', timeout });
|
46
|
+
const optionsCount = await options.count();
|
47
|
+
for (let i = 0; i < optionsCount; i++) {
|
48
|
+
const selectedOption = { element: options.nth(i), page: this.sourceElement.page };
|
49
|
+
const option = new element_1.O3rElement(selectedOption);
|
50
|
+
if (await option.getText() === label) {
|
51
|
+
return option.click();
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return Promise.reject(new Error(`Option with label ${label} not found in select element.`));
|
55
|
+
}
|
117
56
|
/** @inheritDoc */
|
118
|
-
|
57
|
+
getValue() {
|
119
58
|
throw new Error('Cannot use "getValue" function on a Material Select element. Use "getPlainText()" instead.');
|
120
|
-
}
|
121
|
-
|
122
|
-
}(element_1.O3rElement));
|
59
|
+
}
|
60
|
+
}
|
123
61
|
exports.MatSelect = MatSelect;
|
124
62
|
//# sourceMappingURL=select-material.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/select-material.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/select-material.ts"],"names":[],"mappings":";;;AAGA,wCAGoB;AAEpB;;GAEG;AACH,MAAa,SAAU,SAAQ,oBAAU;IACvC,YAAY,aAAmD;QAC7D,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,OAAO,GAAG,IAAI;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CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,KAAK,+BAA+B,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,kBAAkB;IACX,QAAQ;QACb,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAChH,CAAC;CACF;AAxDD,8BAwDC","sourcesContent":["import {\n MatSelectProfile,\n} from '../../angular-materials';\nimport {\n O3rElement,\n PlaywrightSourceElement,\n} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatSelect extends O3rElement implements MatSelectProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByIndex(index: number, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n if ((await options.count()) >= index + 1) {\n const selectedOption = { element: options.nth(index), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n const option = new O3rElement(selectedOption);\n return option.click();\n } else {\n return Promise.reject(new Error(`Option with index ${index} not found in select element.`));\n }\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n const optionsCount = await options.count();\n for (let i = 0; i < optionsCount; i++) {\n const selectedOption = { element: options.nth(i), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n const option = new O3rElement(selectedOption);\n if (await option.getAttribute('ng-reflect-value') === value) {\n return option.click();\n }\n }\n return Promise.reject(new Error(`Option with value ${value} not found in select element.`));\n }\n\n /** @inheritdoc */\n public async selectByLabel(label: string, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n const optionsCount = await options.count();\n for (let i = 0; i < optionsCount; i++) {\n const selectedOption = { element: options.nth(i), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n const option = new O3rElement(selectedOption);\n if (await option.getText() === label) {\n return option.click();\n }\n }\n\n return Promise.reject(new Error(`Option with label ${label} not found in select element.`));\n }\n\n /** @inheritDoc */\n public getValue(): Promise<string | undefined> {\n throw new Error('Cannot use \"getValue\" function on a Material Select element. Use \"getPlainText()\" instead.');\n }\n}\n"]}
|
@@ -1,19 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.MatSlider = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
var THUMB_CLASS = 'mdc-slider__thumb';
|
4
|
+
const elements_1 = require("../elements");
|
5
|
+
const TRACK_CLASS = 'mdc-slider__track';
|
6
|
+
const THUMB_CLASS = 'mdc-slider__thumb';
|
8
7
|
/**
|
9
8
|
* Implementation dedicated to Playwright.
|
10
9
|
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return _super.call(this, sourceElement, ".".concat(TRACK_CLASS), ".".concat(THUMB_CLASS)) || this;
|
10
|
+
class MatSlider extends elements_1.O3rSliderElement {
|
11
|
+
constructor(sourceElement) {
|
12
|
+
super(sourceElement, `.${TRACK_CLASS}`, `.${THUMB_CLASS}`);
|
15
13
|
}
|
16
|
-
|
17
|
-
}(elements_1.O3rSliderElement));
|
14
|
+
}
|
18
15
|
exports.MatSlider = MatSlider;
|
19
16
|
//# sourceMappingURL=slider-material.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"slider-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/slider-material.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"slider-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/slider-material.ts"],"names":[],"mappings":";;;AAUA,0CAEqB;AAErB,MAAM,WAAW,GAA4B,mBAAmB,CAAC;AACjE,MAAM,WAAW,GAA4B,mBAAmB,CAAC;AAEjE;;GAEG;AACH,MAAa,SAAU,SAAQ,2BAAgB;IAC7C,YAAY,aAAmD;QAC7D,KAAK,CAAC,aAAa,EAAE,IAAI,WAAW,EAAE,EAAE,IAAI,WAAW,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAJD,8BAIC","sourcesContent":["import type {\n cssClasses,\n} from '@material/slider';\nimport type {\n MatSliderProfile,\n} from '../../angular-materials';\nimport {\n O3rElement,\n type PlaywrightSourceElement,\n} from '../element';\nimport {\n O3rSliderElement,\n} from '../elements';\n\nconst TRACK_CLASS: typeof cssClasses.TRACK = 'mdc-slider__track';\nconst THUMB_CLASS: typeof cssClasses.THUMB = 'mdc-slider__thumb';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatSlider extends O3rSliderElement implements MatSliderProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement, `.${TRACK_CLASS}`, `.${THUMB_CLASS}`);\n }\n}\n"]}
|
@@ -1,20 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.O3rComponentFixture = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
var element_1 = require("./element");
|
4
|
+
const index_1 = require("../../errors/index");
|
5
|
+
const helpers_1 = require("../helpers");
|
6
|
+
const element_1 = require("./element");
|
8
7
|
/**
|
9
8
|
* Implementation of the fixture dedicated to Playwright, hence using the webdriver to interact with the dom.
|
10
9
|
*/
|
11
|
-
|
10
|
+
class O3rComponentFixture {
|
12
11
|
/**
|
13
12
|
* Root element of this fixture.
|
14
13
|
* All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.
|
15
14
|
* @param rootElement
|
16
15
|
*/
|
17
|
-
|
16
|
+
constructor(rootElement) {
|
18
17
|
this.rootElement = rootElement;
|
19
18
|
}
|
20
19
|
/**
|
@@ -23,45 +22,26 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
23
22
|
* @param element ElementProfile to test
|
24
23
|
* @param timeout specific timeout that will throw when reach
|
25
24
|
*/
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
}
|
34
|
-
return [4 /*yield*/, element.sourceElement.element.first().waitFor({ state: 'attached', timeout: timeout })];
|
35
|
-
case 1:
|
36
|
-
_a.sent();
|
37
|
-
return [2 /*return*/, element];
|
38
|
-
}
|
39
|
-
});
|
40
|
-
});
|
41
|
-
};
|
25
|
+
async throwOnUndefinedElement(element, timeout) {
|
26
|
+
if (!element) {
|
27
|
+
throw new Error('Element not found in ' + this.constructor.name);
|
28
|
+
}
|
29
|
+
await element.sourceElement.element.first().waitFor({ state: 'attached', timeout });
|
30
|
+
return element;
|
31
|
+
}
|
42
32
|
/**
|
43
33
|
* Throws an exception if the element is undefined.
|
44
34
|
* Otherwise returns the element.
|
45
35
|
* @param element ElementProfile to test
|
46
36
|
* @param timeout specific timeout that will throw when reach
|
47
37
|
*/
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return
|
53
|
-
|
54
|
-
|
55
|
-
case 1:
|
56
|
-
el = _a.sent();
|
57
|
-
return [4 /*yield*/, el.sourceElement.element.first().waitFor({ state: 'attached' })];
|
58
|
-
case 2:
|
59
|
-
_a.sent();
|
60
|
-
return [2 /*return*/, el];
|
61
|
-
}
|
62
|
-
});
|
63
|
-
}); })(), timeout);
|
64
|
-
};
|
38
|
+
throwOnUndefined(element, timeout) {
|
39
|
+
return (0, helpers_1.withTimeout)((async () => {
|
40
|
+
const el = await element;
|
41
|
+
await el.sourceElement.element.first().waitFor({ state: 'attached' });
|
42
|
+
return el;
|
43
|
+
})(), timeout);
|
44
|
+
}
|
65
45
|
/**
|
66
46
|
* Get the element associated to the selector if present
|
67
47
|
* @param selector Selector to access the element
|
@@ -71,23 +51,13 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
71
51
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
72
52
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
73
53
|
*/
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
case 1:
|
82
|
-
element = _a.sent();
|
83
|
-
if (options.shouldThrowIfNotPresent) {
|
84
|
-
return [2 /*return*/, this.throwOnUndefinedElement(element, options.timeout)];
|
85
|
-
}
|
86
|
-
return [2 /*return*/, element];
|
87
|
-
}
|
88
|
-
});
|
89
|
-
});
|
90
|
-
};
|
54
|
+
async queryWithOptions(selector, elementConstructor, options = {}) {
|
55
|
+
const element = await (options.index === undefined ? this.query(selector, elementConstructor) : this.queryNth(selector, options.index, elementConstructor));
|
56
|
+
if (options.shouldThrowIfNotPresent) {
|
57
|
+
return this.throwOnUndefinedElement(element, options.timeout);
|
58
|
+
}
|
59
|
+
return element;
|
60
|
+
}
|
91
61
|
/**
|
92
62
|
* Get text from the element associated to the given selector, or undefined if the element is not found or not visible
|
93
63
|
* @param selector Selector to access the element
|
@@ -97,26 +67,13 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
97
67
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
98
68
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
99
69
|
*/
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
case 1:
|
108
|
-
element = _a.sent();
|
109
|
-
return [4 /*yield*/, element.isVisible()];
|
110
|
-
case 2:
|
111
|
-
if (!(_a.sent())) {
|
112
|
-
return [2 /*return*/];
|
113
|
-
}
|
114
|
-
return [4 /*yield*/, element.getText()];
|
115
|
-
case 3: return [2 /*return*/, _a.sent()];
|
116
|
-
}
|
117
|
-
});
|
118
|
-
});
|
119
|
-
};
|
70
|
+
async getText(selector, options = {}) {
|
71
|
+
const element = await this.queryWithOptions(selector, options.elementConstructor, options);
|
72
|
+
if (!await element.isVisible()) {
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
return await element.getText();
|
76
|
+
}
|
120
77
|
/**
|
121
78
|
* Check if the element associated to the given selector is visible
|
122
79
|
* @param selector Selector to access the element
|
@@ -126,21 +83,10 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
126
83
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
127
84
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
128
85
|
*/
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
return tslib_1.__generator(this, function (_a) {
|
134
|
-
switch (_a.label) {
|
135
|
-
case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
|
136
|
-
case 1:
|
137
|
-
element = _a.sent();
|
138
|
-
return [4 /*yield*/, element.isVisible()];
|
139
|
-
case 2: return [2 /*return*/, _a.sent()];
|
140
|
-
}
|
141
|
-
});
|
142
|
-
});
|
143
|
-
};
|
86
|
+
async isVisible(selector, options = {}) {
|
87
|
+
const element = await this.queryWithOptions(selector, options.elementConstructor, options);
|
88
|
+
return await element.isVisible();
|
89
|
+
}
|
144
90
|
/**
|
145
91
|
* Click on the element associated to the given selector if it exists and is visible
|
146
92
|
* @param selector Selector to access the element
|
@@ -150,96 +96,65 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
150
96
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
151
97
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
152
98
|
*/
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
case 2:
|
164
|
-
if (!_a.sent()) return [3 /*break*/, 4];
|
165
|
-
return [4 /*yield*/, element.click()];
|
166
|
-
case 3:
|
167
|
-
_a.sent();
|
168
|
-
_a.label = 4;
|
169
|
-
case 4: return [2 /*return*/];
|
170
|
-
}
|
171
|
-
});
|
172
|
-
});
|
173
|
-
};
|
174
|
-
O3rComponentFixture.prototype.query = function (selector, returnType) {
|
175
|
-
var elements = this.rootElement.sourceElement.element.locator(selector);
|
176
|
-
var element = elements.first();
|
177
|
-
var selectedElement = { element: element, page: this.rootElement.sourceElement.page };
|
99
|
+
async click(selector, options = {}) {
|
100
|
+
const element = await this.queryWithOptions(selector, options.elementConstructor, options);
|
101
|
+
if (await element.isVisible()) {
|
102
|
+
await element.click();
|
103
|
+
}
|
104
|
+
}
|
105
|
+
query(selector, returnType) {
|
106
|
+
const elements = this.rootElement.sourceElement.element.locator(selector);
|
107
|
+
const element = elements.first();
|
108
|
+
const selectedElement = { element: element, page: this.rootElement.sourceElement.page };
|
178
109
|
return Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement));
|
179
|
-
}
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
110
|
+
}
|
111
|
+
queryNth(selector, index, returnType) {
|
112
|
+
const elements = this.rootElement.sourceElement.element.locator(selector);
|
113
|
+
const element = elements.nth(index);
|
114
|
+
const selectedElement = { element: element, page: this.rootElement.sourceElement.page };
|
184
115
|
return Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement));
|
185
|
-
}
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
pElementsCount = _a.sent();
|
204
|
-
elements = [];
|
205
|
-
for (i = 0; i < pElementsCount; i++) {
|
206
|
-
selectedElement = { element: pElements.nth(i), page: this.rootElement.sourceElement.page };
|
207
|
-
elements.push(returnType ? new returnType(selectedElement) : new element_1.O3rElement(selectedElement));
|
208
|
-
}
|
209
|
-
if (!groupType) return [3 /*break*/, 4];
|
210
|
-
group = new groupType(elements);
|
211
|
-
return [4 /*yield*/, group.isValidGroup()];
|
212
|
-
case 3:
|
213
|
-
isValid = _a.sent();
|
214
|
-
if (!isValid) {
|
215
|
-
throw new index_1.FixtureUsageError('invalid group of items');
|
216
|
-
}
|
217
|
-
return [2 /*return*/, group];
|
218
|
-
case 4: return [2 /*return*/, elements];
|
219
|
-
case 5:
|
220
|
-
err_1 = _a.sent();
|
221
|
-
// eslint-disable-next-line no-console -- no other logger available
|
222
|
-
console.warn("Failed to query all ".concat(selector), err_1);
|
223
|
-
return [2 /*return*/, Promise.resolve([])];
|
224
|
-
case 6: return [2 /*return*/];
|
116
|
+
}
|
117
|
+
async queryAll(selector, returnType, groupType, timeout = 5000) {
|
118
|
+
try {
|
119
|
+
const sourceElement = this.rootElement.sourceElement.element;
|
120
|
+
const pElements = sourceElement.locator(selector);
|
121
|
+
// Mandatory because count is not reliable if we don't wait for the list to be attached
|
122
|
+
await pElements.first().waitFor({ state: 'attached', timeout });
|
123
|
+
const pElementsCount = await pElements.count();
|
124
|
+
const elements = [];
|
125
|
+
for (let i = 0; i < pElementsCount; i++) {
|
126
|
+
const selectedElement = { element: pElements.nth(i), page: this.rootElement.sourceElement.page };
|
127
|
+
elements.push(returnType ? new returnType(selectedElement) : new element_1.O3rElement(selectedElement));
|
128
|
+
}
|
129
|
+
if (groupType) {
|
130
|
+
const group = new groupType(elements);
|
131
|
+
const isValid = await group.isValidGroup();
|
132
|
+
if (!isValid) {
|
133
|
+
throw new index_1.FixtureUsageError('invalid group of items');
|
225
134
|
}
|
226
|
-
|
227
|
-
|
228
|
-
|
135
|
+
return group;
|
136
|
+
}
|
137
|
+
return elements;
|
138
|
+
}
|
139
|
+
catch (err) {
|
140
|
+
// eslint-disable-next-line no-console -- no other logger available
|
141
|
+
console.warn(`Failed to query all ${selector}`, err);
|
142
|
+
return Promise.resolve([]);
|
143
|
+
}
|
144
|
+
}
|
229
145
|
/** @inheritdoc */
|
230
|
-
|
146
|
+
getElement() {
|
231
147
|
return this.rootElement;
|
232
|
-
}
|
148
|
+
}
|
233
149
|
/** @inheritdoc */
|
234
|
-
|
150
|
+
getSubComponents() {
|
235
151
|
return Promise.resolve({ block: [this] });
|
236
|
-
}
|
152
|
+
}
|
237
153
|
/** @inheritDoc */
|
238
|
-
|
239
|
-
|
154
|
+
queryNotPresent(selector) {
|
155
|
+
const element = this.rootElement.sourceElement.element.locator(selector).first();
|
240
156
|
return element.isHidden();
|
241
|
-
}
|
242
|
-
|
243
|
-
}());
|
157
|
+
}
|
158
|
+
}
|
244
159
|
exports.O3rComponentFixture = O3rComponentFixture;
|
245
160
|
//# sourceMappingURL=component-fixture.js.map
|