@o3r/testing 10.2.0-prerelease.9 → 10.3.0-prerelease.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.
Files changed (28) hide show
  1. package/README.md +3 -0
  2. package/core/angular/component-fixture.js +12 -12
  3. package/core/angular/component-fixture.js.map +1 -1
  4. package/core/helpers.d.ts.map +1 -1
  5. package/core/playwright/angular-materials/autocomplete-material.js +3 -3
  6. package/core/playwright/angular-materials/autocomplete-material.js.map +1 -1
  7. package/core/playwright/angular-materials/select-material.js +9 -9
  8. package/core/playwright/angular-materials/select-material.js.map +1 -1
  9. package/core/playwright/component-fixture.js +15 -15
  10. package/core/playwright/component-fixture.js.map +1 -1
  11. package/core/playwright/elements/checkbox-element.js +3 -3
  12. package/core/playwright/elements/checkbox-element.js.map +1 -1
  13. package/core/playwright/elements/radio-element.js +3 -3
  14. package/core/playwright/elements/radio-element.js.map +1 -1
  15. package/core/protractor/component-fixture.js +12 -12
  16. package/core/protractor/component-fixture.js.map +1 -1
  17. package/core/protractor/elements/checkbox-element.js +3 -3
  18. package/core/protractor/elements/checkbox-element.js.map +1 -1
  19. package/core/protractor/elements/radio-element.js +3 -3
  20. package/core/protractor/elements/radio-element.js.map +1 -1
  21. package/kassette/update-dates-in-mocks.js +11 -11
  22. package/kassette/update-dates-in-mocks.js.map +1 -1
  23. package/package.json +48 -48
  24. package/schematics/ng-add/fixture/index.d.ts.map +1 -1
  25. package/schematics/ng-add/fixture/index.js +6 -6
  26. package/schematics/ng-add/fixture/index.js.map +1 -1
  27. package/tools/protractor/post-message-interceptor/post-message-interceptor.js +4 -4
  28. package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
package/README.md CHANGED
@@ -9,6 +9,9 @@ This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/ot
9
9
 
10
10
  ## Description
11
11
 
