@o3r/testing 14.0.0-next.0 → 14.0.0-next.10

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 (37) hide show
  1. package/core/playwright/component-fixture.d.ts +2 -2
  2. package/core/playwright/component-fixture.d.ts.map +1 -1
  3. package/core/playwright/component-fixture.js +28 -12
  4. package/core/playwright/component-fixture.js.map +1 -1
  5. package/esm/visual-test/utils.d.ts.map +1 -1
  6. package/esm/visual-test/utils.js +1 -6
  7. package/esm/visual-test/utils.js.map +1 -1
  8. package/mocks/mock-component-generator.d.ts +2 -2
  9. package/mocks/mock-component-generator.js +2 -2
  10. package/mocks/mock-component-generator.js.map +1 -1
  11. package/package.json +62 -53
  12. package/schematics/fixture-to-component/index.d.ts.map +1 -1
  13. package/schematics/fixture-to-component/index.js +6 -5
  14. package/schematics/fixture-to-component/index.js.map +1 -1
  15. package/schematics/ng-add/fixture/index.d.ts +1 -1
  16. package/schematics/ng-add/fixture/index.js +2 -2
  17. package/schematics/ng-add/fixture/index.js.map +1 -1
  18. package/schematics/ng-add/index.d.ts.map +1 -1
  19. package/schematics/ng-add/index.js +16 -56
  20. package/schematics/ng-add/index.js.map +1 -1
  21. package/schematics/ng-add/jest/index.d.ts +13 -0
  22. package/schematics/ng-add/jest/index.d.ts.map +1 -0
  23. package/schematics/ng-add/jest/index.js +76 -0
  24. package/schematics/ng-add/jest/index.js.map +1 -0
  25. package/schematics/ng-add/{templates → jest/templates}/workspace/jest.config.ut.js.template +7 -14
  26. package/schematics/ng-add/playwright/index.d.ts +5 -1
  27. package/schematics/ng-add/playwright/index.d.ts.map +1 -1
  28. package/schematics/ng-add/playwright/index.js +10 -1
  29. package/schematics/ng-add/playwright/index.js.map +1 -1
  30. package/visual-test/utils.d.ts.map +1 -1
  31. package/visual-test/utils.js +1 -6
  32. package/visual-test/utils.js.map +1 -1
  33. /package/schematics/fixture-to-component/templates/{__name__.fixture.ts.template → __name__-fixture.ts.template} +0 -0
  34. /package/schematics/ng-add/{templates → jest/templates}/project/jest.config.js.template +0 -0
  35. /package/schematics/ng-add/{templates → jest/templates}/project/testing/setup-jest.ts.template +0 -0
  36. /package/schematics/ng-add/{templates → jest/templates}/workspace/jest.config.js.template +0 -0
  37. /package/schematics/ng-add/{templates → jest/templates}/workspace/tsconfig.jest.json.template +0 -0
