@o3r/testing 13.5.0-prerelease.8 → 13.5.0-rc.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.
@@ -51,7 +51,7 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
51
51
  * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
52
52
  * @param options.index index Select the element associated to the index
53
53
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
54
- * @param options.timeout Duration to wait for the element to be present before it throws
54
+ * @param options.timeout Duration to wait for the element
55
55
  */
56
56
  protected getText<T extends O3rElement>(selector: string, options?: {
57
57
  elementConstructor?: O3rElementConstructor<T>;
@@ -66,7 +66,7 @@ export declare class O3rComponentFixture<V extends O3rElement = O3rElement> impl
66
66
  * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
67
67
  * @param options.index index Select the element associated to the index
68
68
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
69
- * @param options.timeout Duration to wait for the element to be present before it throws
69
+ * @param options.timeout Duration to wait for the element
70
70
  */
71
71
  protected isVisible<T extends O3rElement>(selector: string, options?: {
72
72
  elementConstructor?: O3rElementConstructor<T> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.d.ts","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,UAAU,EACV,qBAAqB,EAEtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,QAAQ,EACR,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEtG;;GAEG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,YAAW,uBAAuB,CAAC,CAAC,CAAC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CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAuC9L,kBAAkB;IACX,UAAU;IAIjB,kBAAkB;IACX,gBAAgB,IAAI,OAAO,CAAC;QAAE,CAAC,aAAa,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAAA;KAAE,CAAC;IAI1F,kBAAkB;IACX,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAI3D"}
@@ -65,13 +65,10 @@ class O3rComponentFixture {
65
65
  * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
66
66
  * @param options.index index Select the element associated to the index
67
67
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
68
- * @param options.timeout Duration to wait for the element to be present before it throws
68
+ * @param options.timeout Duration to wait for the element
69
69
  */
70
70
  async getText(selector, options = {}) {
71
71
  const element = await this.queryWithOptions(selector, options.elementConstructor, options);
72
- if (!await element.isVisible()) {
73
- return;
74
- }
75
72
  return await element.getText();
76
73
  }
77
74
  /**
@@ -81,11 +78,23 @@ class O3rComponentFixture {
81
78
  * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement
82
79
  * @param options.index index Select the element associated to the index
83
80
  * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present
84
- * @param options.timeout Duration to wait for the element to be present before it throws
81
+ * @param options.timeout Duration to wait for the element
85
82
  */
86
83
  async isVisible(selector, options = {}) {
87
84
  const element = await this.queryWithOptions(selector, options.elementConstructor, options);
88
- return await element.isVisible();
85
+ if (options.timeout) {
86
+ try {
87
+ await element.sourceElement.element.waitFor({
88
+ state: 'visible',
89
+ timeout: options.timeout
90
+ });
91
+ return true;
92
+ }
93
+ catch {
94
+ return false;
95
+ }
96
+ }
97
+ return element.isVisible();
89
98
  }
90
99
  /**
91
100
  * Click on the element associated to the given selector if it exists and is visible
@@ -98,20 +107,24 @@ class O3rComponentFixture {
98
107
  */
99
108
  async click(selector, options = {}) {
100
109
  const element = await this.queryWithOptions(selector, options.elementConstructor, options);
101
- if (await element.isVisible()) {
102
- await element.click();
103
- }
110
+ await element.click();
104
111
  }
105
112
  query(selector, returnType) {
106
113
  const elements = this.rootElement.sourceElement.element.locator(selector);
107
114
  const element = elements.first();
108
- const selectedElement = { element: element, page: this.rootElement.sourceElement.page };
115
+ const selectedElement = {
116
+ element: element,
117
+ page: this.rootElement.sourceElement.page
118
+ };
109
119
  return Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement));
110
120
  }
111
121
  queryNth(selector, index, returnType) {
112
122
  const elements = this.rootElement.sourceElement.element.locator(selector);
113
123
  const element = elements.nth(index);
114
- const selectedElement = { element: element, page: this.rootElement.sourceElement.page };
124
+ const selectedElement = {
125
+ element: element,
126
+ page: this.rootElement.sourceElement.page
127
+ };
115
128
  return Promise.resolve(new (returnType || element_1.O3rElement)(selectedElement));
116
129
  }
117
130
  async queryAll(selector, returnType, groupType, timeout = 5000) {
@@ -123,7 +136,10 @@ class O3rComponentFixture {
123
136
  const pElementsCount = await pElements.count();
124
137
  const elements = [];
125
138
  for (let i = 0; i < pElementsCount; i++) {
126
- const selectedElement = { element: pElements.nth(i), page: this.rootElement.sourceElement.page };
139
+ const selectedElement = {
140
+ element: pElements.nth(i),
141
+ page: this.rootElement.sourceElement.page
142
+ };
127
143
  elements.push(returnType ? new returnType(selectedElement) : new element_1.O3rElement(selectedElement));
128
144
  }
129
145
  if (groupType) {
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":";;;AAAA,8CAE4B;AAI5B,wCAEoB;AACpB,uCAImB;AAQnB;;GAEG;AACH,MAAa,mBAAmB;IAM9B;;;;OAIG;IACH,YAAY,WAAc;QAC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import {\n FixtureUsageError,\n} from '../../errors/index';\nimport type {\n ComponentFixtureProfile,\n} from '../component-fixture';\nimport {\n withTimeout,\n} from '../helpers';\nimport {\n O3rElement,\n O3rElementConstructor,\n PlaywrightSourceElement,\n} from './element';\nimport {\n O3rGroup,\n O3rGroupConstructor,\n} 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 * 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 const element: O3rElement = await (options.index === undefined ? this.query(selector, elementConstructor as any) : this.queryNth(selector, options.index, elementConstructor as any));\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 = { element: element, page: this.rootElement.sourceElement.page } as const satisfies PlaywrightSourceElement;\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 = { element: element, page: this.rootElement.sourceElement.page } as const satisfies PlaywrightSourceElement;\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 // eslint-disable-next-line no-console -- no other logger available\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,8CAE4B;AAI5B,wCAEoB;AACpB,uCAImB;AAQnB;;GAEG;AACH,MAAa,mBAAmB;IAM9B;;;;OAIG;IACH,YAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,uBAAuB,CAAuB,OAAW,EAAE,OAAgB;QACzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,OAAO,CAAC,aA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C,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAU,CAAC,eAAe,CAAC,CAAC,CAAC;YAChG,CAAC;YACD,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,QAAe,CAAC,CAAC;gBAC7C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE,CAAC;gBAE3C,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;gBACxD,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mEAAmE;YACnE,OAAO,CAAC,IAAI,CAAC,uBAAuB,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,kBAAkB;IACX,UAAU;QACf,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,gBAAgB;QACrB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB;IACX,eAAe,CAAC,QAAgB;QACrC,MAAM,OAAO,GAAG,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;CACF;AA7ND,kDA6NC","sourcesContent":["import {\n FixtureUsageError,\n} from '../../errors/index';\nimport type {\n ComponentFixtureProfile,\n} from '../component-fixture';\nimport {\n withTimeout,\n} from '../helpers';\nimport {\n O3rElement,\n O3rElementConstructor,\n PlaywrightSourceElement,\n} from './element';\nimport {\n O3rGroup,\n O3rGroupConstructor,\n} 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 * 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 const element: O3rElement = await (options.index === undefined ? this.query(selector, elementConstructor as any) : this.queryNth(selector, options.index, elementConstructor as any));\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\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 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\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 if (options.timeout) {\n try {\n await element.sourceElement.element.waitFor({\n state: 'visible',\n timeout: options.timeout\n });\n return true;\n } catch {\n return false;\n }\n }\n return 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 await element.click();\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 = {\n element: element,\n page: this.rootElement.sourceElement.page\n } as const satisfies PlaywrightSourceElement;\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 = {\n element: element,\n page: this.rootElement.sourceElement.page\n } as const satisfies PlaywrightSourceElement;\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 = {\n element: pElements.nth(i),\n page: this.rootElement.sourceElement.page\n };\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 // eslint-disable-next-line no-console -- no other logger available\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/testing",
3
- "version": "13.5.0-prerelease.8",
3
+ "version": "13.5.0-rc.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -99,10 +99,10 @@
99
99
  "@material/slider": "^14.0.0",
100
100
  "@ngrx/store": "^20.0.0",
101
101
  "@ngx-translate/core": "^15.0.0 || ~16.0.4",
102
- "@o3r/core": "~13.5.0-prerelease.8",
103
- "@o3r/eslint-config": "~13.5.0-prerelease.8",
104
- "@o3r/localization": "~13.5.0-prerelease.8",
105
- "@o3r/schematics": "~13.5.0-prerelease.8",
102
+ "@o3r/core": "~13.5.0-rc.0",
103
+ "@o3r/eslint-config": "~13.5.0-rc.0",
104
+ "@o3r/localization": "~13.5.0-rc.0",
105
+ "@o3r/schematics": "~13.5.0-rc.0",
106
106
  "@playwright/test": "^1.49.0",
107
107
  "@schematics/angular": "^20.0.0",
108
108
  "eslint": "~9.39.0",
@@ -110,7 +110,6 @@
110
110
  "pngjs": "^7.0.0",
111
111
  "rxjs": "^7.8.1",
112
112
  "temporal-polyfill": "^0.3.0",
113
- "ts-node": "~10.9.2",
114
113
  "type-fest": "^4.30.1",
115
114
  "typescript": "^5.9.0"
116
115
  },
@@ -171,24 +170,24 @@
171
170
  }
172
171
  },
173
172
  "dependencies": {
174
- "@o3r/schematics": "~13.5.0-prerelease.8",
173
+ "@o3r/schematics": "~13.5.0-rc.0",
175
174
  "esbuild": "~0.25.1",
176
175
  "module-from-string": "^3.2.0",
177
176
  "tslib": "^2.6.2"
178
177
  },
179
178
  "devDependencies": {
180
179
  "@amadeus-it-group/kassette": "^1.7.0",
181
- "@angular-devkit/build-angular": "~20.3.11",
182
- "@angular-devkit/core": "~20.3.11",
183
- "@angular-devkit/schematics": "~20.3.11",
184
- "@angular/cli": "~20.3.11",
185
- "@angular/common": "~20.3.13",
186
- "@angular/compiler": "~20.3.13",
187
- "@angular/compiler-cli": "~20.3.13",
188
- "@angular/core": "~20.3.13",
189
- "@angular/forms": "~20.3.13",
190
- "@angular/platform-browser": "~20.3.13",
191
- "@angular/platform-browser-dynamic": "~20.3.13",
180
+ "@angular-devkit/build-angular": "~20.3.13",
181
+ "@angular-devkit/core": "~20.3.13",
182
+ "@angular-devkit/schematics": "~20.3.13",
183
+ "@angular/cli": "~20.3.13",
184
+ "@angular/common": "~20.3.15",
185
+ "@angular/compiler": "~20.3.15",
186
+ "@angular/compiler-cli": "~20.3.15",
187
+ "@angular/core": "~20.3.15",
188
+ "@angular/forms": "~20.3.15",
189
+ "@angular/platform-browser": "~20.3.15",
190
+ "@angular/platform-browser-dynamic": "~20.3.15",
192
191
  "@babel/core": "~7.28.0",
193
192
  "@babel/preset-typescript": "~7.28.0",
194
193
  "@compodoc/compodoc": "^1.1.32",
@@ -198,20 +197,20 @@
198
197
  "@ngx-translate/core": "~16.0.4",
199
198
  "@nx/eslint-plugin": "~21.6.0",
200
199
  "@nx/jest": "~21.6.0",
201
- "@o3r/build-helpers": "~13.5.0-prerelease.8",
202
- "@o3r/core": "~13.5.0-prerelease.8",
203
- "@o3r/eslint-plugin": "~13.5.0-prerelease.8",
204
- "@o3r/localization": "~13.5.0-prerelease.8",
205
- "@o3r/test-helpers": "~13.5.0-prerelease.8",
200
+ "@o3r/build-helpers": "~13.5.0-rc.0",
201
+ "@o3r/core": "~13.5.0-rc.0",
202
+ "@o3r/eslint-plugin": "~13.5.0-rc.0",
203
+ "@o3r/localization": "~13.5.0-rc.0",
204
+ "@o3r/test-helpers": "~13.5.0-rc.0",
206
205
  "@playwright/test": "~1.57.0",
207
- "@schematics/angular": "~20.3.11",
206
+ "@schematics/angular": "~20.3.13",
208
207
  "@stylistic/eslint-plugin": "~5.6.0",
209
- "@swc/helpers": "~0.5.0",
210
- "@types/jest": "~29.5.2",
211
- "@types/node": "~22.18.0",
208
+ "@swc/helpers": "~0.5.17",
209
+ "@types/jest": "~30.0.0",
210
+ "@types/node": "~24.10.0",
212
211
  "@types/pixelmatch": "^5.2.3",
213
212
  "@types/pngjs": "^6.0.0",
214
- "@typescript-eslint/parser": "~8.47.0",
213
+ "@typescript-eslint/parser": "~8.49.0",
215
214
  "angular-eslint": "~20.6.0",
216
215
  "concurrently": "^9.1.0",
217
216
  "cpy-cli": "^6.0.0",
@@ -220,18 +219,19 @@
220
219
  "eslint-import-resolver-typescript": "~4.4.0",
221
220
  "eslint-plugin-import": "~2.32.0",
222
221
  "eslint-plugin-import-newlines": "~1.4.0",
223
- "eslint-plugin-jest": "~29.1.0",
222
+ "eslint-plugin-jest": "~29.2.0",
224
223
  "eslint-plugin-jsdoc": "~54.7.0",
225
224
  "eslint-plugin-prefer-arrow": "~1.2.3",
226
225
  "eslint-plugin-unicorn": "~60.0.0",
227
226
  "eslint-plugin-unused-imports": "~4.3.0",
228
227
  "globals": "^16.0.0",
229
228
  "isomorphic-fetch": "~3.0.0",
230
- "jest": "~29.7.0",
231
- "jest-environment-jsdom": "~29.7.0",
229
+ "jest": "~30.2.0",
230
+ "jest-environment-jsdom": "~30.2.0",
232
231
  "jest-junit": "~16.0.0",
233
- "jest-preset-angular": "~14.6.0",
234
- "jest-util": "~29.7.0",
232
+ "jest-preset-angular": "~16.0.0",
233
+ "jest-util": "~30.2.0",
234
+ "jsdom": "^26.1.0",
235
235
  "jsonc-eslint-parser": "~2.4.0",
236
236
  "nx": "~21.6.0",
237
237
  "pixelmatch": "^7.0.0",
@@ -240,15 +240,20 @@
240
240
  "semver": "^7.5.2",
241
241
  "temporal-polyfill": "^0.3.0",
242
242
  "ts-jest": "~29.4.0",
243
- "ts-node": "~10.9.2",
244
243
  "type-fest": "^4.30.1",
245
244
  "typescript": "~5.9.2",
246
- "typescript-eslint": "~8.47.0",
245
+ "typescript-eslint": "~8.49.0",
247
246
  "zone.js": "~0.15.0"
248
247
  },
249
248
  "generatorDependencies": {
250
249
  "@angular-builders/jest": "~20.0.0",
251
- "rimraf": "^6.0.1"
250
+ "@types/jest": "~30.0.0",
251
+ "jest": "~30.2.0",
252
+ "jest-environment-jsdom": "~30.2.0",
253
+ "jest-preset-angular": "~16.0.0",
254
+ "jest-util": "~30.2.0",
255
+ "rimraf": "^6.0.1",
256
+ "ts-jest": "~29.4.0"
252
257
  },
253
258
  "schematics": "./collection.json",
254
259
  "ng-update": {
@@ -25,6 +25,12 @@ module.exports.getJestProjectConfig = (rootDir, isAngularSetup) => {
25
25
  );
26
26
  moduleNameMapper['^@o3r/testing/core$'] = [require.resolve('@o3r/testing/core/angular')];
27
27
  moduleNameMapper['^@o3r/testing/core/(.*)'] = [join(require.resolve('@o3r/testing/core/angular'), '$1')];
28
+ let angularConfig = {};
29
+ if (isAngularSetup) {
30
+ const { createCjsPreset } = require('jest-preset-angular/presets');
31
+ angularConfig = createCjsPreset();
32
+ }
33
+
28
34
  return {
29
35
  preset: 'ts-jest',
30
36
  setupFilesAfterEnv: ['<rootDir>/testing/setup-jest.ts'],
@@ -56,20 +62,7 @@ module.exports.getJestProjectConfig = (rootDir, isAngularSetup) => {
56
62
  customExportConditions: ['require', 'node']
57
63
  },
58
64
  workerIdleMemoryLimit: '700MB',
59
- ...isAngularSetup ? {
60
- preset: 'jest-preset-angular',
61
- transform: {
62
- // eslint-disable-next-line @typescript-eslint/naming-convention
63
- '^.+\\.tsx?$': [
64
- 'jest-preset-angular',
65
- {
66
- tsconfig: '<rootDir>/tsconfig.spec.json',
67
- stringifyContentPathRegex: '\\.html$'
68
- }
69
- ]
70
- },
71
- globalSetup: 'jest-preset-angular/global-setup',
72
- } : {}
65
+ ...angularConfig
73
66
  };
74
67
  };
75
68