12
+ [![Stable Version](https://img.shields.io/npm/v/@o3r/testing?style=for-the-badge)](https://www.npmjs.com/package/@o3r/testing)
13
+ [![Bundle Size](https://img.shields.io/bundlephobia/min/@o3r/testing?color=green&style=for-the-badge)](https://www.npmjs.com/package/@o3r/testing)
14
+
12
15
  The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.
13
16
 
14
17
  ## How to install
@@ -50,10 +50,10 @@ var O3rComponentFixture = /** @class */ (function () {
50
50
  });
51
51
  });
52
52
  };
53
- O3rComponentFixture.prototype.queryWithOptions = function (selector, elementConstructor, options) {
54
- if (options === void 0) { options = {}; }
55
- return tslib_1.__awaiter(this, void 0, void 0, function () {
53
+ O3rComponentFixture.prototype.queryWithOptions = function (selector_1, elementConstructor_1) {
54
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, elementConstructor, options) {
56
55
  var element;
56
+ if (options === void 0) { options = {}; }
57
57
  return tslib_1.__generator(this, function (_a) {
58
58
  switch (_a.label) {
59
59
  case 0:
@@ -84,10 +84,10 @@ var O3rComponentFixture = /** @class */ (function () {
84
84
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
85
85
  * @param options.timeout Duration to wait for the element to be present before it throws
86
86
  */
87
- O3rComponentFixture.prototype.getText = function (selector, options) {
88
- if (options === void 0) { options = {}; }
89
- return tslib_1.__awaiter(this, void 0, void 0, function () {
87
+ O3rComponentFixture.prototype.getText = function (selector_1) {
88
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
90
89
  var element, _a;
90
+ if (options === void 0) { options = {}; }
91
91
  return tslib_1.__generator(this, function (_b) {
92
92
  switch (_b.label) {
93
93
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -118,10 +118,10 @@ var O3rComponentFixture = /** @class */ (function () {
118
118
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
119
119
  * @param options.timeout Duration to wait for the element to be present before it throws
120
120
  */
121
- O3rComponentFixture.prototype.isVisible = function (selector, options) {
122
- if (options === void 0) { options = {}; }
123
- return tslib_1.__awaiter(this, void 0, void 0, function () {
121
+ O3rComponentFixture.prototype.isVisible = function (selector_1) {
122
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
124
123
  var element, _a;
124
+ if (options === void 0) { options = {}; }
125
125
  return tslib_1.__generator(this, function (_b) {
126
126
  switch (_b.label) {
127
127
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -147,10 +147,10 @@ var O3rComponentFixture = /** @class */ (function () {
147
147
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
148
148
  * @param options.timeout Duration to wait for the element to be present before it throws
149
149
  */
150
- O3rComponentFixture.prototype.click = function (selector, options) {
151
- if (options === void 0) { options = {}; }
152
- return tslib_1.__awaiter(this, void 0, void 0, function () {
150
+ O3rComponentFixture.prototype.click = function (selector_1) {
151
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
153
152
  var element, _a;
153
+ if (options === void 0) { options = {}; }
154
154
  return tslib_1.__generator(this, function (_b) {
155
155
  switch (_b.label) {
156
156
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/angular/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,8DAA6C;AAC7C,4CAAqD;AAErD,sCAAuC;AACvC,qCAA4D;AAK5D;;GAEG;AACH;IAME;;;OAGG;IACH,6BAAY,OAAU;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACO,qDAAuB,GAAjC,UAAwD,OAAW,EAAE,QAAiB;QACpF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED;;;;;O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BACxD,CAAC;wBACD,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;4BAGhC,sBAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAC;;;;KAClC;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,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;IACX,6CAAe,GAAtB,UAAuB,QAAgB,EAAE,QAAiB;QACxD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,qBAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IACH,0BAAC;AAAD,CAAC,AAjND,IAiNC;AAjNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport {By} from '@angular/platform-browser';\nimport {FixtureUsageError} from '../../errors/index';\nimport type {ComponentFixtureProfile} from '../component-fixture';\nimport {withTimeout} from '../helpers';\nimport {O3rElement, O3rElementConstructor} from './element';\nimport {O3rGroup, O3rGroupConstructor} from './group';\n\nexport type {ComponentFixtureProfile, Constructable, FixtureWithCustom} from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to angular, hence using angular testing framework.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n /**\n * DOM element linked to the fixture.\n */\n protected element: V;\n\n /**\n * Root element of this fixture. It will be used as the context for further queries.\n * @param element\n */\n constructor(element: V) {\n this.element = element;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param _timeout specific timeout that will throw when reach\n */\n protected throwOnUndefinedElement<T extends O3rElement>(element?: T, _timeout?: number): Promise<T> {\n if (!element) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return Promise.resolve(element);\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(element: Promise<T | undefined>, timeout?: number): Promise<T> {\n return withTimeout(element, 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: undefined,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n }\n ): Promise<O3rElement | undefined>;\n protected async queryWithOptions<T extends O3rElement>(\n selector: string,\n elementConstructor: O3rElementConstructor<T>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n }\n ): Promise<T | undefined>;\n protected async queryWithOptions<T extends O3rElement>(\n selector: string,\n elementConstructor: O3rElementConstructor<T> | undefined,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<T | O3rElement | undefined> {\n let element: T | O3rElement | undefined;\n if (options.index !== undefined) {\n element = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n element = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(element, options.timeout);\n }\n return element;\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 element = await this.queryWithOptions(selector, options.elementConstructor as any, options);\n if (!element || !await element.isVisible()) {\n return;\n }\n return await element.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 element = await this.queryWithOptions(selector, options.elementConstructor as any, options);\n return !!element && await element.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 element = await this.queryWithOptions(selector, options.elementConstructor as any, options);\n if (!!element && await element.isVisible()) {\n await element.click();\n }\n }\n\n /** @inheritdoc */\n public query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const queriedElement = this.element.sourceElement.query(By.css(selector));\n return Promise.resolve(queriedElement ? (returnType ? new returnType(queriedElement) : new O3rElement(queriedElement)) : undefined);\n }\n\n /** @inheritdoc */\n public queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const queriedElement = this.element.sourceElement.queryAll(By.css(selector))[index];\n return Promise.resolve(queriedElement ? (returnType ? new returnType(queriedElement) : new O3rElement(queriedElement)) : undefined);\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 queriedElement = this.element.sourceElement.queryAll(By.css(selector));\n\n const elements = queriedElement.map((el) => (returnType ? new returnType(el) : new O3rElement(el)));\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 Promise.resolve(elements);\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.element;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{ [componentName: string]: ComponentFixtureProfile[] }> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public queryNotPresent(selector: string, _timeout?: number): Promise<boolean> {\n return Promise.resolve(!this.element.sourceElement.query(By.css(selector)));\n }\n}\n"]}
1
+ {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/angular/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,8DAA6C;AAC7C,4CAAqD;AAErD,sCAAuC;AACvC,qCAA4D;AAK5D;;GAEG;AACH;IAME;;;OAGG;IACH,6BAAY,OAAU;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACO,qDAAuB,GAAjC,UAAwD,OAAW,EAAE,QAAiB;QACpF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACa,8CAAgB,GAAhC,UAAuD,OAA+B,EAAE,OAAgB;;;;gBACtG,sBAAO,IAAA,qBAAW,EAAC,OAAO,EAAE,OAAO,CAAC;yBACjC,IAAI,CAAC,UAAC,EAAE;wBACP,IAAI,CAAC,EAAE,EAAE,CAAC;4BACR,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBACnE,CAAC;wBACD,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,EAAC;;;KACN;IA6Be,8CAAgB,GAAhC;oEACE,QAAgB,EAChB,kBAAwD,EACxD,OAIM;;YAJN,wBAAA,EAAA,YAIM;;;;6BAGF,CAAA,OAAO,CAAC,KAAK,KAAK,SAAS,CAAA,EAA3B,wBAA2B;wBACnB,qBAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAyB,CAAC,EAAA;;wBAAjF,OAAO,GAA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NY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport {By} from '@angular/platform-browser';\nimport {FixtureUsageError} from '../../errors/index';\nimport type {ComponentFixtureProfile} from '../component-fixture';\nimport {withTimeout} from '../helpers';\nimport {O3rElement, O3rElementConstructor} from './element';\nimport {O3rGroup, O3rGroupConstructor} from './group';\n\nexport type {ComponentFixtureProfile, Constructable, FixtureWithCustom} from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to angular, hence using angular testing framework.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n /**\n * DOM element linked to the fixture.\n */\n protected element: V;\n\n /**\n * Root element of this fixture. It will be used as the context for further queries.\n * @param element\n */\n constructor(element: V) {\n this.element = element;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param _timeout specific timeout that will throw when reach\n */\n protected throwOnUndefinedElement<T extends O3rElement>(element?: T, _timeout?: number): Promise<T> {\n if (!element) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return Promise.resolve(element);\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(element: Promise<T | undefined>, timeout?: number): Promise<T> {\n return withTimeout(element, 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: undefined,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n }\n ): Promise<O3rElement | undefined>;\n protected async queryWithOptions<T extends O3rElement>(\n selector: string,\n elementConstructor: O3rElementConstructor<T>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n }\n ): Promise<T | undefined>;\n protected async queryWithOptions<T extends O3rElement>(\n selector: string,\n elementConstructor: O3rElementConstructor<T> | undefined,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<T | O3rElement | undefined> {\n let element: T | O3rElement | undefined;\n if (options.index !== undefined) {\n element = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n element = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(element, options.timeout);\n }\n return element;\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 element = await this.queryWithOptions(selector, options.elementConstructor as any, options);\n if (!element || !await element.isVisible()) {\n return;\n }\n return await element.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 element = await this.queryWithOptions(selector, options.elementConstructor as any, options);\n return !!element && await element.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 element = await this.queryWithOptions(selector, options.elementConstructor as any, options);\n if (!!element && await element.isVisible()) {\n await element.click();\n }\n }\n\n /** @inheritdoc */\n public query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const queriedElement = this.element.sourceElement.query(By.css(selector));\n return Promise.resolve(queriedElement ? (returnType ? new returnType(queriedElement) : new O3rElement(queriedElement)) : undefined);\n }\n\n /** @inheritdoc */\n public queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const queriedElement = this.element.sourceElement.queryAll(By.css(selector))[index];\n return Promise.resolve(queriedElement ? (returnType ? new returnType(queriedElement) : new O3rElement(queriedElement)) : undefined);\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 queriedElement = this.element.sourceElement.queryAll(By.css(selector));\n\n const elements = queriedElement.map((el) => (returnType ? new returnType(el) : new O3rElement(el)));\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 Promise.resolve(elements);\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.element;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{ [componentName: string]: ComponentFixtureProfile[] }> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public queryNotPresent(selector: string, _timeout?: number): Promise<boolean> {\n return Promise.resolve(!this.element.sourceElement.query(By.css(selector)));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/core/helpers.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,SAAS,iDAA6G,CAAC;AAEpI;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;CAGzC;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,qCAA4C,MAAM,eAKzE,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/core/helpers.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,SAAS,YAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,uBAAkF,CAAC;AAEpI;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;CAGzC;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,eAAsB,QAAQ,CAAC,CAAC,YAAY,MAAM,KAAG,QAAQ,CAAC,CAKrF,CAAC"}
@@ -12,10 +12,10 @@ var MatAutocomplete = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritdoc */
15
- MatAutocomplete.prototype.selectByValue = function (value, timeout) {
16
- if (timeout === void 0) { timeout = 5000; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ MatAutocomplete.prototype.selectByValue = function (value_1) {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (value, timeout) {
18
17
  var element, matOptions, matOptionsCount, options, i, _a, _b, _c, selectedOption;
18
+ if (timeout === void 0) { timeout = 5000; }
19
19
  return tslib_1.__generator(this, function (_d) {
20
20
  switch (_d.label) {
21
21
  case 0: return [4 /*yield*/, this.setValue(value)];
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/autocomplete-material.ts"],"names":[],"mappings":";;;;AACA,sCAA6E;AAI7E;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,uCAAa,GAA1B,UAA2B,KAAa,EAAE,OAAc;QAAd,wBAAA,EAAA,cAAc;;;;;4BACtD,qBAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAA;;wBAA1B,SAA0B,CAAC;wBAC3B,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;wBAClC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;wBAC9D,qBAAM,UAAU,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAC,CAAC,EAAA;;wBAA9D,SAA8D,CAAC;wBACvC,qBAAM,UAAU,CAAC,KAAK,EAAE,EAAA;;wBAA1C,eAAe,GAAG,SAAwB;wBAC1C,OAAO,GAA2B,EAAE,CAAC;6BACvC,CAAA,eAAe,GAAG,CAAC,CAAA,EAAnB,wBAAmB;wBACZ,CAAC,GAAG,CAAC;;;6BAAE,CAAA,CAAC,GAAG,eAAe,CAAA;wBACjC,KAAA,CAAA,KAAA,OAAO,CAAA,CAAC,IAAI,CAAA;wBAAC,KAAA,sBAAY,CAAA;wBAAC,qBAAM,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,EAAA;;wBAA7D,cAAa,kBAAa,SAAmC,EAAC,EAAC,CAAC;;;wBAD7B,CAAC,EAAE,CAAA;;4BAGxC,MAAM,IAAI,KAAK,CAAC,qGAA8F,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAAC,CAAC;;6BAElI,CAAA,eAAe,KAAK,CAAC,CAAA,EAArB,yBAAqB;wBACjB,cAAc,GAA4B,EAAC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAC,CAAC;wBAC5G,qBAAM,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAA;;wBAA5C,SAA4C,CAAC;wBAC7C,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;6BAGjD,sBAAO,OAAO,CAAC,MAAM,CAAC,0DAA0D,CAAC,EAAC;;;;KACnF;IACH,sBAAC;AAAD,CAAC,AA5BD,CAAqC,oBAAU,GA4B9C;AA5BY,0CAAe","sourcesContent":["import {MatAutocompleteProfile} from '../../angular-materials';\nimport {getPlainText, O3rElement, PlaywrightSourceElement} from '../element';\n\nexport {SelectElementProfile} from '../../elements';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatAutocomplete extends O3rElement implements MatAutocompleteProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.setValue(value);\n await this.click();\n const element = this.sourceElement.page;\n const matOptions = element.locator('.mat-option, mat-option');\n await matOptions.first().waitFor({state: 'attached', timeout});\n const matOptionsCount = await matOptions.count();\n const options: (string | undefined)[] = [];\n if (matOptionsCount > 1) {\n for (let i = 0; i < matOptionsCount; i++) {\n options.push(getPlainText(await matOptions.nth(i).innerText()));\n }\n throw new Error(`MatAutocomplete selectByValue works only for filtered autocomplete. Found multiple values: ${options.join(', ')}`);\n }\n if (matOptionsCount === 1) {\n const selectedOption: PlaywrightSourceElement = {element: matOptions.nth(0), page: this.sourceElement.page};\n await new O3rElement(selectedOption).click();\n return this.sourceElement.element.press('Tab');\n }\n\n return Promise.reject('Element with selector .mat-option, mat-option not found.');\n }\n}\n"]}
1
+ {"version":3,"file":"autocomplete-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/autocomplete-material.ts"],"names":[],"mappings":";;;;AACA,sCAA6E;AAI7E;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,uCAAa,GAA1B;oEAA2B,KAAa,EAAE,OAAc;;YAAd,wBAAA,EAAA,cAAc;;;4BACtD,qBAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAA;;wBAA1B,SAA0B,CAAC;wBAC3B,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;wBAClC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAA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from '../../angular-materials';\nimport {getPlainText, O3rElement, PlaywrightSourceElement} from '../element';\n\nexport {SelectElementProfile} from '../../elements';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatAutocomplete extends O3rElement implements MatAutocompleteProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.setValue(value);\n await this.click();\n const element = this.sourceElement.page;\n const matOptions = element.locator('.mat-option, mat-option');\n await matOptions.first().waitFor({state: 'attached', timeout});\n const matOptionsCount = await matOptions.count();\n const options: (string | undefined)[] = [];\n if (matOptionsCount > 1) {\n for (let i = 0; i < matOptionsCount; i++) {\n options.push(getPlainText(await matOptions.nth(i).innerText()));\n }\n throw new Error(`MatAutocomplete selectByValue works only for filtered autocomplete. Found multiple values: ${options.join(', ')}`);\n }\n if (matOptionsCount === 1) {\n const selectedOption: PlaywrightSourceElement = {element: matOptions.nth(0), page: this.sourceElement.page};\n await new O3rElement(selectedOption).click();\n return this.sourceElement.element.press('Tab');\n }\n\n return Promise.reject('Element with selector .mat-option, mat-option not found.');\n }\n}\n"]}
@@ -12,10 +12,10 @@ var MatSelect = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritdoc */
15
- MatSelect.prototype.selectByIndex = function (index, timeout) {
16
- if (timeout === void 0) { timeout = 5000; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ MatSelect.prototype.selectByIndex = function (index_1) {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (index, timeout) {
18
17
  var options, selectedOption, option;
18
+ if (timeout === void 0) { timeout = 5000; }
19
19
  return tslib_1.__generator(this, function (_a) {
20
20
  switch (_a.label) {
21
21
  case 0: return [4 /*yield*/, this.click()];
@@ -41,10 +41,10 @@ var MatSelect = /** @class */ (function (_super) {
41
41
  });
42
42
  };
43
43
  /** @inheritdoc */
44
- MatSelect.prototype.selectByValue = function (value, timeout) {
45
- if (timeout === void 0) { timeout = 5000; }
46
- return tslib_1.__awaiter(this, void 0, void 0, function () {
44
+ MatSelect.prototype.selectByValue = function (value_1) {
45
+ return tslib_1.__awaiter(this, arguments, void 0, function (value, timeout) {
47
46
  var options, optionsCount, i, selectedOption, option;
47
+ if (timeout === void 0) { timeout = 5000; }
48
48
  return tslib_1.__generator(this, function (_a) {
49
49
  switch (_a.label) {
50
50
  case 0: return [4 /*yield*/, this.click()];
@@ -78,10 +78,10 @@ var MatSelect = /** @class */ (function (_super) {
78
78
  });
79
79
  };
80
80
  /** @inheritdoc */
81
- MatSelect.prototype.selectByLabel = function (label, timeout) {
82
- if (timeout === void 0) { timeout = 5000; }
83
- return tslib_1.__awaiter(this, void 0, void 0, function () {
81
+ MatSelect.prototype.selectByLabel = function (label_1) {
82
+ return tslib_1.__awaiter(this, arguments, void 0, function (label, timeout) {
84
83
  var options, optionsCount, i, selectedOption, option;
84
+ if (timeout === void 0) { timeout = 5000; }
85
85
  return tslib_1.__generator(this, function (_a) {
86
86
  switch (_a.label) {
87
87
  case 0: return [4 /*yield*/, this.click()];
@@ -1 +1 @@
1
- {"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/select-material.ts"],"names":[],"mappings":";;;;AACA,sCAA+D;AAG/D;;GAEG;AACH;IAA+B,qCAAU;IACvC,mBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,iCAAa,GAA1B,UAA2B,KAAa,EAAE,OAAc;QAAd,wBAAA,EAAA,cAAc;;;;;4BACtD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;wBAC9D,qBAAM,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,KAAK,E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AM,CAAC,4BAAqB,KAAK,kCAA+B,CAAC,EAAC;;;;KAClF;IAED,kBAAkB;IACX,4BAAQ,GAAf;QACE,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAChH,CAAC;IACH,gBAAC;AAAD,CAAC,AAxDD,CAA+B,oBAAU,GAwDxC;AAxDY,8BAAS","sourcesContent":["import {MatSelectProfile} from '../../angular-materials';\nimport {O3rElement, PlaywrightSourceElement} from '../element';\nexport {SelectElementProfile} from '../../elements';\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: PlaywrightSourceElement = {element: options.nth(index), page: this.sourceElement.page};\n const option = new O3rElement(selectedOption);\n return option.click();\n } else {\n return Promise.reject(`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: PlaywrightSourceElement = {element: options.nth(i), page: this.sourceElement.page};\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(`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: PlaywrightSourceElement = {element: options.nth(i), page: this.sourceElement.page};\n const option = new O3rElement(selectedOption);\n if (await option.getText() === label) {\n return option.click();\n }\n }\n\n return Promise.reject(`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
+ {"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/select-material.ts"],"names":[],"mappings":";;;;AACA,sCAA+D;AAG/D;;GAEG;AACH;IAA+B,qCAAU;IACvC,mBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,iCAAa,GAA1B;oEAA2B,KAAa,EAAE,OAAc;;YAAd,wBAAA,EAAA,cAAc;;;4BACtD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;wBAC9D,qBAAM,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAC,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBACvD,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;wBAA1B,IAAI,CAAC,SAAqB,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;4BACnC,cAAc,GAA4B,EAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAC,CAAC;4BACvG,MAAM,GAAG,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC;4BAC9C,sBAAO,MAAM,CAAC,KAAK,EAAE,EAAC;wBACxB,CAAC;6BAAM,CAAC;4BACN,sBAAO,OAAO,CAAC,MAAM,CAAC,4BAAqB,KAAK,kCAA+B,CAAC,EAAC;wBACnF,CAAC;;;;;KAC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AAC;wBAC9D,qBAAM,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAC,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBACvC,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;wBAApC,YAAY,GAAG,SAAqB;wBACjC,CAAC,GAAG,CAAC;;;6BAAE,CAAA,CAAC,GAAG,YAAY,CAAA;wBACxB,cAAc,GAA4B,EAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAC,CAAC;wBACnG,MAAM,GAAG,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC;wBAC1C,qBAAM,MAAM,CAAC,OAAO,EAAE,EAAA;;wBAA1B,IAAI,CAAA,SAAsB,MAAK,KAAK,EAAE,CAAC;4BACrC,sBAAO,MAAM,CAAC,KAAK,EAAE,EAAC;wBACxB,CAAC;;;wBAL+B,CAAC,EAAE,CAAA;;4BAQrC,sBAAO,OAAO,CAAC,MAAM,CAAC,4BAAqB,KAAK,kCAA+B,CAAC,EAAC;;;;KAClF;IAED,kBAAkB;IACX,4BAAQ,GAAf;QACE,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAChH,CAAC;IACH,gBAAC;AAAD,CAAC,AAxDD,CAA+B,oBAAU,GAwDxC;AAxDY,8BAAS","sourcesContent":["import {MatSelectProfile} from '../../angular-materials';\nimport {O3rElement, PlaywrightSourceElement} from '../element';\nexport {SelectElementProfile} from '../../elements';\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: PlaywrightSourceElement = {element: options.nth(index), page: this.sourceElement.page};\n const option = new O3rElement(selectedOption);\n return option.click();\n } else {\n return Promise.reject(`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: PlaywrightSourceElement = {element: options.nth(i), page: this.sourceElement.page};\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(`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: PlaywrightSourceElement = {element: options.nth(i), page: this.sourceElement.page};\n const option = new O3rElement(selectedOption);\n if (await option.getText() === label) {\n return option.click();\n }\n }\n\n return Promise.reject(`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"]}
@@ -72,10 +72,10 @@ var O3rComponentFixture = /** @class */ (function () {
72
72
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
73
73
  * @param options.timeout Duration to wait for the element to be present before it throws
74
74
  */
75
- O3rComponentFixture.prototype.queryWithOptions = function (selector, elementConstructor, options) {
76
- if (options === void 0) { options = {}; }
77
- return tslib_1.__awaiter(this, void 0, void 0, function () {
75
+ O3rComponentFixture.prototype.queryWithOptions = function (selector_1, elementConstructor_1) {
76
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, elementConstructor, options) {
78
77
  var element;
78
+ if (options === void 0) { options = {}; }
79
79
  return tslib_1.__generator(this, function (_a) {
80
80
  switch (_a.label) {
81
81
  case 0:
@@ -106,10 +106,10 @@ var O3rComponentFixture = /** @class */ (function () {
106
106
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
107
107
  * @param options.timeout Duration to wait for the element to be present before it throws
108
108
  */
109
- O3rComponentFixture.prototype.getText = function (selector, options) {
110
- if (options === void 0) { options = {}; }
111
- return tslib_1.__awaiter(this, void 0, void 0, function () {
109
+ O3rComponentFixture.prototype.getText = function (selector_1) {
110
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
112
111
  var element;
112
+ if (options === void 0) { options = {}; }
113
113
  return tslib_1.__generator(this, function (_a) {
114
114
  switch (_a.label) {
115
115
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -135,10 +135,10 @@ var O3rComponentFixture = /** @class */ (function () {
135
135
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
136
136
  * @param options.timeout Duration to wait for the element to be present before it throws
137
137
  */
138
- O3rComponentFixture.prototype.isVisible = function (selector, options) {
139
- if (options === void 0) { options = {}; }
140
- return tslib_1.__awaiter(this, void 0, void 0, function () {
138
+ O3rComponentFixture.prototype.isVisible = function (selector_1) {
139
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
141
140
  var element;
141
+ if (options === void 0) { options = {}; }
142
142
  return tslib_1.__generator(this, function (_a) {
143
143
  switch (_a.label) {
144
144
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -159,10 +159,10 @@ var O3rComponentFixture = /** @class */ (function () {
159
159
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
160
160
  * @param options.timeout Duration to wait for the element to be present before it throws
161
161
  */
162
- O3rComponentFixture.prototype.click = function (selector, options) {
163
- if (options === void 0) { options = {}; }
164
- return tslib_1.__awaiter(this, void 0, void 0, function () {
162
+ O3rComponentFixture.prototype.click = function (selector_1) {
163
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
165
164
  var element;
165
+ if (options === void 0) { options = {}; }
166
166
  return tslib_1.__generator(this, function (_a) {
167
167
  switch (_a.label) {
168
168
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -192,10 +192,10 @@ var O3rComponentFixture = /** @class */ (function () {
192
192
  var selectedElement = { element: element, page: this.rootElement.sourceElement.page };
193
193
  return Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement));
194
194
  };
195
- O3rComponentFixture.prototype.queryAll = function (selector, returnType, groupType, timeout) {
196
- if (timeout === void 0) { timeout = 5000; }
197
- return tslib_1.__awaiter(this, void 0, void 0, function () {
195
+ O3rComponentFixture.prototype.queryAll = function (selector_1, returnType_1, groupType_1) {
196
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, returnType, groupType, timeout) {
198
197
  var sourceElement, pElements, pElementsCount, elements, i, selectedElement, group, isValid, err_1;
198
+ if (timeout === void 0) { timeout = 5000; }
199
199
  return tslib_1.__generator(this, function (_a) {
200
200
  switch (_a.label) {
201
201
  case 0:
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,4CAAuD;AAEvD,sCAAyC;AACzC,qCAAuF;AAKvF;;GAEG;AACH;IAOE;;;;OAIG;IACH,6BAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,qDAAuB,GAAvC,UAA8D,OAAW,EAAE,OAAgB;;;;;wBACzF,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBACnE,CAAC;wBACD,qBAAM,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,CA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AAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IACH,0BAAC;AAAD,CAAC,AAnND,IAmNC;AAnNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { FixtureUsageError } from '../../errors/index';\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor, PlaywrightSourceElement } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to Playwright, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement: V;\n\n /**\n * Root element of this fixture.\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 element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefinedElement<T extends O3rElement>(element?: T, timeout?: number): Promise<T> {\n if (!element) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n await element.sourceElement.element.first().waitFor({state: 'attached', timeout});\n return element;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected throwOnUndefined<T extends O3rElement>(element: Promise<T>, timeout?: number): Promise<T> {\n return withTimeout(\n (async () => {\n const el = await element;\n await el.sourceElement.element.first().waitFor({state: 'attached'});\n return el;\n })(),\n timeout);\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> {\n let element: O3rElement;\n if (options.index !== undefined) {\n element = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n element = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(element, options.timeout);\n }\n return element;\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>;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!await element.isVisible()) {\n return;\n }\n return await element.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 element = await this.queryWithOptions(selector, options.elementConstructor, options);\n return await element.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 element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (await element.isVisible()) {\n await element.click();\n }\n }\n\n /** @inheritdoc */\n public query(selector: string, returnType?: undefined): Promise<O3rElement>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.first();\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n }\n\n /** @inheritdoc */\n public queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.nth(index);\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\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 = 5000\n ): Promise<(T | O3rElement)[] | K> {\n try {\n const sourceElement = this.rootElement.sourceElement.element;\n const pElements = sourceElement.locator(selector);\n // Mandatory because count is not reliable if we don't wait for the list to be attached\n await pElements.first().waitFor({state: 'attached', timeout});\n const pElementsCount = await pElements.count();\n const elements = [];\n for (let i = 0; i < pElementsCount; i++) {\n const selectedElement: PlaywrightSourceElement = {element: pElements.nth(i), page: this.rootElement.sourceElement.page};\n elements.push(returnType ? new returnType(selectedElement) : new O3rElement(selectedElement));\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 group;\n }\n\n return elements;\n } catch (err) {\n console.warn(`Failed to query all ${selector}`, err);\n return Promise.resolve([]);\n }\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 queryNotPresent(selector: string): Promise<boolean> {\n const element = this.rootElement.sourceElement.element.locator(selector).first();\n return element.isHidden();\n }\n}\n"]}
1
+ {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,4CAAuD;AAEvD,sCAAyC;AACzC,qCAAuF;AAKvF;;GAEG;AACH;IAOE;;;;OAIG;IACH,6BAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,qDAAuB,GAAvC,UAA8D,OAAW,EAAE,OAAgB;;;;;wBACzF,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,C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,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;QACjF,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IACH,0BAAC;AAAD,CAAC,AAnND,IAmNC;AAnNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { FixtureUsageError } from '../../errors/index';\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor, PlaywrightSourceElement } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to Playwright, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement: V;\n\n /**\n * Root element of this fixture.\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 element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefinedElement<T extends O3rElement>(element?: T, timeout?: number): Promise<T> {\n if (!element) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n await element.sourceElement.element.first().waitFor({state: 'attached', timeout});\n return element;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param element ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected throwOnUndefined<T extends O3rElement>(element: Promise<T>, timeout?: number): Promise<T> {\n return withTimeout(\n (async () => {\n const el = await element;\n await el.sourceElement.element.first().waitFor({state: 'attached'});\n return el;\n })(),\n timeout);\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> {\n let element: O3rElement;\n if (options.index !== undefined) {\n element = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n element = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(element, options.timeout);\n }\n return element;\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>;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!await element.isVisible()) {\n return;\n }\n return await element.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 element = await this.queryWithOptions(selector, options.elementConstructor, options);\n return await element.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 element = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (await element.isVisible()) {\n await element.click();\n }\n }\n\n /** @inheritdoc */\n public query(selector: string, returnType?: undefined): Promise<O3rElement>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T>;\n public query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.first();\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n }\n\n /** @inheritdoc */\n public queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.nth(index);\n const selectedElement: PlaywrightSourceElement = {element: element, page: this.rootElement.sourceElement.page};\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\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 = 5000\n ): Promise<(T | O3rElement)[] | K> {\n try {\n const sourceElement = this.rootElement.sourceElement.element;\n const pElements = sourceElement.locator(selector);\n // Mandatory because count is not reliable if we don't wait for the list to be attached\n await pElements.first().waitFor({state: 'attached', timeout});\n const pElementsCount = await pElements.count();\n const elements = [];\n for (let i = 0; i < pElementsCount; i++) {\n const selectedElement: PlaywrightSourceElement = {element: pElements.nth(i), page: this.rootElement.sourceElement.page};\n elements.push(returnType ? new returnType(selectedElement) : new O3rElement(selectedElement));\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 group;\n }\n\n return elements;\n } catch (err) {\n console.warn(`Failed to query all ${selector}`, err);\n return Promise.resolve([]);\n }\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 queryNotPresent(selector: string): Promise<boolean> {\n const element = this.rootElement.sourceElement.element.locator(selector).first();\n return element.isHidden();\n }\n}\n"]}
@@ -60,10 +60,10 @@ var O3rCheckboxElement = /** @class */ (function (_super) {
60
60
  * @inheritDoc
61
61
  * If the element contains a label, the label will be used to (un)check the checkbox.
62
62
  */
63
- O3rCheckboxElement.prototype.check = function (value) {
64
- if (value === void 0) { value = true; }
65
- return tslib_1.__awaiter(this, void 0, void 0, function () {
63
+ O3rCheckboxElement.prototype.check = function () {
64
+ return tslib_1.__awaiter(this, arguments, void 0, function (value) {
66
65
  var labelElement, currentValue;
66
+ if (value === void 0) { value = true; }
67
67
  return tslib_1.__generator(this, function (_a) {
68
68
  switch (_a.label) {
69
69
  case 0: return [4 /*yield*/, this.getLabelElement()];
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-element.js","sourceRoot":"","sources":["../../../../src/core/playwright/elements/checkbox-element.ts"],"names":[],"mappings":";;;;AACA,sCAA+D;AAE/D;;GAEG;AACH;IAAwC,8CAAU;IAChD,4BAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAEa,4CAAe,GAA7B;;;;;;;wBAEU,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;wBACjF,qBAAM,eAAe,CAAC,KAAK,EAAE,EAAA;;wBAAjC,IAAI,SAA6B,EAAE,CAAC;4BAClC,sBAAO,eAAe,EAAC;wBACzB,CAAC;wBACD,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAC;;;wBAElC,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAC;;;;;KAErC;IAEa,4CAAe,GAA7B;;;;;;;wBAEU,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBACxD,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;wBAAzB,IAAI,SAAqB,EAAE,CAAC;4BAC1B,sBAAO,OAAO,EAAC;wBACjB,CAAC;;;;wBAED,OAAO,CAAC,IAAI,CAAC,gDAAgD,EAAE,KAAG,CAAC,CAAC;wBACpE,sBAAO;;;;;KAEV;IAED;;;OAGG;IACU,kCAAK,GAAlB,UAAmB,KAAY;QAAZ,sBAAA,EAAA,YAAY;;;;;4BACR,qBAAM,IAAI,CAAC,eAAe,EAAE,EAAA;;wBAA3C,YAAY,GAAG,SAA4B;6BAC7C,YAAY,EAAZ,wBAAY;wBACO,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,OAAO,CAAC,IAAI,CAAC,8BAAuB,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBACD,sBAAO,YAAY,CAAC,KAAK,EAAE,EAAC;4BAEtB,qBAAM,IAAI,CAAC,eAAe,EAAE,EAAA;4BAApC,sBAAO,CAAC,SAA4B,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAC;;;;KACzD;IAED,kBAAkB;IACX,oCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,sCAAS,GAAtB;;;;;4BACuB,qBAAM,IAAI,CAAC,eAAe,EAAE,EAAA;;wBAA3C,YAAY,GAAG,SAA4B;wBACjD,sBAAO,YAAY,CAAC,SAAS,EAAE,EAAC;;;;KACjC;IACH,yBAAC;AAAD,CAAC,AAxDD,CAAwC,oBAAU,GAwDjD;AAxDY,gDAAkB","sourcesContent":["import {CheckboxElementProfile} from '../../elements';\nimport {O3rElement, PlaywrightSourceElement} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rCheckboxElement extends O3rElement implements CheckboxElementProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n private async getInputElement() {\n try {\n const subInputElement = this.sourceElement.element.locator('input[type=\"checkbox\"]');\n if (await subInputElement.count()) {\n return subInputElement;\n }\n return this.sourceElement.element;\n } catch {\n return this.sourceElement.element;\n }\n }\n\n private async getLabelElement() {\n try {\n const element = this.sourceElement.element.locator('label');\n if (await element.count()) {\n return element;\n }\n } catch (err) {\n console.warn('Failed to retrieve label of O3rCheckboxElement', err);\n return;\n }\n }\n\n /**\n * @inheritDoc\n * If the element contains a label, the label will be used to (un)check the checkbox.\n */\n public async check(value = true) {\n const labelElement = await this.getLabelElement();\n if (labelElement) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n console.warn(`Checkbox is already ${currentValue ? 'checked' : 'unchecked'}`);\n return Promise.resolve();\n }\n return labelElement.click();\n }\n return (await this.getInputElement()).setChecked(value);\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const inputElement = await this.getInputElement();\n return inputElement.isChecked();\n }\n}\n"]}
1
+ {"version":3,"file":"checkbox-element.js","sourceRoot":"","sources":["../../../../src/core/playwright/elements/checkbox-element.ts"],"names":[],"mappings":";;;;AACA,sCAA+D;AAE/D;;GAEG;AACH;IAAwC,8CAAU;IAChD,4BAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAEa,4CAAe,GAA7B;;;;;;;wBAEU,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;wBACjF,qBAAM,eAAe,CAAC,KAAK,EAAE,EAAA;;wBAAjC,IAAI,SAA6B,EAAE,CAAC;4BAClC,sBAAO,eAAe,EAAC;wBACzB,CAAC;wBACD,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAC;;;wBAElC,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAC;;;;;KAErC;IAEa,4CAAe,GAA7B;;;;;;;wBAEU,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBACxD,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;wBAAzB,IAAI,SAAqB,EAAE,CAAC;4BAC1B,sBAAO,OAAO,EAAC;wBACjB,CAAC;;;;wBAED,OAAO,CAAC,IAAI,CAAC,gDAAgD,EAAE,KAAG,CAAC,CAAC;wBACpE,sBAAO;;;;;KAEV;IAED;;;OAGG;IACU,kCAAK,GAAlB;oEAAmB,KAAY;;YAAZ,sBAAA,EAAA,YAAY;;;4BACR,qBAAM,IAAI,CAAC,eAAe,EAAE,EAAA;;wBAA3C,YAAY,GAAG,SAA4B;6BAC7C,YAAY,EAAZ,wBAAY;wBACO,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,OAAO,CAAC,IAAI,CAAC,8BAAuB,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBACD,sBAAO,YAAY,CAAC,KAAK,EAAE,EAAC;4BAEtB,qBAAM,IAAI,CAAC,eAAe,EAAE,EAAA;4BAApC,sBAAO,CAAC,SAA4B,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAC;;;;KACzD;IAED,kBAAkB;IACX,oCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,sCAAS,GAAtB;;;;;4BACuB,qBAAM,IAAI,CAAC,eAAe,EAAE,EAAA;;wBAA3C,YAAY,GAAG,SAA4B;wBACjD,sBAAO,YAAY,CAAC,SAAS,EAAE,EAAC;;;;KACjC;IACH,yBAAC;AAAD,CAAC,AAxDD,CAAwC,oBAAU,GAwDjD;AAxDY,gDAAkB","sourcesContent":["import {CheckboxElementProfile} from '../../elements';\nimport {O3rElement, PlaywrightSourceElement} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rCheckboxElement extends O3rElement implements CheckboxElementProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n private async getInputElement() {\n try {\n const subInputElement = this.sourceElement.element.locator('input[type=\"checkbox\"]');\n if (await subInputElement.count()) {\n return subInputElement;\n }\n return this.sourceElement.element;\n } catch {\n return this.sourceElement.element;\n }\n }\n\n private async getLabelElement() {\n try {\n const element = this.sourceElement.element.locator('label');\n if (await element.count()) {\n return element;\n }\n } catch (err) {\n console.warn('Failed to retrieve label of O3rCheckboxElement', err);\n return;\n }\n }\n\n /**\n * @inheritDoc\n * If the element contains a label, the label will be used to (un)check the checkbox.\n */\n public async check(value = true) {\n const labelElement = await this.getLabelElement();\n if (labelElement) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n console.warn(`Checkbox is already ${currentValue ? 'checked' : 'unchecked'}`);\n return Promise.resolve();\n }\n return labelElement.click();\n }\n return (await this.getInputElement()).setChecked(value);\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const inputElement = await this.getInputElement();\n return inputElement.isChecked();\n }\n}\n"]}
@@ -12,9 +12,9 @@ var O3rRadioElement = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritDoc */
15
- O3rRadioElement.prototype.check = function (value) {
16
- if (value === void 0) { value = true; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ O3rRadioElement.prototype.check = function () {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (value) {
17
+ if (value === void 0) { value = true; }
18
18
  return tslib_1.__generator(this, function (_a) {
19
19
  switch (_a.label) {
20
20
  case 0: return [4 /*yield*/, this.isChecked()];
@@ -1 +1 @@
1
- {"version":3,"file":"radio-element.js","sourceRoot":"","sources":["../../../../src/core/playwright/elements/radio-element.ts"],"names":[],"mappings":";;;;AACA,sCAA+D;AAE/D;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,+BAAK,GAAlB,UAAmB,KAAY;QAAZ,sBAAA,EAAA,YAAY;;;;4BACxB,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAA3B,IAAI,CAAC,SAAsB,CAAC,KAAK,KAAK,EAAE,CAAC;4BACvC,OAAO,CAAC,IAAI,CAAC,qCAA8B,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO;wBACT,CAAC;wBACD,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAC;;;;KACrD;IAED,kBAAkB;IACL,iCAAO,GAApB;;;gBACE,sBAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;;;KAC1B;IAED,kBAAkB;IACX,mCAAS,GAAhB;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAChD,CAAC;IACH,sBAAC;AAAD,CAAC,AAvBD,CAAqC,oBAAU,GAuB9C;AAvBY,0CAAe","sourcesContent":["import {RadioElementProfile} from '../../elements';\nimport {O3rElement, PlaywrightSourceElement} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rRadioElement extends O3rElement implements RadioElementProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true) {\n if ((await this.isChecked()) === value) {\n console.warn(`O3rRadioELement is already ${value ? 'checked' : 'unchecked'}`);\n return;\n }\n return this.sourceElement.element.setChecked(value);\n }\n\n /** @inheritDoc */\n public async uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public isChecked(): Promise<boolean> {\n return this.sourceElement.element.isChecked();\n }\n}\n"]}
1
+ {"version":3,"file":"radio-element.js","sourceRoot":"","sources":["../../../../src/core/playwright/elements/radio-element.ts"],"names":[],"mappings":";;;;AACA,sCAA+D;AAE/D;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,+BAAK,GAAlB;oEAAmB,KAAY;YAAZ,sBAAA,EAAA,YAAY;;;4BACxB,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAA3B,IAAI,CAAC,SAAsB,CAAC,KAAK,KAAK,EAAE,CAAC;4BACvC,OAAO,CAAC,IAAI,CAAC,qCAA8B,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO;wBACT,CAAC;wBACD,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAC;;;;KACrD;IAED,kBAAkB;IACL,iCAAO,GAApB;;;gBACE,sBAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;;;KAC1B;IAED,kBAAkB;IACX,mCAAS,GAAhB;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAChD,CAAC;IACH,sBAAC;AAAD,CAAC,AAvBD,CAAqC,oBAAU,GAuB9C;AAvBY,0CAAe","sourcesContent":["import {RadioElementProfile} from '../../elements';\nimport {O3rElement, PlaywrightSourceElement} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class O3rRadioElement extends O3rElement implements RadioElementProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true) {\n if ((await this.isChecked()) === value) {\n console.warn(`O3rRadioELement is already ${value ? 'checked' : 'unchecked'}`);\n return;\n }\n return this.sourceElement.element.setChecked(value);\n }\n\n /** @inheritDoc */\n public async uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public isChecked(): Promise<boolean> {\n return this.sourceElement.element.isChecked();\n }\n}\n"]}
@@ -61,10 +61,10 @@ var O3rComponentFixture = /** @class */ (function () {
61
61
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
62
62
  * @param options.timeout Duration to wait for the element to be present before it throws
63
63
  */
64
- O3rComponentFixture.prototype.queryWithOptions = function (selector, elementConstructor, options) {
65
- if (options === void 0) { options = {}; }
66
- return tslib_1.__awaiter(this, void 0, void 0, function () {
64
+ O3rComponentFixture.prototype.queryWithOptions = function (selector_1, elementConstructor_1) {
65
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, elementConstructor, options) {
67
66
  var queryElement;
67
+ if (options === void 0) { options = {}; }
68
68
  return tslib_1.__generator(this, function (_a) {
69
69
  switch (_a.label) {
70
70
  case 0:
@@ -95,10 +95,10 @@ var O3rComponentFixture = /** @class */ (function () {
95
95
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
96
96
  * @param options.timeout Duration to wait for the element to be present before it throws
97
97
  */
98
- O3rComponentFixture.prototype.getText = function (selector, options) {
99
- if (options === void 0) { options = {}; }
100
- return tslib_1.__awaiter(this, void 0, void 0, function () {
98
+ O3rComponentFixture.prototype.getText = function (selector_1) {
99
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
101
100
  var getTextElement, _a;
101
+ if (options === void 0) { options = {}; }
102
102
  return tslib_1.__generator(this, function (_b) {
103
103
  switch (_b.label) {
104
104
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -129,10 +129,10 @@ var O3rComponentFixture = /** @class */ (function () {
129
129
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
130
130
  * @param options.timeout Duration to wait for the element to be present before it throws
131
131
  */
132
- O3rComponentFixture.prototype.isVisible = function (selector, options) {
133
- if (options === void 0) { options = {}; }
134
- return tslib_1.__awaiter(this, void 0, void 0, function () {
132
+ O3rComponentFixture.prototype.isVisible = function (selector_1) {
133
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
135
134
  var isVisibleElement, _a;
135
+ if (options === void 0) { options = {}; }
136
136
  return tslib_1.__generator(this, function (_b) {
137
137
  switch (_b.label) {
138
138
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -158,10 +158,10 @@ var O3rComponentFixture = /** @class */ (function () {
158
158
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
159
159
  * @param options.timeout Duration to wait for the element to be present before it throws
160
160
  */
161
- O3rComponentFixture.prototype.click = function (selector, options) {
162
- if (options === void 0) { options = {}; }
163
- return tslib_1.__awaiter(this, void 0, void 0, function () {
161
+ O3rComponentFixture.prototype.click = function (selector_1) {
162
+ return tslib_1.__awaiter(this, arguments, void 0, function (selector, options) {
164
163
  var clickElement, _a;
164
+ if (options === void 0) { options = {}; }
165
165
  return tslib_1.__generator(this, function (_b) {
166
166
  switch (_b.label) {
167
167
  case 0: return [4 /*yield*/, this.queryWithOptions(selector, options.elementConstructor, options)];
@@ -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,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,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;;;;gBACrG,sBAAO,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC;yBAChC,IAAI,CAAC,UAAC,EAAE;w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AC,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
+ {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,yCAAiE;AACjE,4CAAuD;AAGvD,sCA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AwB,CAAC,CAAC;wBACxD,CAAC;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"]}
@@ -12,10 +12,10 @@ var O3rCheckboxElement = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritDoc */
15
- O3rCheckboxElement.prototype.check = function (value, associatedLabel) {
16
- if (value === void 0) { value = true; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ O3rCheckboxElement.prototype.check = function () {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (value, associatedLabel) {
18
17
  var currentValue;
18
+ if (value === void 0) { value = true; }
19
19
  return tslib_1.__generator(this, function (_a) {
20
20
  switch (_a.label) {
21
21
  case 0: return [4 /*yield*/, this.isChecked()];
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/checkbox-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAwC,8CAAU;IAChD,4BAAY,aAA4B;QACtC,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,kCAAK,GAAlB,UAAmB,KAAY,EAAE,eAA4B;QAA1C,sBAAA,EAAA,YAAY;;;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBAED,sBAAO,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACjE;IAED,kBAAkB;IACX,oCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,sCAAS,GAAtB;;;;;4BACgB,qBAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAA;;wBAA7C,KAAK,GAAG,SAAqC;wBACnD,sBAAO,KAAK,EAAC;;;;KACd;IACH,yBAAC;AAAD,CAAC,AAzBD,CAAwC,oBAAU,GAyBjD;AAzBY,gDAAkB","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {CheckboxElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rCheckboxElement extends O3rElement implements CheckboxElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true, associatedLabel?: O3rElement) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n return Promise.resolve();\n }\n\n return associatedLabel ? associatedLabel.click() : this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const value = await this.sourceElement.isSelected();\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"checkbox-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/checkbox-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAwC,8CAAU;IAChD,4BAAY,aAA4B;QACtC,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,kCAAK,GAAlB;oEAAmB,KAAY,EAAE,eAA4B;;YAA1C,sBAAA,EAAA,YAAY;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBAED,sBAAO,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACjE;IAED,kBAAkB;IACX,oCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,sCAAS,GAAtB;;;;;4BACgB,qBAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAA;;wBAA7C,KAAK,GAAG,SAAqC;wBACnD,sBAAO,KAAK,EAAC;;;;KACd;IACH,yBAAC;AAAD,CAAC,AAzBD,CAAwC,oBAAU,GAyBjD;AAzBY,gDAAkB","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {CheckboxElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rCheckboxElement extends O3rElement implements CheckboxElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true, associatedLabel?: O3rElement) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n return Promise.resolve();\n }\n\n return associatedLabel ? associatedLabel.click() : this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const value = await this.sourceElement.isSelected();\n return value;\n }\n}\n"]}
@@ -12,10 +12,10 @@ var O3rRadioElement = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritDoc */
15
- O3rRadioElement.prototype.check = function (value) {
16
- if (value === void 0) { value = true; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ O3rRadioElement.prototype.check = function () {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (value) {
18
17
  var currentValue;
18
+ if (value === void 0) { value = true; }
19
19
  return tslib_1.__generator(this, function (_a) {
20
20
  switch (_a.label) {
21
21
  case 0: return [4 /*yield*/, this.isChecked()];
@@ -1 +1 @@
1
- {"version":3,"file":"radio-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/radio-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAA4B;QACtC,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,+BAAK,GAAlB,UAAmB,KAAY;QAAZ,sBAAA,EAAA,YAAY;;;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,OAAO,CAAC,IAAI,CAAC,qCAA8B,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBAED,sBAAO,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACrB;IAED,kBAAkB;IACX,iCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,mCAAS,GAAtB;;;;;4BACkB,qBAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA;;wBAA5C,OAAO,GAAG,SAAkC;wBAClD,sBAAO,OAAO,KAAK,SAAS,EAAC;;;;KAC9B;IACH,sBAAC;AAAD,CAAC,AA1BD,CAAqC,oBAAU,GA0B9C;AA1BY,0CAAe","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {RadioElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rRadioElement extends O3rElement implements RadioElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n console.warn(`O3rRadioElement is already ${value ? 'checked' : 'unchecked'}`);\n return Promise.resolve();\n }\n\n return this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const checked = await this.getAttribute('checked');\n return checked !== undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"radio-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/radio-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAA4B;QACtC,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,+BAAK,GAAlB;oEAAmB,KAAY;;YAAZ,sBAAA,EAAA,YAAY;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,OAAO,CAAC,IAAI,CAAC,qCAA8B,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBAED,sBAAO,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACrB;IAED,kBAAkB;IACX,iCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,mCAAS,GAAtB;;;;;4BACkB,qBAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA;;wBAA5C,OAAO,GAAG,SAAkC;wBAClD,sBAAO,OAAO,KAAK,SAAS,EAAC;;;;KAC9B;IACH,sBAAC;AAAD,CAAC,AA1BD,CAAqC,oBAAU,GA0B9C;AA1BY,0CAAe","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {RadioElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rRadioElement extends O3rElement implements RadioElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n console.warn(`O3rRadioElement is already ${value ? 'checked' : 'unchecked'}`);\n return Promise.resolve();\n }\n\n return this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const checked = await this.getAttribute('checked');\n return checked !== undefined;\n }\n}\n"]}
@@ -8,11 +8,11 @@ var temporal_polyfill_1 = require("temporal-polyfill");
8
8
  * @param mock the mock instance provided by the hook method of Kassette
9
9
  * @param inputOptions default options will extract ISO strings and use 'day-offset' mode
10
10
  */
11
- function updateDatesInMocks(mock, inputOptions) {
12
- var _a, _b;
13
- if (inputOptions === void 0) { inputOptions = {}; }
14
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
- var plainDateLength, options, todayTime, replaceDatesInInput, checksum, _c, localPayload, referenceTime, timeOffset_1, replaceDatesInOutput, wrappedPayload;
11
+ function updateDatesInMocks(mock_1) {
12
+ return tslib_1.__awaiter(this, arguments, void 0, function (mock, inputOptions) {
13
+ var plainDateLength, options, todayTime, replaceDatesInInput, checksum, _a, localPayload, referenceTime, timeOffset_1, replaceDatesInOutput, wrappedPayload;
14
+ var _b, _c;
15
+ if (inputOptions === void 0) { inputOptions = {}; }
16
16
  return tslib_1.__generator(this, function (_d) {
17
17
  switch (_d.label) {
18
18
  case 0:
@@ -53,17 +53,17 @@ function updateDatesInMocks(mock, inputOptions) {
53
53
  case 1:
54
54
  checksum = _d.sent();
55
55
  mock.setLocalPath([mock.localPath, checksum]);
56
- _c = /get|post/.test(mock.request.method);
57
- if (!_c) return [3 /*break*/, 3];
56
+ _a = /get|post/.test(mock.request.method);
57
+ if (!_a) return [3 /*break*/, 3];
58
58
  return [4 /*yield*/, mock.hasLocalMock()];
59
59
  case 2:
60
- _c = (_d.sent());
60
+ _a = (_d.sent());
61
61
  _d.label = 3;
62
62
  case 3:
63
- if (!_c) return [3 /*break*/, 6];
63
+ if (!_a) return [3 /*break*/, 6];
64
64
  return [4 /*yield*/, mock.readLocalPayload()];
65
65
  case 4:
66
- localPayload = (_a = (_d.sent())) === null || _a === void 0 ? void 0 : _a.payload;
66
+ localPayload = (_b = (_d.sent())) === null || _b === void 0 ? void 0 : _b.payload;
67
67
  if (!(localPayload && localPayload.data.creationDateTime)) return [3 /*break*/, 6];
68
68
  referenceTime = temporal_polyfill_1.Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));
69
69
  timeOffset_1 = temporal_polyfill_1.Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });
@@ -83,7 +83,7 @@ function updateDatesInMocks(mock, inputOptions) {
83
83
  };
84
84
  wrappedPayload = mock.createPayload({
85
85
  data: localPayload.data,
86
- body: replaceDatesInOutput(((_b = localPayload.body) === null || _b === void 0 ? void 0 : _b.toString()) || '')
86
+ body: replaceDatesInOutput(((_c = localPayload.body) === null || _c === void 0 ? void 0 : _c.toString()) || '')
87
87
  });
88
88
  mock.fillResponseFromPayload(wrappedPayload);
89
89
  return [4 /*yield*/, mock.sendResponse()];
@@ -1 +1 @@
1
- {"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;;;AACA,uDAA2C;A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AC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,UAAC,KAAK,IAAK,OAAA,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,CAAC,YAAU,CAAC,IAAI,GAAG,CAAC,CAAC,MAAG,CAAC,CAAC,EAAtG,CAAsG,CAAC,CAAC;4BAC9J,CAAC;wBACH,CAAC;wBACD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC;oBACI,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;wBACxC,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,IAAI,EAAE,oBAAoB,CAAC,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC;qBAChE,CAAC,CAAC;oBACH,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;oBAC7C,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;oBAAzB,SAAyB,CAAC;;;;;;CAIjC;AAtED,gDAsEC","sourcesContent":["import type {IMock} from '@amadeus-it-group/kassette';\nimport {Temporal} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options: 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"]}
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;gEAAC,IAAW,EAAE,YAAqD;;;QAArD,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,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qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;oBAAzB,SAAyB,CAAC;;;;;;CAIjC;AAtED,gDAsEC","sourcesContent":["import type {IMock} from '@amadeus-it-group/kassette';\nimport {Temporal} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options: 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/testing",
3
- "version": "10.2.0-prerelease.9",
3
+ "version": "10.3.0-prerelease.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -95,25 +95,25 @@
95
95
  },
96
96
  "peerDependencies": {
97
97
  "@amadeus-it-group/kassette": "^1.7.0",
98
- "@angular-devkit/schematics": "~17.2.0",
99
- "@angular/animations": "~17.2.0",
100
- "@angular/common": "~17.2.0",
101
- "@angular/core": "~17.2.0",
102
- "@angular/forms": "~17.2.0",
103
- "@angular/platform-browser": "~17.2.0",
98
+ "@angular-devkit/schematics": "~17.3.0",
99
+ "@angular/animations": "~17.3.0",
100
+ "@angular/common": "~17.3.0",
101
+ "@angular/core": "~17.3.0",
102
+ "@angular/forms": "~17.3.0",
103
+ "@angular/platform-browser": "~17.3.0",
104
104
  "@ngrx/store": "~17.1.0",
105
105
  "@ngx-translate/core": "~15.0.0",
106
- "@o3r/core": "^10.2.0-prerelease.9",
107
- "@o3r/localization": "^10.2.0-prerelease.9",
108
- "@o3r/schematics": "^10.2.0-prerelease.9",
109
- "@playwright/test": "~1.42.0",
110
- "@schematics/angular": "~17.2.0",
106
+ "@o3r/core": "^10.3.0-prerelease.0",
107
+ "@o3r/localization": "^10.3.0-prerelease.0",
108
+ "@o3r/schematics": "^10.3.0-prerelease.0",
109
+ "@playwright/test": "~1.43.0",
110
+ "@schematics/angular": "~17.3.0",
111
111
  "pixelmatch": "^5.2.1",
112
112
  "pngjs": "^7.0.0",
113
113
  "protractor": "^7.0.0",
114
114
  "rxjs": "^7.8.1",
115
115
  "temporal-polyfill": "^0.2.0",
116
- "typescript": "~5.3.3"
116
+ "typescript": "~5.4.2"
117
117
  },
118
118
  "peerDependenciesMeta": {
119
119
  "@amadeus-it-group/kassette": {
@@ -156,59 +156,59 @@
156
156
  "dependencies": {
157
157
  "esbuild": "~0.20.0",
158
158
  "module-from-string": "^3.2.0",
159
- "tslib": "^2.5.3"
159
+ "tslib": "^2.6.2"
160
160
  },
161
161
  "devDependencies": {
162
162
  "@amadeus-it-group/kassette": "^1.7.0",
163
- "@angular-devkit/build-angular": "~17.2.0",
164
- "@angular-devkit/core": "~17.2.0",
165
- "@angular-devkit/schematics": "~17.2.0",
166
- "@angular-eslint/eslint-plugin": "~17.2.0",
167
- "@angular/cli": "~17.2.0",
168
- "@angular/common": "~17.2.0",
169
- "@angular/compiler": "~17.2.0",
170
- "@angular/compiler-cli": "~17.2.0",
171
- "@angular/core": "~17.2.0",
172
- "@angular/forms": "~17.2.0",
173
- "@angular/platform-browser": "~17.2.0",
174
- "@angular/platform-browser-dynamic": "~17.2.0",
163
+ "@angular-devkit/build-angular": "~17.3.0",
164
+ "@angular-devkit/core": "~17.3.0",
165
+ "@angular-devkit/schematics": "~17.3.0",
166
+ "@angular-eslint/eslint-plugin": "~17.3.0",
167
+ "@angular/cli": "~17.3.0",
168
+ "@angular/common": "~17.3.0",
169
+ "@angular/compiler": "~17.3.0",
170
+ "@angular/compiler-cli": "~17.3.0",
171
+ "@angular/core": "~17.3.0",
172
+ "@angular/forms": "~17.3.0",
173
+ "@angular/platform-browser": "~17.3.0",
174
+ "@angular/platform-browser-dynamic": "~17.3.0",
175
175
  "@babel/core": "~7.24.0",
176
- "@babel/preset-typescript": "~7.23.0",
176
+ "@babel/preset-typescript": "~7.24.0",
177
177
  "@compodoc/compodoc": "^1.1.19",
178
178
  "@ngrx/store": "~17.1.0",
179
179
  "@ngx-translate/core": "~15.0.0",
180
- "@nx/eslint-plugin": "~18.0.2",
181
- "@nx/jest": "~18.0.2",
182
- "@o3r/build-helpers": "^10.2.0-prerelease.9",
183
- "@o3r/core": "^10.2.0-prerelease.9",
184
- "@o3r/eslint-plugin": "^10.2.0-prerelease.9",
185
- "@o3r/localization": "^10.2.0-prerelease.9",
186
- "@o3r/schematics": "^10.2.0-prerelease.9",
187
- "@o3r/test-helpers": "^10.2.0-prerelease.9",
188
- "@playwright/test": "~1.42.0",
189
- "@schematics/angular": "~17.2.0",
180
+ "@nx/eslint-plugin": "~18.2.0",
181
+ "@nx/jest": "~18.2.0",
182
+ "@o3r/build-helpers": "^10.3.0-prerelease.0",
183
+ "@o3r/core": "^10.3.0-prerelease.0",
184
+ "@o3r/eslint-plugin": "^10.3.0-prerelease.0",
185
+ "@o3r/localization": "^10.3.0-prerelease.0",
186
+ "@o3r/schematics": "^10.3.0-prerelease.0",
187
+ "@o3r/test-helpers": "^10.3.0-prerelease.0",
188
+ "@playwright/test": "~1.43.0",
189
+ "@schematics/angular": "~17.3.0",
190
190
  "@stylistic/eslint-plugin-ts": "^1.5.4",
191
191
  "@types/jest": "~29.5.2",
192
192
  "@types/node": "^20.0.0",
193
193
  "@types/pixelmatch": "^5.2.3",
194
194
  "@types/pngjs": "^6.0.0",
195
- "@typescript-eslint/eslint-plugin": "^7.0.1",
196
- "@typescript-eslint/parser": "^7.0.1",
195
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
196
+ "@typescript-eslint/parser": "^7.2.0",
197
197
  "concurrently": "^8.0.0",
198
198
  "cpy-cli": "^5.0.0",
199
- "eslint": "^8.42.0",
200
- "eslint-import-resolver-node": "^0.3.4",
199
+ "eslint": "^8.57.0",
200
+ "eslint-import-resolver-node": "^0.3.9",
201
201
  "eslint-plugin-jest": "~27.9.0",
202
- "eslint-plugin-jsdoc": "~48.2.0",
202
+ "eslint-plugin-jsdoc": "~48.2.1",
203
203
  "eslint-plugin-prefer-arrow": "~1.2.3",
204
- "eslint-plugin-unicorn": "^51.0.0",
204
+ "eslint-plugin-unicorn": "^51.0.1",
205
205
  "isomorphic-fetch": "~3.0.0",
206
206
  "jest": "~29.7.0",
207
207
  "jest-environment-jsdom": "~29.7.0",
208
208
  "jest-junit": "~16.0.0",
209
- "jest-preset-angular": "~14.0.0",
209
+ "jest-preset-angular": "~14.0.3",
210
210
  "jsonc-eslint-parser": "~2.4.0",
211
- "nx": "~18.0.2",
211
+ "nx": "~18.2.0",
212
212
  "pid-from-port": "^1.1.3",
213
213
  "pixelmatch": "^5.2.1",
214
214
  "pngjs": "^7.0.0",
@@ -216,10 +216,10 @@
216
216
  "rxjs": "^7.8.1",
217
217
  "semver": "^7.5.2",
218
218
  "temporal-polyfill": "^0.2.0",
219
- "ts-jest": "~29.1.1",
220
- "ts-node": "~10.9.1",
219
+ "ts-jest": "~29.1.2",
220
+ "ts-node": "~10.9.2",
221
221
  "type-fest": "^4.10.2",
222
- "typescript": "~5.3.3",
222
+ "typescript": "~5.4.2",
223
223
  "zone.js": "~0.14.2"
224
224
  },
225
225
  "schematics": "./collection.json",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAKjF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,4BAA4B,EAAE,OAAO,GAAG,IAAI,CA4FnL"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAIjF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,EAAE,4BAA4B,EAAE,OAAO,GAAG,IAAI,CA6FnL"}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateFixtureConfig = void 0;
4
4
  /* eslint-disable @typescript-eslint/naming-convention */
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
- const schematics_2 = require("@o3r/schematics");
7
6
  const ts = require("typescript");
8
7
  /**
9
8
  * Add fixture configuration
@@ -19,10 +18,11 @@ function updateFixtureConfig(options, registerUnitTestFixturePaths) {
19
18
  * @param tree
20
19
  * @param context
21
20
  */
22
- const updateTestTsconfig = (tree, context) => {
23
- const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
21
+ const updateTestTsconfig = async (tree, context) => {
22
+ const { getTestFramework, getWorkspaceConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
23
+ const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
24
24
  if (!workspaceProject) {
25
- return tree;
25
+ return;
26
26
  }
27
27
  const testTarget = workspaceProject.architect && workspaceProject.architect.test;
28
28
  const tsconfig = testTarget && testTarget.options && testTarget.options.tsConfig;
@@ -40,7 +40,7 @@ function updateFixtureConfig(options, registerUnitTestFixturePaths) {
40
40
  }
41
41
  return libs;
42
42
  }, []);
43
- const testFramework = options.testingFramework || (0, schematics_2.getTestFramework)((0, schematics_2.getWorkspaceConfig)(tree), context);
43
+ const testFramework = options.testingFramework || getTestFramework(getWorkspaceConfig(tree), context);
44
44
  if (testFramework === 'jest') {
45
45
  tsconfigCompilerOptions.types ||= [];
46
46
  if (tsconfigCompilerOptions.types.indexOf('jest') === -1) {
@@ -51,7 +51,7 @@ function updateFixtureConfig(options, registerUnitTestFixturePaths) {
51
51
  tsconfigCompilerOptions.outDir = 'test';
52
52
  tree.overwrite(tsconfig, JSON.stringify(tsconfigFile, null, 2));
53
53
  }
54
- return tree;
54
+ return;
55
55
  };
56
56
  /**
57
57
  * Update base tsconfig paths with o3r fixtures
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,2DAAiF;AACjF,gDAAuE;AAEvE,iCAAiC;AAEjC;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,OAAkG,EAAE,4BA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CAAC,eAAe,CAAC,OAAO,KAAK,GAAG,CAAC;YACvD,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;YAC/G,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACrH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEzF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,IAAA,kBAAK,EAAC,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,CAAC;AACxE,CAAC;AA7FD,kDA6FC"}
@@ -125,10 +125,10 @@ var PostMessageInterceptor = /** @class */ (function () {
125
125
  * @param timeoutInterval Interval in milliseconds between two checks
126
126
  * @param retries How many retries to be executed (-1 for infinite retries)
127
127
  */
128
- PostMessageInterceptor.prototype.getMessages = function (timeoutInterval, retries) {
129
- if (timeoutInterval === void 0) { timeoutInterval = 100; }
130
- if (retries === void 0) { retries = -1; }
131
- return tslib_1.__awaiter(this, void 0, void 0, function () {
128
+ PostMessageInterceptor.prototype.getMessages = function () {
129
+ return tslib_1.__awaiter(this, arguments, void 0, function (timeoutInterval, retries) {
130
+ if (timeoutInterval === void 0) { timeoutInterval = 100; }
131
+ if (retries === void 0) { retries = -1; }
132
132
  return tslib_1.__generator(this, function (_a) {
133
133
  switch (_a.label) {
134
134
  case 0: return [4 /*yield*/, this.execInstanceAsyncMethod('getMessages', timeoutInterval, retries)];
@@ -1 +1 @@
1
- {"version":3,"file":"post-message-interceptor.js","sourceRoot":"","sources":["../../../../src/tools/protractor/post-message-interceptor/post-message-interceptor.ts"],"names":[],"mappings":";;;;AAAA,4BAA8B;AAC9B,gCAAkC;AAClC,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AAnB,UAAoB,WAAyB;;;;4BAC3C,qBAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAA;;wBAApD,SAAoD,CAAC;;;;;KACtD;IAED;;OAEG;IACU,8CAAa,GAA1B;;;;4BACE,qBAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAA;;wBAA9C,SAA8C,CAAC;;;;;KAChD;IAED;;;;OAIG;IACU,4CAAW,GAAxB,UAAyB,eAAqB,EAAE,OAAY;QAAnC,gCAAA,EAAA,qBAAqB;QAAE,wBAAA,EAAA,WAAW,CAAC;;;;4BAClD,qBAAM,IAAI,CAAC,uBAAuB,CAAC,aAAa,EAAE,eAAe,EAAE,OAAO,CAAC,EAAA;4BAAnF,sBAAO,CAAC,SAA2E,CAAsB,EAAC;;;;KAC3G;IACH,6BAAC;AAAD,CAAC,AAlED,IAkEC;AAlEY,wDAAsB","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { browser } from 'protractor';\n\nimport { ConditionFn, PostMessageCall } from './core';\n\n/**\n * Controls the postMessage interceptor\n */\nexport class PostMessageInterceptor {\n private readonly GET_INSTANCE = 'window.postMessageInterceptor.getInstance()';\n\n /**\n * Executes a script in the app\n * @param methodName\n * @param {...any} args\n */\n private async execInstanceMethod(methodName: string, ...args: any[]) {\n return await browser.executeScript(`${this.GET_INSTANCE}.${methodName}(...arguments);`, ...args);\n }\n\n /**\n * Executes an async script in the app\n * @param methodName\n * @param {...any} args\n */\n private async execInstanceAsyncMethod(methodName: string, ...args: any[]) {\n return await browser.executeAsyncScript(`${this.GET_INSTANCE}.${methodName}(...arguments);`, ...args);\n }\n\n /**\n * Initializes the PostMessageInterceptor in the app\n * NOTE: It does not start listening right away. You need to call listen()\n */\n public async initialize() {\n const fetchManager = fs.readFileSync(\n path.resolve(process.cwd(), 'node_modules', '@o3r', 'testing', 'tools', 'protractor', 'post-message-interceptor', '_post-message-interceptor.js'),\n {\n encoding: 'utf-8'\n }\n );\n await browser.executeScript(fetchManager);\n await this.execInstanceMethod('init');\n }\n\n /**\n * Stops the PostMessageInterceptor.\n */\n public async stop() {\n await this.execInstanceMethod('stop');\n }\n\n /**\n * Listens for post messages\n * @param conditionFn an optional boolean function that will evaluate if the message should be saved or not in the stack\n */\n public async listen(conditionFn?: ConditionFn) {\n await this.execInstanceMethod('listen', conditionFn);\n }\n\n /**\n * Stops listening for post messages, resets the stack and clears the condition\n */\n public async stopListening() {\n await this.execInstanceMethod('stopListening');\n }\n\n /**\n * Get all the post messages\n * @param timeoutInterval Interval in milliseconds between two checks\n * @param retries How many retries to be executed (-1 for infinite retries)\n */\n public async getMessages(timeoutInterval = 100, retries = -1): Promise<PostMessageCall[]> {\n return (await this.execInstanceAsyncMethod('getMessages', timeoutInterval, retries)) as PostMessageCall[];\n }\n}\n"]}
1
+ {"version":3,"file":"post-message-interceptor.js","sourceRoot":"","sources":["../../../../src/tools/protractor/post-message-interceptor/post-message-interceptor.ts"],"names":[],"mappings":";;;;AAAA,4BAA8B;AAC9B,gCAAkC;AAClC,yCAAqC;AAIrC;;GAEG;AACH;IAAA;QACmB,iBAAY,GAAG,6CAA6C,CAAC;IAiEhF,CAAC;IA/DC;;;;OAIG;IACW,mDAAkB,GAAhC,UAAiC,UAAkB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;;;;4BAC1D,qBAAM,oBAAO,CAAC,aAAa,OAArB,oBAAO,yBAAe,UAAG,IAAI,CAAC,YAAY,cAAI,UAAU,oBAAiB,GAAK,IAAI,WAAC;4BAAhG,sBAAO,SAAyF,EAAC;;;;KAClG;IAED;;;;OAIG;IACW,wDAAuB,GAArC,UAAsC,UAAkB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;;;;4BAC/D,qBAAM,oBAAO,CAAC,kBAAkB,OAA1B,oBAAO,yBAAoB,UAAG,IAAI,CAAC,YAAY,cAAI,UA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sB","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { browser } from 'protractor';\n\nimport { ConditionFn, PostMessageCall } from './core';\n\n/**\n * Controls the postMessage interceptor\n */\nexport class PostMessageInterceptor {\n private readonly GET_INSTANCE = 'window.postMessageInterceptor.getInstance()';\n\n /**\n * Executes a script in the app\n * @param methodName\n * @param {...any} args\n */\n private async execInstanceMethod(methodName: string, ...args: any[]) {\n return await browser.executeScript(`${this.GET_INSTANCE}.${methodName}(...arguments);`, ...args);\n }\n\n /**\n * Executes an async script in the app\n * @param methodName\n * @param {...any} args\n */\n private async execInstanceAsyncMethod(methodName: string, ...args: any[]) {\n return await browser.executeAsyncScript(`${this.GET_INSTANCE}.${methodName}(...arguments);`, ...args);\n }\n\n /**\n * Initializes the PostMessageInterceptor in the app\n * NOTE: It does not start listening right away. You need to call listen()\n */\n public async initialize() {\n const fetchManager = fs.readFileSync(\n path.resolve(process.cwd(), 'node_modules', '@o3r', 'testing', 'tools', 'protractor', 'post-message-interceptor', '_post-message-interceptor.js'),\n {\n encoding: 'utf-8'\n }\n );\n await browser.executeScript(fetchManager);\n await this.execInstanceMethod('init');\n }\n\n /**\n * Stops the PostMessageInterceptor.\n */\n public async stop() {\n await this.execInstanceMethod('stop');\n }\n\n /**\n * Listens for post messages\n * @param conditionFn an optional boolean function that will evaluate if the message should be saved or not in the stack\n */\n public async listen(conditionFn?: ConditionFn) {\n await this.execInstanceMethod('listen', conditionFn);\n }\n\n /**\n * Stops listening for post messages, resets the stack and clears the condition\n */\n public async stopListening() {\n await this.execInstanceMethod('stopListening');\n }\n\n /**\n * Get all the post messages\n * @param timeoutInterval Interval in milliseconds between two checks\n * @param retries How many retries to be executed (-1 for infinite retries)\n */\n public async getMessages(timeoutInterval = 100, retries = -1): Promise<PostMessageCall[]> {\n return (await this.execInstanceAsyncMethod('getMessages', timeoutInterval, retries)) as PostMessageCall[];\n }\n}\n"]}