@@ -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;;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CAAC,CAAC,EAAE,CAAC;IAC7I,QAAQ,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,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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,EAAE,CAAC;QACjF,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;CACF;AA9MD,kDA8MC","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 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,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\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/visual-test/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,SAAe,QAkB9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,YAGrC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,QAOzD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/visual-test/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,SAAe,QAkB9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,YAGrC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,QAGzD"}
@@ -37,11 +37,6 @@ export function isVisualTestingEnabled() {
37
37
  */
38
38
  export function toggleVisualTestingRender(enabled) {
39
39
  const visualTestingClass = 'visual-testing-render';
40
- if (enabled) {
41
- document.body.classList.add(visualTestingClass);
42
- }
43
- else {
44
- document.body.classList.remove(visualTestingClass);
45
- }
40
+ document.body.classList.toggle(visualTestingClass, enabled);
46
41
  }
47
42
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/visual-test/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAW,GAAG,YAAY;IAC7D,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,gBAAgB,CAAC,WAAW,GAAG;OAC1B,kBAAkB,KAAK,WAAW;;OAElC,kBAAkB,KAAK,WAAW;;;;;;;;;IASrC,CAAC;IAEH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,IAAI,OAAO,EAAE,CAAC;QACZ,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/visual-test/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAW,GAAG,YAAY;IAC7D,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,gBAAgB,CAAC,WAAW,GAAG;OAC1B,kBAAkB,KAAK,WAAW;;OAElC,kBAAkB,KAAK,WAAW;;;;;;;;;IASrC,CAAC;IAEH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC"}
@@ -9,7 +9,7 @@ import { Type } from '@angular/core';
9
9
  * @param config.isControlValueAccessor
10
10
  * @example
11
11
  * ```typescript
12
- * // hero.component.ts
12
+ * // hero.ts
13
13
  * \@Component({selector: 'hero'})
14
14
  * class HeroComponent {
15
15
  * \@Input() name: string;
@@ -17,7 +17,7 @@ import { Type } from '@angular/core';
17
17
  * }
18
18
  *
19
19
  * // mock generation
20
- * class MockComponent extends generateMockComponent('hero.component.ts') {}
20
+ * class MockComponent extends generateMockComponent('hero.ts') {}
21
21
  * ```
22
22
  */
23
23
  export declare function generateMockComponent<T = Record<string, unknown>>(componentPath: string, config?: {
@@ -113,7 +113,7 @@ function getSelector(parentNode, source, isInDecorator = false, isInComponentCon
113
113
  * @param config.isControlValueAccessor
114
114
  * @example
115
115
  * ```typescript
116
- * // hero.component.ts
116
+ * // hero.ts
117
117
  * \@Component({selector: 'hero'})
118
118
  * class HeroComponent {
119
119
  * \@Input() name: string;
@@ -121,7 +121,7 @@ function getSelector(parentNode, source, isInDecorator = false, isInComponentCon
121
121
  * }
122
122
  *
123
123
  * // mock generation
124
- * class MockComponent extends generateMockComponent('hero.component.ts') {}
124
+ * class MockComponent extends generateMockComponent('hero.ts') {}
125
125
  * ```
126
126
  */
127
127
  function generateMockComponent(componentPath, config) {
@@ -1 +1 @@
1
- {"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;AAmIA,sDAyCC;AA5KD,wCAKuB;AACvB,0CAEwB;AACxB,iCAAiC;AAEjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,WAAoB,EAAE,SAAuB,EAAE,MAAqB;IACrF,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACvG,IAAI,eAAe,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,eAAe,CAAC,CAAC,CAA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iB;wBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;wBACnC,KAAK,EAAE,IAAI;qBACZ;iBACF;aACF;YACD,CAAC,CAAC,EAAE;KACP,CAAC,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC","sourcesContent":["import {\n Component,\n EventEmitter,\n forwardRef,\n Type,\n} from '@angular/core';\nimport {\n NG_VALUE_ACCESSOR,\n} from '@angular/forms';\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && node.getText(source).startsWith('@Input');\n}\n\n/**\n * Determine if the node in an output field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && node.getText(source).startsWith('@Output');\n}\n\n/**\n * Get the name of the input / output\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(input|output) *\\( *([\"'](.*)[\"'])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/[\"']/gi, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * ```typescript\n * // hero.component.ts\n * \\@Component({selector: 'hero'})\n * class HeroComponent {\n * \\@Input() name: string;\n * \\@Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.component.ts') {}\n * ```\n */\nexport function generateMockComponent<T = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => {};\n this.registerOnChange = () => {};\n this.registerOnTouched = () => {};\n }\n }\n };\n\n return Component({\n template: config?.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor)\n ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n }\n : {}\n })(mock) as Type<T>;\n}\n"]}
1
+ {"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;AAmIA,sDAyCC;AA5KD,wCAKuB;AACvB,0CAEwB;AACxB,iCAAiC;AAEjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,WAAoB,EAAE,SAAuB,EAAE,MAAqB;IACrF,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACvG,IAAI,eAAe,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,eAAe,CAAC,CAAC,C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AAiB;wBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;wBACnC,KAAK,EAAE,IAAI;qBACZ;iBACF;aACF;YACD,CAAC,CAAC,EAAE;KACP,CAAC,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC","sourcesContent":["import {\n Component,\n EventEmitter,\n forwardRef,\n Type,\n} from '@angular/core';\nimport {\n NG_VALUE_ACCESSOR,\n} from '@angular/forms';\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && node.getText(source).startsWith('@Input');\n}\n\n/**\n * Determine if the node in an output field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && node.getText(source).startsWith('@Output');\n}\n\n/**\n * Get the name of the input / output\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(input|output) *\\( *([\"'](.*)[\"'])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/[\"']/gi, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * ```typescript\n * // hero.ts\n * \\@Component({selector: 'hero'})\n * class HeroComponent {\n * \\@Input() name: string;\n * \\@Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.ts') {}\n * ```\n */\nexport function generateMockComponent<T = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => {};\n this.registerOnChange = () => {};\n this.registerOnTouched = () => {};\n }\n }\n };\n\n return Component({\n template: config?.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor)\n ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n }\n : {}\n })(mock) as Type<T>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/testing",
3
- "version": "14.0.0-next.0",
3
+ "version": "14.0.0-next.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,7 +11,6 @@
11
11
  "otter-module"
12
12
  ],
13
13
  "main": "public_api.js",
14
- "typings": "public_api.d.ts",
15
14
  "types": "public_api.d.ts",
16
15
  "sideEffects": false,
17
16
  "scripts": {
@@ -100,18 +99,19 @@
100
99
  "@material/slider": "^14.0.0",
101
100
  "@ngrx/store": "^20.0.0",
102
101
  "@ngx-translate/core": "^15.0.0 || ~16.0.4",
103
- "@o3r/core": "^14.0.0-next.0",
104
- "@o3r/localization": "^14.0.0-next.0",
105
- "@o3r/schematics": "^14.0.0-next.0",
102
+ "@o3r/core": "~14.0.0-next.10",
103
+ "@o3r/eslint-config": "~14.0.0-next.10",
104
+ "@o3r/localization": "~14.0.0-next.10",
105
+ "@o3r/schematics": "~14.0.0-next.10",
106
106
  "@playwright/test": "^1.49.0",
107
107
  "@schematics/angular": "^20.0.0",
108
+ "eslint": "~9.39.0",
108
109
  "pixelmatch": "^7.0.0",
109
110
  "pngjs": "^7.0.0",
110
111
  "rxjs": "^7.8.1",
111
112
  "temporal-polyfill": "^0.3.0",
112
- "ts-node": "~10.9.2",
113
- "type-fest": "^4.30.1",
114
- "typescript": "^5.8.0"
113
+ "type-fest": "^5.3.1",
114
+ "typescript": "^5.9.0"
115
115
  },
116
116
  "peerDependenciesMeta": {
117
117
  "@amadeus-it-group/kassette": {
@@ -141,6 +141,9 @@
141
141
  "@o3r/core": {
142
142
  "optional": true
143
143
  },
144
+ "@o3r/eslint-config": {
145
+ "optional": true
146
+ },
144
147
  "@o3r/localization": {
145
148
  "optional": true
146
149
  },
@@ -167,84 +170,90 @@
167
170
  }
168
171
  },
169
172
  "dependencies": {
170
- "@o3r/schematics": "^14.0.0-next.0",
173
+ "@o3r/schematics": "~14.0.0-next.10",
171
174
  "esbuild": "~0.25.1",
172
175
  "module-from-string": "^3.2.0",
173
176
  "tslib": "^2.6.2"
174
177
  },
175
178
  "devDependencies": {
176
179
  "@amadeus-it-group/kassette": "^1.7.0",
177
- "@angular-devkit/build-angular": "~20.2.0",
178
- "@angular-devkit/core": "~20.2.0",
179
- "@angular-devkit/schematics": "~20.2.0",
180
- "@angular/cli": "~20.2.0",
181
- "@angular/common": "~20.2.0",
182
- "@angular/compiler": "~20.2.0",
183
- "@angular/compiler-cli": "~20.2.0",
184
- "@angular/core": "~20.2.0",
185
- "@angular/forms": "~20.2.0",
186
- "@angular/platform-browser": "~20.2.0",
187
- "@angular/platform-browser-dynamic": "~20.2.0",
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",
188
191
  "@babel/core": "~7.28.0",
189
- "@babel/preset-typescript": "~7.27.0",
190
- "@compodoc/compodoc": "^1.1.19",
192
+ "@babel/preset-typescript": "~7.28.0",
193
+ "@compodoc/compodoc": "^1.1.32",
191
194
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
192
195
  "@material/slider": "^14.0.0",
193
- "@ngrx/store": "~20.0.0",
196
+ "@ngrx/store": "~20.1.0",
194
197
  "@ngx-translate/core": "~16.0.4",
195
- "@nx/eslint-plugin": "~21.5.0",
196
- "@nx/jest": "~21.5.0",
197
- "@o3r/build-helpers": "^14.0.0-next.0",
198
- "@o3r/core": "^14.0.0-next.0",
199
- "@o3r/eslint-plugin": "^14.0.0-next.0",
200
- "@o3r/localization": "^14.0.0-next.0",
201
- "@o3r/test-helpers": "^14.0.0-next.0",
202
- "@playwright/test": "~1.55.0",
203
- "@schematics/angular": "~20.2.0",
204
- "@stylistic/eslint-plugin": "~5.3.0",
205
- "@swc/helpers": "~0.5.0",
206
- "@types/jest": "~29.5.2",
207
- "@types/node": "^22.0.0",
198
+ "@nx/eslint-plugin": "~21.6.0",
199
+ "@nx/jest": "~21.6.0",
200
+ "@o3r/build-helpers": "~14.0.0-next.10",
201
+ "@o3r/core": "~14.0.0-next.10",
202
+ "@o3r/eslint-plugin": "~14.0.0-next.10",
203
+ "@o3r/localization": "~14.0.0-next.10",
204
+ "@o3r/test-helpers": "~14.0.0-next.10",
205
+ "@playwright/test": "~1.57.0",
206
+ "@schematics/angular": "~20.3.13",
207
+ "@stylistic/eslint-plugin": "~5.6.0",
208
+ "@swc/helpers": "~0.5.17",
209
+ "@types/jest": "~30.0.0",
210
+ "@types/node": "~24.10.0",
208
211
  "@types/pixelmatch": "^5.2.3",
209
212
  "@types/pngjs": "^6.0.0",
210
- "@typescript-eslint/parser": "~8.43.0",
211
- "angular-eslint": "~20.2.0",
213
+ "@typescript-eslint/parser": "~8.51.0",
214
+ "angular-eslint": "~20.6.0",
212
215
  "concurrently": "^9.1.0",
213
216
  "cpy-cli": "^6.0.0",
214
- "eslint": "~9.35.0",
217
+ "eslint": "~9.39.0",
215
218
  "eslint-import-resolver-node": "~0.3.9",
216
219
  "eslint-import-resolver-typescript": "~4.4.0",
217
220
  "eslint-plugin-import": "~2.32.0",
218
221
  "eslint-plugin-import-newlines": "~1.4.0",
219
- "eslint-plugin-jest": "~29.0.0",
220
- "eslint-plugin-jsdoc": "~54.7.0",
222
+ "eslint-plugin-jest": "~29.11.0",
223
+ "eslint-plugin-jsdoc": "~61.5.0",
221
224
  "eslint-plugin-prefer-arrow": "~1.2.3",
222
- "eslint-plugin-unicorn": "~60.0.0",
223
- "eslint-plugin-unused-imports": "~4.2.0",
225
+ "eslint-plugin-unicorn": "~62.0.0",
226
+ "eslint-plugin-unused-imports": "~4.3.0",
224
227
  "globals": "^16.0.0",
225
228
  "isomorphic-fetch": "~3.0.0",
226
- "jest": "~29.7.0",
227
- "jest-environment-jsdom": "~29.7.0",
229
+ "jest": "~30.2.0",
230
+ "jest-environment-jsdom": "~30.2.0",
228
231
  "jest-junit": "~16.0.0",
229
- "jest-preset-angular": "~14.6.0",
230
- "jest-util": "~29.7.0",
232
+ "jest-preset-angular": "~16.0.0",
233
+ "jest-util": "~30.2.0",
234
+ "jsdom": "^26.1.0",
231
235
  "jsonc-eslint-parser": "~2.4.0",
232
- "nx": "~21.5.0",
233
- "pid-from-port": "^1.1.3",
236
+ "nx": "~21.6.0",
234
237
  "pixelmatch": "^7.0.0",
235
238
  "pngjs": "^7.0.0",
236
239
  "rxjs": "^7.8.1",
237
240
  "semver": "^7.5.2",
238
241
  "temporal-polyfill": "^0.3.0",
239
242
  "ts-jest": "~29.4.0",
240
- "ts-node": "~10.9.2",
241
- "type-fest": "^4.30.1",
243
+ "type-fest": "^5.3.1",
242
244
  "typescript": "~5.9.2",
243
- "typescript-eslint": "~8.43.0",
245
+ "typescript-eslint": "~8.51.0",
244
246
  "zone.js": "~0.15.0"
245
247
  },
246
248
  "generatorDependencies": {
247
- "@angular-builders/jest": "~20.0.0"
249
+ "@angular-builders/jest": "~20.0.0",
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"
248
257
  },
249
258
  "schematics": "./collection.json",
250
259
  "ng-update": {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":"AAKA,OAAO,EASL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAepC,OAAO,KAAK,EACV,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAWlB;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,CAkG1E;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,wBAAuC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":"AAKA,OAAO,EASL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAiBpC,OAAO,KAAK,EACV,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAWlB;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,CAmG1E;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,wBAAuC,CAAC"}
@@ -9,7 +9,7 @@ const change_1 = require("@schematics/angular/utility/change");
9
9
  const ts = require("typescript");
10
10
  const checkFixture = (componentPath, tree, baseFileName) => {
11
11
  const files = [
12
- node_path_1.posix.join((0, node_path_1.dirname)(componentPath), `${baseFileName}.fixture.ts`)
12
+ node_path_1.posix.join((0, node_path_1.dirname)(componentPath), `${baseFileName}-fixture.ts`)
13
13
  ];
14
14
  if (files.some((file) => tree.exists(file))) {
15
15
  throw new schematics_2.O3rCliError(`Unable to add fixture to this component because it already has at least one of these files: ${files.join(', ')}.`);
@@ -22,12 +22,13 @@ const checkFixture = (componentPath, tree, baseFileName) => {
22
22
  function ngAddFixtureFn(options) {
23
23
  return async (tree, context) => {
24
24
  try {
25
- const baseFileName = (0, node_path_1.basename)(options.path, '.component.ts');
25
+ const baseFileName = (0, schematics_2.getComponentBaseFileName)(options.path);
26
26
  const { name } = (0, schematics_2.getO3rComponentInfoOrThrowIfNotFound)(tree, options.path);
27
27
  checkFixture(options.path, tree, baseFileName);
28
28
  const properties = {
29
29
  ...options,
30
- componentFixture: name.concat('Fixture'),
30
+ componentFixture: (0, schematics_2.getComponentFixtureName)(baseFileName),
31
+ componentName: name,
31
32
  name: baseFileName
32
33
  };
33
34
  const createFixtureFilesRule = (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates'), [
@@ -35,7 +36,7 @@ function ngAddFixtureFn(options) {
35
36
  (0, schematics_1.renameTemplateFiles)(),
36
37
  (0, schematics_1.move)((0, node_path_1.dirname)(options.path))
37
38
  ]), schematics_1.MergeStrategy.Overwrite);
38
- const specFilePath = options.specFilePath || node_path_1.posix.join((0, node_path_1.dirname)(options.path), `${baseFileName}.spec.ts`);
39
+ const specFilePath = options.specFilePath || node_path_1.posix.join((0, node_path_1.dirname)(options.path), `${(0, node_path_1.basename)(options.path, '.ts')}.spec.ts`);
39
40
  const updateSpecRule = (0, schematics_1.chain)([
40
41
  (0, schematics_2.addImportsRule)(specFilePath, [
41
42
  {
@@ -43,7 +44,7 @@ function ngAddFixtureFn(options) {
43
44
  importNames: ['O3rElement']
44
45
  },
45
46
  {
46
- from: `./${baseFileName}.fixture`,
47
+ from: `./${baseFileName}-fixture`,
47
48
  importNames: [`${properties.componentFixture}Component`]
48
49
  }
49
50
  ]),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":";;;AAmDA,wCAkGC;AArJD,yCAImB;AACnB,2DAcoC;AACpC,gDAQyB;AACzB,+DAG4C;AAC5C,iCAAiC;AAKjC,MAAM,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AAG,IAAA,iCAAoB,EAAC,cAAc,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
2
  /**
3
3
  * Add fixture configuration
4
- * @param options @see RuleFactory.options
4
+ * @param options {@link RuleFactory.options}
5
5
  * @param options.projectName
6
6
  * @param options.testingFramework
7
7
  */
@@ -6,7 +6,7 @@ const schematics_2 = require("@o3r/schematics");
6
6
  const ts = require("typescript");
7
7
  /**
8
8
  * Add fixture configuration
9
- * @param options @see RuleFactory.options
9
+ * @param options {@link RuleFactory.options}
10
10
  * @param options.projectName
11
11
  * @param options.testingFramework
12
12
  */
@@ -49,7 +49,7 @@ function updateFixtureConfig(options) {
49
49
  tsconfigCompilerOptions.esModuleInterop = true;
50
50
  tsconfigCompilerOptions.outDir = 'test';
51
51
  tsconfigFile.include ||= [];
52
- tsconfigFile.include.concat(['**/fixture/', '**/*.fixture.ts', '**/fixtures.ts']);
52
+ tsconfigFile.include.concat(['**/fixture/', '**/*.fixture.ts', '**/*-fixture.ts', '**/fixtures.ts']);
53
53
  tree.overwrite(tsconfigPath, JSON.stringify(tsconfigFile, null, 2));
54
54
  }
55
55
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":";;AAqBA,kDAuFC;AA5GD,2DAKoC;AACpC,gDAGyB;AAIzB,iCAAiC;AAEjC;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAAkG;IACpI,MAAM,QAAQ,GAAG,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;IAClE;;;;OAIG;IACH,MAAM,kBAAkB,GAAS,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QACzE,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CA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,eAAO,MAAM,KAAK,wBAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAyIpC;;;GAGG;AACH,eAAO,MAAM,KAAK,wBAAgC,CAAC"}
@@ -7,6 +7,7 @@ const prompt_1 = require("@angular/cli/src/utilities/prompt");
7
7
  const schematics_1 = require("@angular-devkit/schematics");
8
8
  const schematics_2 = require("@o3r/schematics");
9
9
  const fixture_1 = require("./fixture");
10
+ const jest_1 = require("./jest");
10
11
  const playwright_1 = require("./playwright");
11
12
  /**
12
13
  * List of external dependencies to be added to the project as peer dependencies
@@ -32,9 +33,16 @@ function ngAddFn(options) {
32
33
  const testPackageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
33
34
  const packageJson = JSON.parse(fs.readFileSync(testPackageJsonPath, { encoding: 'utf8' }));
34
35
  const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
35
- const workingDirectory = workspaceProject?.root || '.';
36
36
  const projectType = workspaceProject?.projectType || 'application';
37
37
  let installJest;
38
+ let isEslintInstalled;
39
+ try {
40
+ require.resolve('@o3r/eslint-config');
41
+ isEslintInstalled = true;
42
+ }
43
+ catch {
44
+ isEslintInstalled = false;
45
+ }
38
46
  const testFramework = options.testingFramework || (0, schematics_2.getTestFramework)((0, schematics_2.getWorkspaceConfig)(tree), context);
39
47
  switch (testFramework) {
40
48
  case 'jest': {
@@ -67,7 +75,12 @@ function ngAddFn(options) {
67
75
  (0, fixture_1.updateFixtureConfig)(options),
68
76
  (0, schematics_2.removePackages)(['@otter/testing']),
69
77
  (0, schematics_2.addVsCodeRecommendations)(['Orta.vscode-jest']),
70
- installPlaywright ? (0, playwright_1.updatePlaywright)(options) : schematics_1.noop,
78
+ ...installPlaywright
79
+ ? [
80
+ (0, playwright_1.updatePlaywright)(options)
81
+ ]
82
+ : [],
83
+ ...installJest ? [(0, jest_1.setupJest)(options)] : [],
71
84
  (0, schematics_2.registerPackageCollectionSchematics)(packageJson),
72
85
  (0, schematics_2.setupSchematicsParamsForProject)({
73
86
  '@o3r/core:component': schematicsDefaultOptions,
@@ -76,63 +89,10 @@ function ngAddFn(options) {
76
89
  }, options.projectName),
77
90
  (0, schematics_2.ngAddDependenciesRule)(options, testPackageJsonPath, {
78
91
  dependenciesToInstall,
79
- devDependenciesToInstall: devDependenciesToInstall.concat(installJest
80
- ? [
81
- '@angular-builders/jest',
82
- '@types/jest',
83
- 'jest',
84
- 'jest-environment-jsdom',
85
- 'jest-preset-angular',
86
- 'jest-util',
87
- 'ts-jest'
88
- ]
89
- : [], installPlaywright
90
- ? [
91
- '@playwright/test',
92
- 'rimraf'
93
- ]
94
- : [])
92
+ devDependenciesToInstall: devDependenciesToInstall.concat(installJest ? (0, jest_1.jestDependencies)(isEslintInstalled) : [], installPlaywright ? playwright_1.playwrightDependencies : [])
95
93
  }),
96
94
  options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEditorConfig)()
97
95
  ];
98
- if (installJest) {
99
- if (workingDirectory === undefined) {
100
- throw new schematics_2.O3rCliError(`Could not find working directory for project ${options.projectName || ''}`);
101
- }
102
- else {
103
- if (workspaceProject) {
104
- const packageJsonFile = tree.readJson(`${workingDirectory}/package.json`);
105
- packageJsonFile.scripts ||= {};
106
- packageJsonFile.scripts.test = 'jest';
107
- tree.overwrite(`${workingDirectory}/package.json`, JSON.stringify(packageJsonFile, null, 2));
108
- const rootRelativePath = path.posix.relative(workingDirectory, tree.root.path.replace(/^\//, './'));
109
- const jestConfigFilesForProject = () => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates/project'), [
110
- (0, schematics_1.template)({
111
- ...options,
112
- rootRelativePath,
113
- isAngularSetup: tree.exists('/angular.json')
114
- }),
115
- (0, schematics_1.move)(workingDirectory),
116
- (0, schematics_1.renameTemplateFiles)()
117
- ]), schematics_1.MergeStrategy.Overwrite);
118
- rules.push(jestConfigFilesForProject);
119
- }
120
- if (tree.exists('/jest.config.js')) {
121
- context.logger.info('Jest configuration files already exist at the root of the project.');
122
- }
123
- else {
124
- const jestConfigFilesForWorkspace = () => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates/workspace'), [
125
- (0, schematics_1.template)({
126
- ...options,
127
- tsconfigPath: `./${['tsconfig.base.json', 'tsconfig.json'].find((tsconfigBase) => tree.exists(`./${tsconfigBase}`))}`
128
- }),
129
- (0, schematics_1.move)(tree.root.path),
130
- (0, schematics_1.renameTemplateFiles)()
131
- ]), schematics_1.MergeStrategy.Default);
132
- rules.push(jestConfigFilesForWorkspace);
133
- }
134
- }
135
- }
136
96
  return () => (0, schematics_1.chain)(rules)(tree, context);
137
97
  }
138
98
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,8DAE2C;AAC3C,2DAaoC;AACpC,gDAWyB;AAOzB,uCAEmB;AACnB,6CAEsB;AACtB;;GAEG;AACH,MAAM,qBAAqB,GAAa,EAAE,CAAC;AAE3C;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,YAAY;IACZ,OAAO;IACP,+BAA+B;IAC/B,eAAe;IACf,iBAAiB;CAClB,CAAC;AAEF;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA8B;IAC7C,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,IAAI,CAAC;YACH,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;YAChF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,MAAM,E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wBAAwB,EAAE,wBAAwB,CAAC,MAAM,CACvD,WAAW,CAAC,CAAC,CAAC,IAAA,uBAAgB,EAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,EACtD,iBAAiB,CAAC,CAAC,CAAC,mCAAsB,CAAC,CAAC,CAAC,EAAE,CAChD;iBACF,CACF;gBACD,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,8BAAiB,GAAE;aAClD,CAAC;YACF,OAAO,GAAG,EAAE,CAAC,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;;+GAEoF,CAAC,CAAC;YAC3G,MAAM,IAAI,wBAAW,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACU,QAAA,KAAK,GAAG,IAAA,iCAAoB,EAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import type { NgAddSchematicsSchema } from '../../../schematics/ng-add/schema';
3
+ /**
4
+ * List of dependencies needed to run jest
5
+ * @param eslintDependencies
6
+ */
7
+ export declare const jestDependencies: (eslintDependencies: boolean) => string[];
8
+ /**
9
+ * Setup jest as recommended
10
+ * @param options
11
+ */
12
+ export declare function setupJest(options: NgAddSchematicsSchema): Rule;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,oBAAoB,OAAO,aAS3D,CAAC;AAeF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAqC9D"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jestDependencies = void 0;
4
+ exports.setupJest = setupJest;
5
+ const path = require("node:path");
6
+ const schematics_1 = require("@angular-devkit/schematics");
7
+ const schematics_2 = require("@o3r/schematics");
8
+ /**
9
+ * List of dependencies needed to run jest
10
+ * @param eslintDependencies
11
+ */
12
+ const jestDependencies = (eslintDependencies) => [
13
+ '@angular-builders/jest',
14
+ '@types/jest',
15
+ 'jest',
16
+ 'jest-environment-jsdom',
17
+ 'jest-preset-angular',
18
+ 'jest-util',
19
+ 'ts-jest',
20
+ ...eslintDependencies ? ['eslint-plugin-jest'] : []
21
+ ];
22
+ exports.jestDependencies = jestDependencies;
23
+ /**
24
+ * Run jest on 'npm/yarn run test'
25
+ * @param workingDirectory
26
+ */
27
+ function setupJestScript(workingDirectory) {
28
+ return (tree) => {
29
+ const packageJsonFile = tree.readJson(`${workingDirectory}/package.json`);
30
+ packageJsonFile.scripts ||= {};
31
+ packageJsonFile.scripts.test = 'jest';
32
+ tree.overwrite(`${workingDirectory}/package.json`, JSON.stringify(packageJsonFile, null, 2));
33
+ };
34
+ }
35
+ /**
36
+ * Setup jest as recommended
37
+ * @param options
38
+ */
39
+ function setupJest(options) {
40
+ return (tree, context) => {
41
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
42
+ const workingDirectory = workspaceProject?.root || '.';
43
+ if (workingDirectory === undefined) {
44
+ throw new schematics_2.O3rCliError(`Could not find working directory for project ${options.projectName || ''}`);
45
+ }
46
+ const rootRelativePath = path.posix.relative(workingDirectory, tree.root.path.replace(/^\//, './'));
47
+ const setupJestInProject = (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./jest/templates/project'), [
48
+ (0, schematics_1.template)({
49
+ ...options,
50
+ rootRelativePath,
51
+ isAngularSetup: tree.exists('/angular.json')
52
+ }),
53
+ (0, schematics_1.move)(workingDirectory),
54
+ (0, schematics_1.renameTemplateFiles)()
55
+ ]), schematics_1.MergeStrategy.Overwrite);
56
+ const rules = [
57
+ setupJestScript(workingDirectory),
58
+ setupJestInProject
59
+ ];
60
+ if (tree.exists('/jest.config.js')) {
61
+ context.logger.info('Jest configuration files already exist at the root of the project.');
62
+ }
63
+ else {
64
+ rules.push((0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./jest/templates/workspace'), [
65
+ (0, schematics_1.template)({
66
+ ...options,
67
+ tsconfigPath: `./${['tsconfig.base.json', 'tsconfig.json'].find((tsconfigBase) => tree.exists(`./${tsconfigBase}`))}`
68
+ }),
69
+ (0, schematics_1.move)(tree.root.path),
70
+ (0, schematics_1.renameTemplateFiles)()
71
+ ]), schematics_1.MergeStrategy.Default));
72
+ }
73
+ return (0, schematics_1.chain)(rules)(tree, context);
74
+ };
75
+ }
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":";;;AAyDA,8BAqCC;AA9FD,kCAAkC;AAClC,2DAYoC;AACpC,gDAGyB;AAQzB;;;GAGG;AACI,MAAM,gBAAgB,GAAG,CAAC,kBAA2B,EAAE,EAAE,CAAC;IAC/D,wBAAwB;IACxB,aAAa;IACb,MAAM;IACN,wBAAwB;IACxB,qBAAqB;IACrB,WAAW;IACX,SAAS;IACT,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE;CACpD,CAAC;AATW,QAAA,gBAAgB,oBAS3B;AAEF;;;GAGG;AACH,SAAS,eAAe,CAAC,gBAAwB;IAC/C,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB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gB,CAAC;YACtB,IAAA,gCAAmB,GAAE;SACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC;QAE7B,MAAM,KAAK,GAAG;YACZ,eAAe,CAAC,gBAAgB,CAAC;YACjC,kBAAkB;SACnB,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAS,EAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,4BAA4B,CAAC,EAAE;gBAC5D,IAAA,qBAAQ,EAAC;oBACP,GAAG,OAAO;oBACV,YAAY,EAAE,KAAK,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC,EAAE;iBACtH,CAAC;gBACF,IAAA,iBAAI,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBACpB,IAAA,gCAAmB,GAAE;aACtB,CAAC,EAAE,0BAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC"}
@@ -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
 
@@ -1,8 +1,12 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
2
  import { NgAddPackageOptions } from '@o3r/schematics';
3
+ /**
4
+ * List of dependencies required by playwright
5
+ */
6
+ export declare const playwrightDependencies: string[];
3
7
  /**
4
8
  * Add Playwright to Otter application
5
- * @param options @see RuleFactory.options
9
+ * @param options {@link RuleFactory.options}
6
10
  */
7
11
  export declare function updatePlaywright(options: NgAddPackageOptions): Rule;
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/playwright/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,IAAI,EAKL,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAKzB;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAkDnE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/playwright/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,IAAI,EAKL,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAKzB;;GAEG;AACH,eAAO,MAAM,sBAAsB,UAIlC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAkDnE"}
@@ -1,13 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.playwrightDependencies = void 0;
3
4
  exports.updatePlaywright = updatePlaywright;
4
5
  const path = require("node:path");
5
6
  const core_1 = require("@angular-devkit/core");
6
7
  const schematics_1 = require("@angular-devkit/schematics");
7
8
  const schematics_2 = require("@o3r/schematics");
9
+ /**
10
+ * List of dependencies required by playwright
11
+ */
12
+ exports.playwrightDependencies = [
13
+ '@playwright/test',
14
+ '@types/node',
15
+ 'rimraf'
16
+ ];
8
17
  /**
9
18
  * Add Playwright to Otter application
10
- * @param options @see RuleFactory.options
19
+ * @param options {@link RuleFactory.options}
11
20
  */
12
21
  function updatePlaywright(options) {
13
22
  return (tree, context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/playwright/index.ts"],"names":[],"mappings":";;AA6BA,4CAkDC;AA/ED,kCAAkC;AAClC,+CAE8B;AAC9B,2DAWoC;AACpC,gDAIyB;AAKzB;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,OAA4B;IAC3D,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,WAAW,IAAI,IAAA,+BAAkB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC;QAExH,mBAAmB;QACnB,MAAM,aAAa,GAAG,YAAY,CAAC;QACnC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,IAAI,SAAS,GAAG,IAAI,CAAC,QAAQ,CA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C,wBAAwB,CAAC,EAAE;gBAC1D,IAAA,qBAAQ,EAAC;oBACP,GAAG,cAAO;oBACV,UAAU;oBACV,YAAY;iBACb,CAAC;gBACF,IAAA,gCAAmB,GAAE;gBACrB,IAAA,iBAAI,EAAC,gBAAgB,CAAC;aACvB,CAAC,CAAC;YAEH,OAAO,IAAA,sBAAS,EAAC,cAAc,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/visual-test/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,SAAe,QAkB9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,YAGrC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,QAOzD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/visual-test/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,SAAe,QAkB9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,YAGrC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,QAGzD"}
@@ -42,11 +42,6 @@ function isVisualTestingEnabled() {
42
42
  */
43
43
  function toggleVisualTestingRender(enabled) {
44
44
  const visualTestingClass = 'visual-testing-render';
45
- if (enabled) {
46
- document.body.classList.add(visualTestingClass);
47
- }
48
- else {
49
- document.body.classList.remove(visualTestingClass);
50
- }
45
+ document.body.classList.toggle(visualTestingClass, enabled);
51
46
  }
52
47
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/visual-test/utils.ts"],"names":[],"mappings":";;AAOA,oDAkBC;AAKD,wDAGC;AAOD,8DAOC;AA/CD;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,WAAW,GAAG,YAAY;IAC7D,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,gBAAgB,CAAC,WAAW,GAAG;OAC1B,kBAAkB,KAAK,WAAW;;OAElC,kBAAkB,KAAK,WAAW;;;;;;;;;IASrC,CAAC;IAEH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,OAAgB;IACxD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,IAAI,OAAO,EAAE,CAAC;QACZ,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACrD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Prepare css rule to hide specific blocks\n *\n * Should be called only once during the visual test.\n * @note this function is evaluated in the context of the page and should not use external variables\n * @param ignoreClass\n */\nexport function prepareVisualTesting(ignoreClass = 'e2e-ignore') {\n const visualTestingCss = document.createElement('style');\n const visualTestingClass = 'visual-testing-render';\n visualTestingCss.textContent = `\n .${visualTestingClass} .${ignoreClass} {position: relative;}\n\n .${visualTestingClass} .${ignoreClass}:before {\n z-index: 999;\n content: '';\n width: 100%;\n height: 100%;\n background: grey;\n position: absolute;\n left: 0;\n top: 0;\n }`;\n\n document.head.append(visualTestingCss);\n}\n\n/**\n * Determine if the visual testing is enabled\n */\nexport function isVisualTestingEnabled() {\n const visualTestingClass = 'visual-testing-render';\n return document.body.classList.contains(visualTestingClass);\n}\n\n/**\n * Toggle the visual testing view : if it is active, will hide tagged components as grey blocks.\n * @note this function is evaluated in the context of the page and cannot use external code\n * @param enabled\n */\nexport function toggleVisualTestingRender(enabled: boolean) {\n const visualTestingClass = 'visual-testing-render';\n if (enabled) {\n document.body.classList.add(visualTestingClass);\n } else {\n document.body.classList.remove(visualTestingClass);\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/visual-test/utils.ts"],"names":[],"mappings":";;AAOA,oDAkBC;AAKD,wDAGC;AAOD,8DAGC;AA3CD;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,WAAW,GAAG,YAAY;IAC7D,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,gBAAgB,CAAC,WAAW,GAAG;OAC1B,kBAAkB,KAAK,WAAW;;OAElC,kBAAkB,KAAK,WAAW;;;;;;;;;IASrC,CAAC;IAEH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,OAAgB;IACxD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;IACnD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * Prepare css rule to hide specific blocks\n *\n * Should be called only once during the visual test.\n * @note this function is evaluated in the context of the page and should not use external variables\n * @param ignoreClass\n */\nexport function prepareVisualTesting(ignoreClass = 'e2e-ignore') {\n const visualTestingCss = document.createElement('style');\n const visualTestingClass = 'visual-testing-render';\n visualTestingCss.textContent = `\n .${visualTestingClass} .${ignoreClass} {position: relative;}\n\n .${visualTestingClass} .${ignoreClass}:before {\n z-index: 999;\n content: '';\n width: 100%;\n height: 100%;\n background: grey;\n position: absolute;\n left: 0;\n top: 0;\n }`;\n\n document.head.append(visualTestingCss);\n}\n\n/**\n * Determine if the visual testing is enabled\n */\nexport function isVisualTestingEnabled() {\n const visualTestingClass = 'visual-testing-render';\n return document.body.classList.contains(visualTestingClass);\n}\n\n/**\n * Toggle the visual testing view : if it is active, will hide tagged components as grey blocks.\n * @note this function is evaluated in the context of the page and cannot use external code\n * @param enabled\n */\nexport function toggleVisualTestingRender(enabled: boolean) {\n const visualTestingClass = 'visual-testing-render';\n document.body.classList.toggle(visualTestingClass, enabled);\n}\n"]}