@o3r/testing 12.4.1 → 12.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/angular/angular-materials/autocomplete-material.js +9 -20
- package/core/angular/angular-materials/autocomplete-material.js.map +1 -1
- package/core/angular/angular-materials/index.js +1 -1
- package/core/angular/angular-materials/select-material.js +42 -91
- package/core/angular/angular-materials/select-material.js.map +1 -1
- package/core/angular/angular-materials/slider-material.js +8 -11
- package/core/angular/angular-materials/slider-material.js.map +1 -1
- package/core/angular/component-fixture.js +68 -148
- package/core/angular/component-fixture.js.map +1 -1
- package/core/angular/element.js +44 -50
- package/core/angular/element.js.map +1 -1
- package/core/angular/elements/checkbox-element.js +12 -16
- package/core/angular/elements/checkbox-element.js.map +1 -1
- package/core/angular/elements/index.js +1 -1
- package/core/angular/elements/radio-element.js +12 -16
- package/core/angular/elements/radio-element.js.map +1 -1
- package/core/angular/elements/select-element.js +28 -49
- package/core/angular/elements/select-element.js.map +1 -1
- package/core/angular/elements/slider-element.js +38 -42
- package/core/angular/elements/slider-element.js.map +1 -1
- package/core/angular/group.js +9 -14
- package/core/angular/group.js.map +1 -1
- package/core/angular/groups/index.js +1 -1
- package/core/angular/groups/radio-group.js +25 -62
- package/core/angular/groups/radio-group.js.map +1 -1
- package/core/angular/index.js +1 -1
- package/core/angular/page-fixture.js +8 -11
- package/core/angular/page-fixture.js.map +1 -1
- package/core/angular-materials/autocomplete-material.js +8 -11
- package/core/angular-materials/autocomplete-material.js.map +1 -1
- package/core/angular-materials/index.js +1 -1
- package/core/angular-materials/select-material.js +12 -15
- package/core/angular-materials/select-material.js.map +1 -1
- package/core/angular-materials/slider-material.js +5 -8
- package/core/angular-materials/slider-material.js.map +1 -1
- package/core/component-fixture.js +28 -33
- package/core/component-fixture.js.map +1 -1
- package/core/element.js +24 -26
- package/core/element.js.map +1 -1
- package/core/elements/checkbox-element.js +12 -16
- package/core/elements/checkbox-element.js.map +1 -1
- package/core/elements/index.js +1 -1
- package/core/elements/radio-element.js +12 -16
- package/core/elements/radio-element.js.map +1 -1
- package/core/elements/select-element.js +10 -13
- package/core/elements/select-element.js.map +1 -1
- package/core/elements/slider-element.js +5 -8
- package/core/elements/slider-element.js.map +1 -1
- package/core/group.js +9 -15
- package/core/group.js.map +1 -1
- package/core/groups/index.js +1 -1
- package/core/groups/radio-group.js +8 -11
- package/core/groups/radio-group.js.map +1 -1
- package/core/helpers.js +11 -16
- package/core/helpers.js.map +1 -1
- package/core/index.js +1 -1
- package/core/page-fixture.js +8 -11
- package/core/page-fixture.js.map +1 -1
- package/core/playwright/angular-materials/autocomplete-material.js +26 -56
- package/core/playwright/angular-materials/autocomplete-material.js.map +1 -1
- package/core/playwright/angular-materials/index.js +1 -1
- package/core/playwright/angular-materials/select-material.js +48 -110
- package/core/playwright/angular-materials/select-material.js.map +1 -1
- package/core/playwright/angular-materials/slider-material.js +7 -10
- package/core/playwright/angular-materials/slider-material.js.map +1 -1
- package/core/playwright/component-fixture.js +88 -173
- package/core/playwright/component-fixture.js.map +1 -1
- package/core/playwright/element.js +38 -90
- package/core/playwright/element.js.map +1 -1
- package/core/playwright/elements/checkbox-element.js +49 -94
- package/core/playwright/elements/checkbox-element.js.map +1 -1
- package/core/playwright/elements/index.js +1 -1
- package/core/playwright/elements/radio-element.js +18 -34
- package/core/playwright/elements/radio-element.js.map +1 -1
- package/core/playwright/elements/select-element.js +14 -21
- package/core/playwright/elements/select-element.js.map +1 -1
- package/core/playwright/elements/slider-element.js +78 -157
- package/core/playwright/elements/slider-element.js.map +1 -1
- package/core/playwright/group.js +9 -14
- package/core/playwright/group.js.map +1 -1
- package/core/playwright/groups/index.js +1 -1
- package/core/playwright/groups/radio-group.js +27 -64
- package/core/playwright/groups/radio-group.js.map +1 -1
- package/core/playwright/index.js +1 -1
- package/core/playwright/page-fixture.js +8 -18
- package/core/playwright/page-fixture.js.map +1 -1
- package/core/protractor/angular-materials/autocomplete-material.js +12 -26
- package/core/protractor/angular-materials/autocomplete-material.js.map +1 -1
- package/core/protractor/angular-materials/index.js +1 -1
- package/core/protractor/angular-materials/select-material.js +45 -97
- package/core/protractor/angular-materials/select-material.js.map +1 -1
- package/core/protractor/component-fixture.js +89 -200
- package/core/protractor/component-fixture.js.map +1 -1
- package/core/protractor/element.js +46 -118
- package/core/protractor/element.js.map +1 -1
- package/core/protractor/elements/checkbox-element.js +18 -40
- package/core/protractor/elements/checkbox-element.js.map +1 -1
- package/core/protractor/elements/index.js +1 -1
- package/core/protractor/elements/radio-element.js +20 -42
- package/core/protractor/elements/radio-element.js.map +1 -1
- package/core/protractor/elements/select-element.js +16 -37
- package/core/protractor/elements/select-element.js.map +1 -1
- package/core/protractor/group.js +9 -14
- package/core/protractor/group.js.map +1 -1
- package/core/protractor/groups/index.js +1 -1
- package/core/protractor/groups/radio-group.js +29 -66
- package/core/protractor/groups/radio-group.js.map +1 -1
- package/core/protractor/index.js +1 -1
- package/core/protractor/page-fixture.js +9 -12
- package/core/protractor/page-fixture.js.map +1 -1
- package/core/protractor/utils.js +1 -1
- package/core/protractor/utils.js.map +1 -1
- package/errors/fixture-usage-error.js +5 -10
- package/errors/fixture-usage-error.js.map +1 -1
- package/errors/index.js +1 -1
- package/errors/transpilation-purpose-only.js +5 -10
- package/errors/transpilation-purpose-only.js.map +1 -1
- package/kassette/index.js +1 -1
- package/kassette/update-dates-in-mocks.js +66 -85
- package/kassette/update-dates-in-mocks.js.map +1 -1
- package/localization/index.js +1 -1
- package/localization/localization-mock.js +38 -60
- package/localization/localization-mock.js.map +1 -1
- package/mocks/index.js +1 -1
- package/mocks/mock-component-generator.js +54 -53
- package/mocks/mock-component-generator.js.map +1 -1
- package/package.json +11 -11
- package/public_api.js +1 -1
- package/store/index.js +1 -1
- package/store/testable-select.js +13 -13
- package/store/testable-select.js.map +1 -1
- package/tools/index.js +1 -1
- package/tools/path-replacement/index.js +1 -1
- package/tools/path-replacement/path-replacement.js +24 -19
- package/tools/path-replacement/path-replacement.js.map +1 -1
- package/tools/protractor/fetch-manager/index.js +1 -1
- package/tools/protractor/fetch-manager/utils.js +15 -51
- package/tools/protractor/fetch-manager/utils.js.map +1 -1
- package/tools/protractor/index.js +1 -1
- package/tools/protractor/post-message-interceptor/index.js +1 -1
- package/tools/protractor/post-message-interceptor/post-message-interceptor.js +30 -103
- package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
- package/visual-test/index.js +1 -1
- package/visual-test/utils.js +18 -7
- package/visual-test/utils.js.map +1 -1
- package/visual-test/visual-test.js +29 -34
- package/visual-test/visual-test.js.map +1 -1
- package/visual-testing-reporter/index.d.ts.map +1 -1
- package/visual-testing-reporter/index.js +37 -40
- package/visual-testing-reporter/index.js.map +1 -1
@@ -1,113 +1,61 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.MatSelect = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
var element_1 = require("../element");
|
4
|
+
const protractor_1 = require("protractor");
|
5
|
+
const element_1 = require("../element");
|
7
6
|
/**
|
8
7
|
* Implementation dedicated to Protractor.
|
9
8
|
* @deprecated Will be removed in v13, please use Playwright instead
|
10
9
|
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return _super.call(this, sourceElement) || this;
|
10
|
+
class MatSelect extends element_1.O3rElement {
|
11
|
+
constructor(sourceElement) {
|
12
|
+
super(sourceElement);
|
15
13
|
}
|
16
14
|
/** @inheritdoc */
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return [2 /*return*/, Promise.reject(new Error("Option with index ".concat(index, " not found in select element.")))];
|
30
|
-
}
|
31
|
-
else {
|
32
|
-
option = new element_1.O3rElement(options[index]);
|
33
|
-
return [2 /*return*/, option.click()];
|
34
|
-
}
|
35
|
-
return [2 /*return*/];
|
36
|
-
}
|
37
|
-
});
|
38
|
-
});
|
39
|
-
};
|
15
|
+
async selectByIndex(index, _timeout) {
|
16
|
+
await this.click();
|
17
|
+
// eslint-disable-next-line no-underscore-dangle -- naming convention imposed by Playwright
|
18
|
+
const options = await protractor_1.element.all(protractor_1.By.css('mat-option')).asElementFinders_();
|
19
|
+
if (typeof options[index] === 'undefined') {
|
20
|
+
return Promise.reject(new Error(`Option with index ${index} not found in select element.`));
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
const option = new element_1.O3rElement(options[index]);
|
24
|
+
return option.click();
|
25
|
+
}
|
26
|
+
}
|
40
27
|
/** @inheritdoc */
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
_a.label = 3;
|
54
|
-
case 3:
|
55
|
-
if (!(_i < options_1.length)) return [3 /*break*/, 6];
|
56
|
-
opt = options_1[_i];
|
57
|
-
option = new element_1.O3rElement(opt);
|
58
|
-
return [4 /*yield*/, option.getAttribute('ng-reflect-value')];
|
59
|
-
case 4:
|
60
|
-
if ((_a.sent()) === value) {
|
61
|
-
return [2 /*return*/, option.click()];
|
62
|
-
}
|
63
|
-
_a.label = 5;
|
64
|
-
case 5:
|
65
|
-
_i++;
|
66
|
-
return [3 /*break*/, 3];
|
67
|
-
case 6: return [2 /*return*/, Promise.reject(new Error("Option with value ".concat(value, " not found in select element.")))];
|
68
|
-
}
|
69
|
-
});
|
70
|
-
});
|
71
|
-
};
|
28
|
+
async selectByValue(value, _timeout) {
|
29
|
+
await this.click();
|
30
|
+
// eslint-disable-next-line no-underscore-dangle -- naming convention imposed by Playwright
|
31
|
+
const options = await protractor_1.element.all(protractor_1.By.css('mat-option')).asElementFinders_();
|
32
|
+
for (const opt of options) {
|
33
|
+
const option = new element_1.O3rElement(opt);
|
34
|
+
if (await option.getAttribute('ng-reflect-value') === value) {
|
35
|
+
return option.click();
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return Promise.reject(new Error(`Option with value ${value} not found in select element.`));
|
39
|
+
}
|
72
40
|
/** @inheritdoc */
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
_a.label = 3;
|
86
|
-
case 3:
|
87
|
-
if (!(_i < options_2.length)) return [3 /*break*/, 6];
|
88
|
-
opt = options_2[_i];
|
89
|
-
option = new element_1.O3rElement(opt);
|
90
|
-
return [4 /*yield*/, option.getText()];
|
91
|
-
case 4:
|
92
|
-
if ((_a.sent()) === label) {
|
93
|
-
return [2 /*return*/, option.click()];
|
94
|
-
}
|
95
|
-
_a.label = 5;
|
96
|
-
case 5:
|
97
|
-
_i++;
|
98
|
-
return [3 /*break*/, 3];
|
99
|
-
case 6: return [2 /*return*/, Promise.reject(new Error("Option with label ".concat(label, " not found in select element.")))];
|
100
|
-
}
|
101
|
-
});
|
102
|
-
});
|
103
|
-
};
|
41
|
+
async selectByLabel(label, _timeout) {
|
42
|
+
await this.click();
|
43
|
+
// eslint-disable-next-line no-underscore-dangle -- naming convention imposed by Playwright
|
44
|
+
const options = await protractor_1.element.all(protractor_1.By.css('mat-option')).asElementFinders_();
|
45
|
+
for (const opt of options) {
|
46
|
+
const option = new element_1.O3rElement(opt);
|
47
|
+
if (await option.getText() === label) {
|
48
|
+
return option.click();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return Promise.reject(new Error(`Option with label ${label} not found in select element.`));
|
52
|
+
}
|
104
53
|
/** @inheritDoc */
|
105
|
-
|
54
|
+
getValue() {
|
106
55
|
// eslint-disable-next-line no-console -- no other logger available
|
107
56
|
console.warn('Usage of "getValue" is not recommended on Material Select elements. Use "getPlainText()" instead.');
|
108
|
-
return
|
109
|
-
}
|
110
|
-
|
111
|
-
}(element_1.O3rElement));
|
57
|
+
return super.getValue();
|
58
|
+
}
|
59
|
+
}
|
112
60
|
exports.MatSelect = MatSelect;
|
113
61
|
//# sourceMappingURL=select-material.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/protractor/angular-materials/select-material.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/protractor/angular-materials/select-material.ts"],"names":[],"mappings":";;;AAAA,2CAIoB;AAIpB,wCAEoB;AAEpB;;;GAGG;AACH,MAAa,SAAU,SAAQ,oBAAU;IACvC,YAAY,aAAyC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,QAAiB;QACzD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,2FAA2F;QAC3F,MAAM,OAAO,GAAoB,MAAM,oBAAO,CAAC,GAAG,CAAC,eAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7F,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE,CAAC;YAC1C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,KAAK,+BAA+B,CAAC,CAAC,CAAC;QAC9F,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,IAAI,oBAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9C,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,QAAiB;QACzD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,2FAA2F;QAC3F,MAAM,OAAO,GAAoB,MAAM,oBAAO,CAAC,GAAG,CAAC,eAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAE7F,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,IAAI,oBAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,MAAM,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC5D,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,KAAK,+BAA+B,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,QAAiB;QACzD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,2FAA2F;QAC3F,MAAM,OAAO,GAAoB,MAAM,oBAAO,CAAC,GAAG,CAAC,eAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAE7F,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,IAAI,oBAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,KAAK,EAAE,CAAC;gBACrC,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,KAAK,+BAA+B,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,kBAAkB;IACX,QAAQ;QACb,mEAAmE;QACnE,OAAO,CAAC,IAAI,CAAC,mGAAmG,CAAC,CAAC;QAClH,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;CACF;AAxDD,8BAwDC","sourcesContent":["import {\n By,\n element,\n ElementFinder,\n} from 'protractor';\nimport {\n MatSelectProfile,\n} from '../../angular-materials';\nimport {\n O3rElement,\n} from '../element';\n\n/**\n * Implementation dedicated to Protractor.\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport class MatSelect extends O3rElement implements MatSelectProfile {\n constructor(sourceElement: ElementFinder | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByIndex(index: number, _timeout?: number) {\n await this.click();\n // eslint-disable-next-line no-underscore-dangle -- naming convention imposed by Playwright\n const options: ElementFinder[] = await element.all(By.css('mat-option')).asElementFinders_();\n if (typeof options[index] === 'undefined') {\n return Promise.reject(new Error(`Option with index ${index} not found in select element.`));\n } else {\n const option = new O3rElement(options[index]);\n return option.click();\n }\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, _timeout?: number) {\n await this.click();\n // eslint-disable-next-line no-underscore-dangle -- naming convention imposed by Playwright\n const options: ElementFinder[] = await element.all(By.css('mat-option')).asElementFinders_();\n\n for (const opt of options) {\n const option = new O3rElement(opt);\n if (await option.getAttribute('ng-reflect-value') === value) {\n return option.click();\n }\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?: number) {\n await this.click();\n // eslint-disable-next-line no-underscore-dangle -- naming convention imposed by Playwright\n const options: ElementFinder[] = await element.all(By.css('mat-option')).asElementFinders_();\n\n for (const opt of options) {\n const option = new O3rElement(opt);\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() {\n // eslint-disable-next-line no-console -- no other logger available\n console.warn('Usage of \"getValue\" is not recommended on Material Select elements. Use \"getPlainText()\" instead.');\n return super.getValue();\n }\n}\n"]}
|
@@ -1,23 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.O3rComponentFixture = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
var utils_1 = require("./utils");
|
4
|
+
const protractor_1 = require("protractor");
|
5
|
+
const index_1 = require("../../errors/index");
|
6
|
+
const helpers_1 = require("../helpers");
|
7
|
+
const element_1 = require("./element");
|
8
|
+
const utils_1 = require("./utils");
|
10
9
|
/**
|
11
10
|
* Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.
|
12
11
|
* @deprecated Will be removed in v13, please use Playwright instead
|
13
12
|
*/
|
14
|
-
|
13
|
+
class O3rComponentFixture {
|
15
14
|
/**
|
16
15
|
* Root element of this fixture. Optional in a Protractor.
|
17
16
|
* All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.
|
18
17
|
* @param rootElement
|
19
18
|
*/
|
20
|
-
|
19
|
+
constructor(rootElement) {
|
21
20
|
this.rootElement = rootElement;
|
22
21
|
}
|
23
22
|
/**
|
@@ -26,32 +25,27 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
26
25
|
* @param elemnt ElementProfile to test
|
27
26
|
* @param _timeout specific timeout that will throw when reach
|
28
27
|
*/
|
29
|
-
|
28
|
+
throwOnUndefinedElement(elemnt, _timeout) {
|
30
29
|
if (!elemnt) {
|
31
30
|
throw new Error('Element not found in ' + this.constructor.name);
|
32
31
|
}
|
33
32
|
return Promise.resolve(elemnt);
|
34
|
-
}
|
33
|
+
}
|
35
34
|
/**
|
36
35
|
* Throws an exception if the element is undefined.
|
37
36
|
* Otherwise returns the element.
|
38
37
|
* @param elemnt ElementProfile to test
|
39
38
|
* @param timeout specific timeout that will throw when reach
|
40
39
|
*/
|
41
|
-
|
42
|
-
return
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
throw new Error('Element not found in ' + _this.constructor.name);
|
49
|
-
}
|
50
|
-
return el;
|
51
|
-
})];
|
52
|
-
});
|
40
|
+
async throwOnUndefined(elemnt, timeout) {
|
41
|
+
return (0, helpers_1.withTimeout)(elemnt, timeout)
|
42
|
+
.then((el) => {
|
43
|
+
if (!el) {
|
44
|
+
throw new Error('Element not found in ' + this.constructor.name);
|
45
|
+
}
|
46
|
+
return el;
|
53
47
|
});
|
54
|
-
}
|
48
|
+
}
|
55
49
|
/**
|
56
50
|
* Get the element associated to the selector if present
|
57
51
|
* @param selector Selector to access the element
|
@@ -61,25 +55,15 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
61
55
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
62
56
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
63
57
|
*/
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
case 1:
|
74
|
-
queryElement = _a.sent();
|
75
|
-
if (options.shouldThrowIfNotPresent) {
|
76
|
-
return [2 /*return*/, this.throwOnUndefinedElement(queryElement, options.timeout)];
|
77
|
-
}
|
78
|
-
return [2 /*return*/, queryElement];
|
79
|
-
}
|
80
|
-
});
|
81
|
-
});
|
82
|
-
};
|
58
|
+
async queryWithOptions(selector, elementConstructor, options = {}) {
|
59
|
+
const queryElement = await (options.index === undefined
|
60
|
+
? this.query(selector, elementConstructor)
|
61
|
+
: this.queryNth(selector, options.index, elementConstructor));
|
62
|
+
if (options.shouldThrowIfNotPresent) {
|
63
|
+
return this.throwOnUndefinedElement(queryElement, options.timeout);
|
64
|
+
}
|
65
|
+
return queryElement;
|
66
|
+
}
|
83
67
|
/**
|
84
68
|
* Get text from the element associated to the given selector, or undefined if the element is not found or not visible
|
85
69
|
* @param selector Selector to access the element
|
@@ -89,31 +73,13 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
89
73
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
90
74
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
91
75
|
*/
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
case 1:
|
100
|
-
getTextElement = _b.sent();
|
101
|
-
_a = !getTextElement;
|
102
|
-
if (_a) return [3 /*break*/, 3];
|
103
|
-
return [4 /*yield*/, getTextElement.isVisible()];
|
104
|
-
case 2:
|
105
|
-
_a = !(_b.sent());
|
106
|
-
_b.label = 3;
|
107
|
-
case 3:
|
108
|
-
if (_a) {
|
109
|
-
return [2 /*return*/];
|
110
|
-
}
|
111
|
-
return [4 /*yield*/, getTextElement.getText()];
|
112
|
-
case 4: return [2 /*return*/, _b.sent()];
|
113
|
-
}
|
114
|
-
});
|
115
|
-
});
|
116
|
-
};
|
76
|
+
async getText(selector, options = {}) {
|
77
|
+
const getTextElement = await this.queryWithOptions(selector, options.elementConstructor, options);
|
78
|
+
if (!getTextElement || !await getTextElement.isVisible()) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
return await getTextElement.getText();
|
82
|
+
}
|
117
83
|
/**
|
118
84
|
* Check if the element associated to the given selector is visible
|
119
85
|
* @param selector Selector to access the element
|
@@ -123,26 +89,10 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
123
89
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
124
90
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
125
91
|
*/
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
return tslib_1.__generator(this, function (_b) {
|
131
|
-
switch (_b.label) {
|
132
|
-
case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
|
133
|
-
case 1:
|
134
|
-
isVisibleElement = _b.sent();
|
135
|
-
_a = !!isVisibleElement;
|
136
|
-
if (!_a) return [3 /*break*/, 3];
|
137
|
-
return [4 /*yield*/, isVisibleElement.isVisible()];
|
138
|
-
case 2:
|
139
|
-
_a = (_b.sent());
|
140
|
-
_b.label = 3;
|
141
|
-
case 3: return [2 /*return*/, _a];
|
142
|
-
}
|
143
|
-
});
|
144
|
-
});
|
145
|
-
};
|
92
|
+
async isVisible(selector, options = {}) {
|
93
|
+
const isVisibleElement = await this.queryWithOptions(selector, options.elementConstructor, options);
|
94
|
+
return !!isVisibleElement && await isVisibleElement.isVisible();
|
95
|
+
}
|
146
96
|
/**
|
147
97
|
* Click on the element associated to the given selector if it exists and is visible
|
148
98
|
* @param selector Selector to access the element
|
@@ -152,123 +102,62 @@ var O3rComponentFixture = /** @class */ (function () {
|
|
152
102
|
* @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
|
153
103
|
* @param options.timeout Duration to wait for the element to be present before it throws
|
154
104
|
*/
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
});
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
return [2 /*return*/, returnType ? new returnType(queriedElement) : new element_1.O3rElement(queriedElement)];
|
199
|
-
}
|
200
|
-
});
|
201
|
-
});
|
202
|
-
};
|
203
|
-
O3rComponentFixture.prototype.queryNth = function (selector, index, returnType) {
|
204
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
205
|
-
var sourceElement, item;
|
206
|
-
return tslib_1.__generator(this, function (_a) {
|
207
|
-
switch (_a.label) {
|
208
|
-
case 0:
|
209
|
-
sourceElement = this.rootElement && this.rootElement.sourceElement;
|
210
|
-
item = (sourceElement || protractor_1.element).all(protractor_1.By.css(selector)).get(index);
|
211
|
-
return [4 /*yield*/, item.isPresent()];
|
212
|
-
case 1:
|
213
|
-
if (!(_a.sent())) {
|
214
|
-
// eslint-disable-next-line no-console -- no other logger available
|
215
|
-
console.warn("No component matching ".concat(selector, ":nth(").concat(index, ") found"));
|
216
|
-
return [2 /*return*/];
|
217
|
-
}
|
218
|
-
return [2 /*return*/, new (returnType || element_1.O3rElement)(item)];
|
219
|
-
}
|
220
|
-
});
|
221
|
-
});
|
222
|
-
};
|
223
|
-
O3rComponentFixture.prototype.queryAll = function (selector, returnType, groupType, _timeout) {
|
224
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
225
|
-
var pElements, elements, group, isValid;
|
226
|
-
return tslib_1.__generator(this, function (_a) {
|
227
|
-
switch (_a.label) {
|
228
|
-
case 0:
|
229
|
-
pElements = (this.rootElement ? this.rootElement.sourceElement.all(protractor_1.By.css(selector)) : protractor_1.element.all(protractor_1.By.css(selector)))
|
230
|
-
.filter(function (item) { return typeof item !== 'undefined'; })
|
231
|
-
.then(function (elf) { return elf.map(function (item) { return (returnType ? new returnType(item) : new element_1.O3rElement(item)); }); });
|
232
|
-
return [4 /*yield*/, (0, utils_1.convertPromise)(pElements)];
|
233
|
-
case 1:
|
234
|
-
elements = _a.sent();
|
235
|
-
if (!groupType) return [3 /*break*/, 3];
|
236
|
-
group = new groupType(elements);
|
237
|
-
return [4 /*yield*/, group.isValidGroup()];
|
238
|
-
case 2:
|
239
|
-
isValid = _a.sent();
|
240
|
-
if (!isValid) {
|
241
|
-
throw new index_1.FixtureUsageError('invalid group of items');
|
242
|
-
}
|
243
|
-
return [2 /*return*/, Promise.resolve(group)];
|
244
|
-
case 3: return [2 /*return*/, elements];
|
245
|
-
}
|
246
|
-
});
|
247
|
-
});
|
248
|
-
};
|
105
|
+
async click(selector, options = {}) {
|
106
|
+
const clickElement = await this.queryWithOptions(selector, options.elementConstructor, options);
|
107
|
+
if (!!clickElement && await clickElement.isVisible()) {
|
108
|
+
await clickElement.click();
|
109
|
+
}
|
110
|
+
}
|
111
|
+
async query(selector, returnType) {
|
112
|
+
const sourceElement = this.rootElement && this.rootElement.sourceElement;
|
113
|
+
const cssSelector = protractor_1.By.css(selector);
|
114
|
+
const isElPresent = await (sourceElement ? sourceElement.isElementPresent(cssSelector) : protractor_1.browser.isElementPresent(cssSelector));
|
115
|
+
if (!isElPresent) {
|
116
|
+
// eslint-disable-next-line no-console -- no other logger available
|
117
|
+
console.warn(`No component matching ${selector} found`);
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
const queriedElement = sourceElement ? sourceElement.element(cssSelector) : (0, protractor_1.element)(cssSelector);
|
121
|
+
return returnType ? new returnType(queriedElement) : new element_1.O3rElement(queriedElement);
|
122
|
+
}
|
123
|
+
async queryNth(selector, index, returnType) {
|
124
|
+
const sourceElement = this.rootElement && this.rootElement.sourceElement;
|
125
|
+
const item = (sourceElement || protractor_1.element).all(protractor_1.By.css(selector)).get(index);
|
126
|
+
if (!(await item.isPresent())) {
|
127
|
+
// eslint-disable-next-line no-console -- no other logger available
|
128
|
+
console.warn(`No component matching ${selector}:nth(${index}) found`);
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
return new (returnType || element_1.O3rElement)(item);
|
132
|
+
}
|
133
|
+
async queryAll(selector, returnType, groupType, _timeout) {
|
134
|
+
const pElements = (this.rootElement ? this.rootElement.sourceElement.all(protractor_1.By.css(selector)) : protractor_1.element.all(protractor_1.By.css(selector)))
|
135
|
+
.filter((item) => typeof item !== 'undefined')
|
136
|
+
.then((elf) => elf.map((item) => (returnType ? new returnType(item) : new element_1.O3rElement(item))));
|
137
|
+
const elements = await (0, utils_1.convertPromise)(pElements);
|
138
|
+
if (groupType) {
|
139
|
+
const group = new groupType(elements);
|
140
|
+
const isValid = await group.isValidGroup();
|
141
|
+
if (!isValid) {
|
142
|
+
throw new index_1.FixtureUsageError('invalid group of items');
|
143
|
+
}
|
144
|
+
return Promise.resolve(group);
|
145
|
+
}
|
146
|
+
return elements;
|
147
|
+
}
|
249
148
|
/** @inheritdoc */
|
250
|
-
|
149
|
+
getElement() {
|
251
150
|
return this.rootElement;
|
252
|
-
}
|
151
|
+
}
|
253
152
|
/** @inheritdoc */
|
254
|
-
|
153
|
+
getSubComponents() {
|
255
154
|
return Promise.resolve({ block: [this] });
|
256
|
-
}
|
155
|
+
}
|
257
156
|
/** @inheritDoc */
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
case 0:
|
264
|
-
sourceElement = this.rootElement && this.rootElement.sourceElement;
|
265
|
-
return [4 /*yield*/, (sourceElement || protractor_1.browser).isElementPresent(protractor_1.By.css(selector))];
|
266
|
-
case 1: return [2 /*return*/, !(_a.sent())];
|
267
|
-
}
|
268
|
-
});
|
269
|
-
});
|
270
|
-
};
|
271
|
-
return O3rComponentFixture;
|
272
|
-
}());
|
157
|
+
async queryNotPresent(selector, _timeout) {
|
158
|
+
const sourceElement = this.rootElement && this.rootElement.sourceElement;
|
159
|
+
return !(await (sourceElement || protractor_1.browser).isElementPresent(protractor_1.By.css(selector)));
|
160
|
+
}
|
161
|
+
}
|
273
162
|
exports.O3rComponentFixture = O3rComponentFixture;
|
274
163
|
//# sourceMappingURL=component-fixture.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,yCAKoB;AACpB,4CAE4B;AAM5B,sCAEoB;AACpB,qCAImB;AAKnB,iCAEiB;AAiBjB;;;GAGG;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,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,8CAAgB,GAAhC,UAAuD,MAA8B,EAAE,OAAgB;;;;gB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G,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,AAhND,IAgNC;AAhNY,kDAAmB","sourcesContent":["import {\n browser,\n By,\n element,\n ElementFinder,\n} from 'protractor';\nimport {\n FixtureUsageError,\n} from '../../errors/index';\nimport type {\n ComponentFixtureProfile as ComponentFixtureProfileCore,\n Constructable as ConstructableCore,\n FixtureWithCustom as FixtureWithCustomCore,\n} from '../component-fixture';\nimport {\n withTimeout,\n} from '../helpers';\nimport {\n ElementProfile,\n O3rElement,\n O3rElementConstructor,\n} from './element';\nimport {\n O3rGroup,\n O3rGroupConstructor,\n} from './group';\nimport {\n convertPromise,\n} from './utils';\n\n/**\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport interface ComponentFixtureProfile<V extends ElementProfile = ElementProfile> extends ComponentFixtureProfileCore<V> {}\n\n/**\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport interface FixtureWithCustom extends FixtureWithCustomCore {}\n\n/**\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport interface Constructable<T extends ComponentFixtureProfile, U extends FixtureWithCustom = FixtureWithCustom> extends ConstructableCore<T, U> {}\n\n/**\n * Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.\n * @deprecated Will be removed in v13, please use Playwright instead\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 * 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 const queryElement: O3rElement | undefined = await (\n options.index === undefined\n ? this.query(selector, elementConstructor as any)\n : this.queryNth(selector, options.index, 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 const isElPresent = await (sourceElement ? sourceElement.isElementPresent(cssSelector) : browser.isElementPresent(cssSelector));\n if (!isElPresent) {\n // eslint-disable-next-line no-console -- no other logger available\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 // eslint-disable-next-line no-console -- no other logger available\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,2CAKoB;AACpB,8CAE4B;AAM5B,wCAEoB;AACpB,uCAImB;AAKnB,mCAEiB;AAiBjB;;;GAGG;AACH,MAAa,mBAAmB;IAM9B;;;;OAIG;IACH,YAAY,WAAe;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,uBAAuB,CAAuB,MAAU,EAAE,QAAiB;QACnF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,gBAAgB,CAAuB,MAA8B,EAAE,OAAgB;QACrG,OAAO,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC;aAChC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;YACX,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,C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,CAAC,CAAC;YAC7C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE,CAAC;YAE3C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;YACxD,CAAC;YACD,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,kBAAkB;IACX,UAAU;QACf,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,gBAAgB;QACrB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,eAAe,CAAC,QAAgB,EAAE,QAAiB;QAC9D,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;QACzE,OAAO,CAAC,CAAC,MAAM,CAAC,aAAa,IAAI,oBAAO,CAAC,CAAC,gBAAgB,CAAC,eAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;CACF;AAhND,kDAgNC","sourcesContent":["import {\n browser,\n By,\n element,\n ElementFinder,\n} from 'protractor';\nimport {\n FixtureUsageError,\n} from '../../errors/index';\nimport type {\n ComponentFixtureProfile as ComponentFixtureProfileCore,\n Constructable as ConstructableCore,\n FixtureWithCustom as FixtureWithCustomCore,\n} from '../component-fixture';\nimport {\n withTimeout,\n} from '../helpers';\nimport {\n ElementProfile,\n O3rElement,\n O3rElementConstructor,\n} from './element';\nimport {\n O3rGroup,\n O3rGroupConstructor,\n} from './group';\nimport {\n convertPromise,\n} from './utils';\n\n/**\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport interface ComponentFixtureProfile<V extends ElementProfile = ElementProfile> extends ComponentFixtureProfileCore<V> {}\n\n/**\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport interface FixtureWithCustom extends FixtureWithCustomCore {}\n\n/**\n * @deprecated Will be removed in v13, please use Playwright instead\n */\nexport interface Constructable<T extends ComponentFixtureProfile, U extends FixtureWithCustom = FixtureWithCustom> extends ConstructableCore<T, U> {}\n\n/**\n * Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.\n * @deprecated Will be removed in v13, please use Playwright instead\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 * 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 const queryElement: O3rElement | undefined = await (\n options.index === undefined\n ? this.query(selector, elementConstructor as any)\n : this.queryNth(selector, options.index, 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 const isElPresent = await (sourceElement ? sourceElement.isElementPresent(cssSelector) : browser.isElementPresent(cssSelector));\n if (!isElPresent) {\n // eslint-disable-next-line no-console -- no other logger available\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 // eslint-disable-next-line no-console -- no other logger available\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"]}
|