@o3r/testing 11.6.0-prerelease.9 → 12.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/core/playwright/angular-materials/autocomplete-material.js.map +1 -1
  2. package/core/playwright/angular-materials/select-material.js.map +1 -1
  3. package/core/playwright/component-fixture.js.map +1 -1
  4. package/kassette/update-dates-in-mocks.js.map +1 -1
  5. package/localization/localization-mock.js.map +1 -1
  6. package/package.json +32 -31
  7. package/schematics/add-functions-to-fixture/models.d.ts +18 -2
  8. package/schematics/add-functions-to-fixture/models.d.ts.map +1 -1
  9. package/schematics/add-functions-to-fixture/models.js.map +1 -1
  10. package/schematics/ng-update/v9-0/localization-imports/localization-imports-map.d.ts +16 -2
  11. package/schematics/ng-update/v9-0/localization-imports/localization-imports-map.d.ts.map +1 -1
  12. package/schematics/ng-update/v9-0/localization-imports/localization-imports-map.js.map +1 -1
  13. package/tools/protractor/fetch-manager/_fetch-manager.d.ts +1 -0
  14. package/tools/protractor/fetch-manager/_fetch-manager.d.ts.map +1 -0
  15. package/tools/protractor/fetch-manager/_fetch-manager.js +127 -0
  16. package/tools/protractor/fetch-manager/_fetch-manager.js.map +1 -0
  17. package/tools/protractor/post-message-interceptor/_post-message-interceptor.d.ts +5 -0
  18. package/tools/protractor/post-message-interceptor/_post-message-interceptor.d.ts.map +1 -0
  19. package/tools/protractor/post-message-interceptor/_post-message-interceptor.js +157 -0
  20. package/tools/protractor/post-message-interceptor/_post-message-interceptor.js.map +1 -0
  21. package/visual-test/visual-test.d.ts +1 -1
  22. package/visual-test/visual-test.d.ts.map +1 -1
  23. package/visual-test/visual-test.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/autocomplete-material.ts"],"names":[],"mappings":";;;;AAGA,sCAIoB;AAEpB;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,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C,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;wBAC9G,qBAAM,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAA;;wBAA5C,SAA4C,CAAC;wBAC7C,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;6BAGjD,sBAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC,EAAC;;;;KAC9F;IACH,sBAAC;AAAD,CAAC,AA5BD,CAAqC,oBAAU,GA4B9C;AA5BY,0CAAe","sourcesContent":["import {\n MatAutocompleteProfile,\n} from '../../angular-materials';\nimport {\n getPlainText,\n O3rElement,\n PlaywrightSourceElement,\n} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatAutocomplete extends O3rElement implements MatAutocompleteProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.setValue(value);\n await this.click();\n const element = this.sourceElement.page;\n const matOptions = element.locator('.mat-option, mat-option');\n await matOptions.first().waitFor({ state: 'attached', timeout });\n const matOptionsCount = await matOptions.count();\n const options: (string | undefined)[] = [];\n if (matOptionsCount > 1) {\n for (let i = 0; i < matOptionsCount; i++) {\n options.push(getPlainText(await matOptions.nth(i).innerText()));\n }\n throw new Error(`MatAutocomplete selectByValue works only for filtered autocomplete. Found multiple values: ${options.join(', ')}`);\n }\n if (matOptionsCount === 1) {\n const selectedOption: PlaywrightSourceElement = { element: matOptions.nth(0), page: this.sourceElement.page };\n await new O3rElement(selectedOption).click();\n return this.sourceElement.element.press('Tab');\n }\n\n return Promise.reject(new Error('Element with selector .mat-option, mat-option not found.'));\n }\n}\n"]}
1
+ {"version":3,"file":"autocomplete-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/autocomplete-material.ts"],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AArB,yBAAqB;wBACjB,cAAc,GAAG,EAAE,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAA6C,CAAC;wBAChI,qBAAM,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAA;;wBAA5C,SAA4C,CAAC;wBAC7C,sBAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;6BAGjD,sBAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC,EAAC;;;;KAC9F;IACH,sBAAC;AAAD,CAAC,AA5BD,CAAqC,oBAAU,GA4B9C;AA5BY,0CAAe","sourcesContent":["import {\n MatAutocompleteProfile,\n} from '../../angular-materials';\nimport {\n getPlainText,\n O3rElement,\n PlaywrightSourceElement,\n} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatAutocomplete extends O3rElement implements MatAutocompleteProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.setValue(value);\n await this.click();\n const element = this.sourceElement.page;\n const matOptions = element.locator('.mat-option, mat-option');\n await matOptions.first().waitFor({ state: 'attached', timeout });\n const matOptionsCount = await matOptions.count();\n const options: (string | undefined)[] = [];\n if (matOptionsCount > 1) {\n for (let i = 0; i < matOptionsCount; i++) {\n options.push(getPlainText(await matOptions.nth(i).innerText()));\n }\n throw new Error(`MatAutocomplete selectByValue works only for filtered autocomplete. Found multiple values: ${options.join(', ')}`);\n }\n if (matOptionsCount === 1) {\n const selectedOption = { element: matOptions.nth(0), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n await new O3rElement(selectedOption).click();\n return this.sourceElement.element.press('Tab');\n }\n\n return Promise.reject(new Error('Element with selector .mat-option, mat-option not found.'));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/select-material.ts"],"names":[],"mappings":";;;;AAGA,sCAGoB;AAEpB;;GAEG;AACH;IAA+B,qCAAU;IACvC,mBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,iCAAa,GAA1B;oEAA2B,KAAa,EAAE,OAAc;;YAAd,wBAAA,EAAA,cAAc;;;4BACtD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;wBAC9D,qBAAM,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAE,CAAC,EAAA;;wBAA7D,SAA6D,CAAC;wBACzD,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;wBAA1B,IAAI,CAAC,SAAqB,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;4BACnC,cAAc,GAA4B,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;4BACzG,MAAM,GAAG,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC;4BAC9C,sBAAO,MAAM,CAAC,KAAK,EAAE,EAAC;wBACxB,CAAC;6BAAM,CAAC;4BACN,sBAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAAqB,KAAK,kCAA+B,CAAC,CAAC,EAAC;wBAC9F,CAAC;;;;;KACF;IAED,kBAAkB;IACL,iCAAa,GAA1B;oEAA2B,KAAa,EAAE,OAAc;;YAAd,wBAAA,EAAA,cAAc;;;4BACtD,qBAAM,IAAI,CAAC,KAAK,EA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AAA,EAAE,CAAC,EAAA;;wBAA7D,SAA6D,CAAC;wBACzC,qBAAM,OAAO,CAAC,KAAK,EAAE,EAAA;;wBAApC,YAAY,GAAG,SAAqB;wBACjC,CAAC,GAAG,CAAC;;;6BAAE,CAAA,CAAC,GAAG,YAAY,CAAA;wBACxB,cAAc,GAA4B,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;wBACrG,MAAM,GAAG,IAAI,oBAAU,CAAC,cAAc,CAAC,CAAC;wBAC1C,qBAAM,MAAM,CAAC,OAAO,EAAE,EAAA;;wBAA1B,IAAI,CAAA,SAAsB,MAAK,KAAK,EAAE,CAAC;4BACrC,sBAAO,MAAM,CAAC,KAAK,EAAE,EAAC;wBACxB,CAAC;;;wBAL+B,CAAC,EAAE,CAAA;;4BAQrC,sBAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAAqB,KAAK,kCAA+B,CAAC,CAAC,EAAC;;;;KAC7F;IAED,kBAAkB;IACX,4BAAQ,GAAf;QACE,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAChH,CAAC;IACH,gBAAC;AAAD,CAAC,AAxDD,CAA+B,oBAAU,GAwDxC;AAxDY,8BAAS","sourcesContent":["import {\n MatSelectProfile,\n} from '../../angular-materials';\nimport {\n O3rElement,\n PlaywrightSourceElement,\n} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatSelect extends O3rElement implements MatSelectProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByIndex(index: number, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n if ((await options.count()) >= index + 1) {\n const selectedOption: PlaywrightSourceElement = { element: options.nth(index), page: this.sourceElement.page };\n const option = new O3rElement(selectedOption);\n return option.click();\n } else {\n return Promise.reject(new Error(`Option with index ${index} not found in select element.`));\n }\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n const optionsCount = await options.count();\n for (let i = 0; i < optionsCount; i++) {\n const selectedOption: PlaywrightSourceElement = { element: options.nth(i), page: this.sourceElement.page };\n const option = new O3rElement(selectedOption);\n if (await option.getAttribute('ng-reflect-value') === value) {\n return option.click();\n }\n }\n return Promise.reject(new Error(`Option with value ${value} not found in select element.`));\n }\n\n /** @inheritdoc */\n public async selectByLabel(label: string, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n const optionsCount = await options.count();\n for (let i = 0; i < optionsCount; i++) {\n const selectedOption: PlaywrightSourceElement = { element: options.nth(i), page: this.sourceElement.page };\n const option = new O3rElement(selectedOption);\n if (await option.getText() === label) {\n return option.click();\n }\n }\n\n return Promise.reject(new Error(`Option with label ${label} not found in select element.`));\n }\n\n /** @inheritDoc */\n public getValue(): Promise<string | undefined> {\n throw new Error('Cannot use \"getValue\" function on a Material Select element. Use \"getPlainText()\" instead.');\n }\n}\n"]}
1
+ {"version":3,"file":"select-material.js","sourceRoot":"","sources":["../../../../src/core/playwright/angular-materials/select-material.ts"],"names":[],"mappings":";;;;AAGA,sCAGoB;AAEpB;;GAEG;AACH;IAA+B,qCAAU;IACvC,mBAAY,aAAmD;QAC7D,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,iCAAa,GAA1B;oEAA2B,KAAa,EAAE,OAAc;;YAAd,wBAAA,EAAA,cAAc;;;4BACtD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,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AAK,EAAE,CAAC;4BACrC,sBAAO,MAAM,CAAC,KAAK,EAAE,EAAC;wBACxB,CAAC;;;wBAL+B,CAAC,EAAE,CAAA;;4BAQrC,sBAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAAqB,KAAK,kCAA+B,CAAC,CAAC,EAAC;;;;KAC7F;IAED,kBAAkB;IACX,4BAAQ,GAAf;QACE,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;IAChH,CAAC;IACH,gBAAC;AAAD,CAAC,AAxDD,CAA+B,oBAAU,GAwDxC;AAxDY,8BAAS","sourcesContent":["import {\n MatSelectProfile,\n} from '../../angular-materials';\nimport {\n O3rElement,\n PlaywrightSourceElement,\n} from '../element';\n\n/**\n * Implementation dedicated to Playwright.\n */\nexport class MatSelect extends O3rElement implements MatSelectProfile {\n constructor(sourceElement: PlaywrightSourceElement | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByIndex(index: number, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n if ((await options.count()) >= index + 1) {\n const selectedOption = { element: options.nth(index), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n const option = new O3rElement(selectedOption);\n return option.click();\n } else {\n return Promise.reject(new Error(`Option with index ${index} not found in select element.`));\n }\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n const optionsCount = await options.count();\n for (let i = 0; i < optionsCount; i++) {\n const selectedOption = { element: options.nth(i), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n const option = new O3rElement(selectedOption);\n if (await option.getAttribute('ng-reflect-value') === value) {\n return option.click();\n }\n }\n return Promise.reject(new Error(`Option with value ${value} not found in select element.`));\n }\n\n /** @inheritdoc */\n public async selectByLabel(label: string, timeout = 5000) {\n await this.click();\n const options = this.sourceElement.page.locator('mat-option');\n await options.first().waitFor({ state: 'attached', timeout });\n const optionsCount = await options.count();\n for (let i = 0; i < optionsCount; i++) {\n const selectedOption = { element: options.nth(i), page: this.sourceElement.page } as const satisfies PlaywrightSourceElement;\n const option = new O3rElement(selectedOption);\n if (await option.getText() === label) {\n return option.click();\n }\n }\n\n return Promise.reject(new Error(`Option with label ${label} not found in select element.`));\n }\n\n /** @inheritDoc */\n public getValue(): Promise<string | undefined> {\n throw new Error('Cannot use \"getValue\" function on a Material Select element. Use \"getPlainText()\" instead.');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/playwright/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4CAE4B;AAI5B,sCAEoB;AACpB,qCAImB;AAQnB;;GAEG;AACH;IAME;;;;OAIG;IACH,6BAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,qDAAuB,GAAvC,UAA8D,OAAW,EAAE,OAAgB;;;;;wBACzF,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBACnE,CAAC;wBACD,qBAAM,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAE,CAAC,EAAA;;wBAAnF,SAAmF,CAAC;wBACpF,sBAAO,OAAO,EAAC;;;;KAChB;IAED;;;;;OAKG;IACO,8CAAgB,GAA1B,UAAiD,OAAmB,EAAE,OAAgB;QAAtF,iBAQC;QAPC,OAAO,IAAA,qBAAW,EAChB,CAAC;;;;4BACY,qBAAM,OAAO,EAAA;;wBAAlB,EAAE,GAAG,SAAa;wBACxB,qBAAM,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,K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GAAG,IAAI,SAAS,CAAC,QAAe,CAAC,CAAC;wBAC7B,qBAAM,KAAK,CAAC,YAAY,EAAE,EAAA;;wBAApC,OAAO,GAAG,SAA0B;wBAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;wBACxD,CAAC;wBACD,sBAAO,KAAK,EAAC;4BAGf,sBAAO,QAAQ,EAAC;;;wBAEhB,mEAAmE;wBACnE,OAAO,CAAC,IAAI,CAAC,8BAAuB,QAAQ,CAAE,EAAE,KAAG,CAAC,CAAC;wBACrD,sBAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAC;;;;;KAE9B;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB;IACX,6CAAe,GAAtB,UAAuB,QAAgB;QACrC,IAAM,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;IACH,0BAAC;AAAD,CAAC,AA9MD,IA8MC;AA9MY,kDAAmB","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: PlaywrightSourceElement = { element: element, page: this.rootElement.sourceElement.page };\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n }\n\n /** @inheritdoc */\n public queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T>;\n public queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement> {\n const elements = this.rootElement.sourceElement.element.locator(selector);\n const element = elements.nth(index);\n const selectedElement: PlaywrightSourceElement = { element: element, page: this.rootElement.sourceElement.page };\n return Promise.resolve(new (returnType || O3rElement)(selectedElement));\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n timeout = 5000\n ): Promise<(T | O3rElement)[] | K> {\n try {\n const sourceElement = this.rootElement.sourceElement.element;\n const pElements = sourceElement.locator(selector);\n // Mandatory because count is not reliable if we don't wait for the list to be attached\n await pElements.first().waitFor({ state: 'attached', timeout });\n const pElementsCount = await pElements.count();\n const elements = [];\n for (let i = 0; i < pElementsCount; i++) {\n const selectedElement: PlaywrightSourceElement = { element: pElements.nth(i), page: this.rootElement.sourceElement.page };\n elements.push(returnType ? new returnType(selectedElement) : new O3rElement(selectedElement));\n }\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return group;\n }\n\n return elements;\n } catch (err) {\n // 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,4CAE4B;AAI5B,sCAEoB;AACpB,qCAImB;AAQnB;;GAEG;AACH;IAME;;;;OAIG;IACH,6BAAY,WAAc;QACxB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,qDAAuB,GAAvC,UAA8D,OAAW,EAAE,OAAgB;;;;;wBACzF,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBACnE,CAAC;wBACD,qBAAM,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,SAAA,EAAE,CAAC,EAAA;;wBAAnF,SAAmF,CAAC;wBACpF,sBAAO,OAAO,EAAC;;;;KAChB;IAED;;;;;OAKG;IACO,8CAAgB,GAA1B,UAAiD,OAAmB,EAAE,OAAgB;QAAtF,iBAQC;QAPC,OAAO,IAAA,qBAAW,EAChB,CAAC;;;;4BACY,qBAAM,OAAO,EA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U,CAAC,eAAe,CAAC,CAAC,CAAC;wBAChG,CAAC;6BACG,SAAS,EAAT,wBAAS;wBACL,KAAK,GAAG,IAAI,SAAS,CAAC,QAAe,CAAC,CAAC;wBAC7B,qBAAM,KAAK,CAAC,YAAY,EAAE,EAAA;;wBAApC,OAAO,GAAG,SAA0B;wBAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;wBACxD,CAAC;wBACD,sBAAO,KAAK,EAAC;4BAGf,sBAAO,QAAQ,EAAC;;;wBAEhB,mEAAmE;wBACnE,OAAO,CAAC,IAAI,CAAC,8BAAuB,QAAQ,CAAE,EAAE,KAAG,CAAC,CAAC;wBACrD,sBAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAC;;;;;KAE9B;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB;IACX,6CAAe,GAAtB,UAAuB,QAAgB;QACrC,IAAM,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;IACH,0BAAC;AAAD,CAAC,AA9MD,IA8MC;AA9MY,kDAAmB","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 +1 @@
1
- {"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;AA2CA,gDAsEC;;AA9GD,uDAE2B;AAiC3B;;;;GAIG;AACH,SAAsB,kBAAkB;gEAAC,IAAW,EAAE,YAAqD;;;QAArD,6BAAA,EAAA,iBAAqD;;;;oBACnG,eAAe,GAAG,qBAAqB,CAAC,MAAM,CAAC;oBAC/C,OAAO,sBACX,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,6BAA6B,EACxC,SAAS,EAAE;4BACT,QAAQ,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,EAA7C,CAA6C;4BACjE,MAAM,EAAE,UAAC,KAAK;gCACZ,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gCAC1D,OAAO,KAAK,CAAC,MAAM,GAAG,eAAe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AAC;oBACH,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;oBAC7C,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;oBAAzB,SAAyB,CAAC;;;;;;CAIjC","sourcesContent":["import type {\n IMock,\n} from '@amadeus-it-group/kassette';\nimport {\n Temporal,\n} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options: UpdateDatesInMocksOptions = {\n mode: 'day-offset',\n extractor: /\\b(\\d{4}-\\d{2}-\\d{2})[^\"]*/g,\n converter: {\n fromDate: (date) => date.toString().substring(0, plainDateLength),\n toDate: (input) => {\n input = input.replace(/\\.\\d+/, '').replace(/Z/, '+00:00');\n return input.length > plainDateLength\n ? Temporal.ZonedDateTime.from(`${input.replace(/(\\.\\d+)/, '')}[${input.replace(/^.*(\\+\\d{2}:\\d{2}).*$/, '$1') || '+00:00'}]`)\n : Temporal.PlainDate.from(input);\n }\n },\n ...inputOptions\n };\n const todayTime = Temporal.Now.plainDateISO();\n\n // Update request\n const replaceDatesInInput = (input: string): string => {\n switch (options.mode) {\n case 'any': {\n return input.replace(options.extractor, '<any>');\n }\n case 'day-offset': {\n return input.replace(options.extractor, (match) => `<t+${Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);\n }\n case 'same-day-of-week': {\n return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);\n }\n }\n return input;\n };\n const checksum = await mock.checksum({\n headers: false,\n body: { filter: (body) => replaceDatesInInput(body.toString()) },\n query: { filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)])) },\n customData: { updateDatesMode: options.mode }\n });\n mock.setLocalPath([mock.localPath, checksum]);\n\n // Update response\n if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {\n const localPayload = (await mock.readLocalPayload())?.payload;\n if (localPayload && localPayload.data.creationDateTime) {\n const referenceTime = Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));\n const timeOffset = Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });\n if (timeOffset.days !== 0) {\n mock.setMode('manual');\n const replaceDatesInOutput = (output: string): string => {\n switch (options.mode) {\n case 'any':\n case 'day-offset': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));\n }\n case 'same-day-of-week': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));\n }\n }\n return output;\n };\n const wrappedPayload = mock.createPayload({\n data: localPayload.data,\n body: replaceDatesInOutput(localPayload.body?.toString() || '')\n });\n mock.fillResponseFromPayload(wrappedPayload);\n await mock.sendResponse();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"update-dates-in-moc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AC,EAA3E,CAA2E,CAAC,CAAC;4BACnI,CAAC;4BACD,KAAK,kBAAkB,CAAC,CAAC,CAAC;gCACxB,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,UAAC,KAAK,IAAK,OAAA,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,CAAC,YAAU,CAAC,IAAI,GAAG,CAAC,CAAC,MAAG,CAAC,CAAC,EAAtG,CAAsG,CAAC,CAAC;4BAC9J,CAAC;wBACH,CAAC;wBACD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC;oBACI,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;wBACxC,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,IAAI,EAAE,oBAAoB,CAAC,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC;qBAChE,CAAC,CAAC;oBACH,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;oBAC7C,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;oBAAzB,SAAyB,CAAC;;;;;;CAIjC","sourcesContent":["import type {\n IMock,\n} from '@amadeus-it-group/kassette';\nimport {\n Temporal,\n} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options = {\n mode: 'day-offset',\n extractor: /\\b(\\d{4}-\\d{2}-\\d{2})[^\"]*/g,\n converter: {\n fromDate: (date) => date.toString().substring(0, plainDateLength),\n toDate: (input) => {\n input = input.replace(/\\.\\d+/, '').replace(/Z/, '+00:00');\n return input.length > plainDateLength\n ? Temporal.ZonedDateTime.from(`${input.replace(/(\\.\\d+)/, '')}[${input.replace(/^.*(\\+\\d{2}:\\d{2}).*$/, '$1') || '+00:00'}]`)\n : Temporal.PlainDate.from(input);\n }\n },\n ...inputOptions\n } as const satisfies UpdateDatesInMocksOptions;\n const todayTime = Temporal.Now.plainDateISO();\n\n // Update request\n const replaceDatesInInput = (input: string): string => {\n switch (options.mode) {\n case 'any': {\n return input.replace(options.extractor, '<any>');\n }\n case 'day-offset': {\n return input.replace(options.extractor, (match) => `<t+${Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);\n }\n case 'same-day-of-week': {\n return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);\n }\n }\n return input;\n };\n const checksum = await mock.checksum({\n headers: false,\n body: { filter: (body) => replaceDatesInInput(body.toString()) },\n query: { filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)])) },\n customData: { updateDatesMode: options.mode }\n });\n mock.setLocalPath([mock.localPath, checksum]);\n\n // Update response\n if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {\n const localPayload = (await mock.readLocalPayload())?.payload;\n if (localPayload && localPayload.data.creationDateTime) {\n const referenceTime = Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));\n const timeOffset = Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });\n if (timeOffset.days !== 0) {\n mock.setMode('manual');\n const replaceDatesInOutput = (output: string): string => {\n switch (options.mode) {\n case 'any':\n case 'day-offset': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));\n }\n case 'same-day-of-week': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));\n }\n }\n return output;\n };\n const wrappedPayload = mock.createPayload({\n data: localPayload.data,\n body: replaceDatesInOutput(localPayload.body?.toString() || '')\n });\n mock.fillResponseFromPayload(wrappedPayload);\n await mock.sendResponse();\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localization-mock.js","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":";;;AAsEA,wDAoBC;;AA1FD,sCAMuB;AACvB,4CAG6B;AAC7B,kDAI2B;AAC3B,6BAEc;AAEd,IAAM,gCAAgC,GAAuC;IAC3E,gBAAgB,EAAE,CAAC,IAAI,CAAC;IACxB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,EAAE;IACf,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAGF;IAAA;IAIA,CAAC;IAHQ,qCAAS,GAAhB;QAAiB,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QAC7B,OAAO,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAf,CAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,CA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A,EAAA,4DAAgG;IAChG,6BAAA,EAAA,iBAAmC;IAEnC,yBAAA,EAAA,gBAAgB;IAChB,+BAAA,EAAA,sBAAsB;IAEtB;QACE,iCAAkB,CAAC,OAAO,CAAC,cAAM,OAAA,yBAAyB,EAAzB,CAAyB,CAAC;QAC3D,sBAAe,CAAC,OAAO,CAAC;YACtB,MAAM,EAAE;gBACN,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE;oBACR,cAAc,EAAE,UAAC,IAAY,IAAK,OAAA,IAAA,SAAE,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAtB,CAAsB;iBACzD;aACF;YACD,QAAQ,EAAE,2BAA2B;SACtC,CAAC;OACC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAC1E;AACJ,CAAC","sourcesContent":["import {\n ModuleWithProviders,\n NgModule,\n Pipe,\n PipeTransform,\n Provider,\n} from '@angular/core';\nimport {\n TranslateLoader,\n TranslateModule,\n} from '@ngx-translate/core';\nimport {\n LocalizationConfiguration,\n LocalizationModule,\n LocalizationTranslatePipe,\n} from '@o3r/localization';\nimport {\n of,\n} from 'rxjs';\n\nconst defaultLocalizationConfiguration: Partial<LocalizationConfiguration> = {\n supportedLocales: ['en'],\n language: 'en',\n endPointUrl: '',\n fallbackLanguage: 'en'\n};\n\n@Pipe({ name: 'translate' })\nexport class TranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@Pipe({ name: 'o3rTranslate' })\nexport class O3rTranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@NgModule({\n declarations: [TranslatePipeMock, O3rTranslatePipeMock],\n exports: [TranslatePipeMock, O3rTranslatePipeMock]\n})\nexport class LocalizationDependencyMocks {\n public static forTest(pipeWithPrefix = false): ModuleWithProviders<LocalizationDependencyMocks> {\n return {\n ngModule: LocalizationDependencyMocks,\n providers: [{ provide: LocalizationTranslatePipe, useClass: pipeWithPrefix ? O3rTranslatePipeMock : TranslatePipeMock }]\n };\n }\n}\n\n/** Mock to provide to the MockTranslation module */\nexport interface MockTranslations {\n [lang: string]: {\n [key: string]: any;\n };\n}\n\n/**\n * Function to get the list of modules required to test component using Localization module\n * @param localizationConfiguration Localization configuration\n * @param translations Translations to use\n * @param translationCompilerProvider Provider for translations compiler\n * @param mockPipe Enable translation pipe mocking\n * @param pipeWithPrefix Enable pipe with prefix\n * @returns List of modules to import in the TestBed\n */\nexport function mockTranslationModules(\n localizationConfiguration: Partial<LocalizationConfiguration> = defaultLocalizationConfiguration,\n translations: MockTranslations = {},\n translationCompilerProvider?: Provider,\n mockPipe = false,\n pipeWithPrefix = false\n): ModuleWithProviders<LocalizationModule>[] {\n return [\n LocalizationModule.forRoot(() => localizationConfiguration),\n TranslateModule.forRoot({\n loader: {\n provide: TranslateLoader,\n useValue: {\n getTranslation: (lang: string) => of(translations[lang])\n }\n },\n compiler: translationCompilerProvider\n }),\n ...(mockPipe ? [LocalizationDependencyMocks.forTest(pipeWithPrefix)] : [])\n ];\n}\n"]}
1
+ {"version":3,"file":"localization-mock.js","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":";;;AAsEA,wDAoBC;;AA1FD,sCAMuB;AACvB,4CAG6B;AAC7B,kDAI2B;AAC3B,6BAEc;AAEd,IAAM,gCAAgC,GAAG;IACvC,gBAAgB,EAAE,CAAC,IAAI,CAAC;IACxB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,EAAE;IACf,gBAAgB,EAAE,IAAI;CAC+B,CAAC;AAGxD;IAAA;IAIA,CAAC;IAHQ,qCAAS,GAAhB;QAAiB,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QAC7B,OAAO,IAAI,I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A,AAPD,IAOC;AAPY,kEAA2B;AAgBxC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,yBAAgG,EAChG,YAAmC,EACnC,2BAAsC,EACtC,QAAgB,EAChB,cAAsB;IAJtB,0CAAA,EAAA,4DAAgG;IAChG,6BAAA,EAAA,iBAAmC;IAEnC,yBAAA,EAAA,gBAAgB;IAChB,+BAAA,EAAA,sBAAsB;IAEtB;QACE,iCAAkB,CAAC,OAAO,CAAC,cAAM,OAAA,yBAAyB,EAAzB,CAAyB,CAAC;QAC3D,sBAAe,CAAC,OAAO,CAAC;YACtB,MAAM,EAAE;gBACN,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE;oBACR,cAAc,EAAE,UAAC,IAAY,IAAK,OAAA,IAAA,SAAE,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAtB,CAAsB;iBACzD;aACF;YACD,QAAQ,EAAE,2BAA2B;SACtC,CAAC;OACC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAC1E;AACJ,CAAC","sourcesContent":["import {\n ModuleWithProviders,\n NgModule,\n Pipe,\n PipeTransform,\n Provider,\n} from '@angular/core';\nimport {\n TranslateLoader,\n TranslateModule,\n} from '@ngx-translate/core';\nimport {\n LocalizationConfiguration,\n LocalizationModule,\n LocalizationTranslatePipe,\n} from '@o3r/localization';\nimport {\n of,\n} from 'rxjs';\n\nconst defaultLocalizationConfiguration = {\n supportedLocales: ['en'],\n language: 'en',\n endPointUrl: '',\n fallbackLanguage: 'en'\n} as const satisfies Partial<LocalizationConfiguration>;\n\n@Pipe({ name: 'translate' })\nexport class TranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@Pipe({ name: 'o3rTranslate' })\nexport class O3rTranslatePipeMock implements PipeTransform {\n public transform(...args: any[]): string | undefined {\n return args && args.map((arg) => JSON.parse(arg)).join(', ');\n }\n}\n\n@NgModule({\n declarations: [TranslatePipeMock, O3rTranslatePipeMock],\n exports: [TranslatePipeMock, O3rTranslatePipeMock]\n})\nexport class LocalizationDependencyMocks {\n public static forTest(pipeWithPrefix = false): ModuleWithProviders<LocalizationDependencyMocks> {\n return {\n ngModule: LocalizationDependencyMocks,\n providers: [{ provide: LocalizationTranslatePipe, useClass: pipeWithPrefix ? O3rTranslatePipeMock : TranslatePipeMock }]\n };\n }\n}\n\n/** Mock to provide to the MockTranslation module */\nexport interface MockTranslations {\n [lang: string]: {\n [key: string]: any;\n };\n}\n\n/**\n * Function to get the list of modules required to test component using Localization module\n * @param localizationConfiguration Localization configuration\n * @param translations Translations to use\n * @param translationCompilerProvider Provider for translations compiler\n * @param mockPipe Enable translation pipe mocking\n * @param pipeWithPrefix Enable pipe with prefix\n * @returns List of modules to import in the TestBed\n */\nexport function mockTranslationModules(\n localizationConfiguration: Partial<LocalizationConfiguration> = defaultLocalizationConfiguration,\n translations: MockTranslations = {},\n translationCompilerProvider?: Provider,\n mockPipe = false,\n pipeWithPrefix = false\n): ModuleWithProviders<LocalizationModule>[] {\n return [\n LocalizationModule.forRoot(() => localizationConfiguration),\n TranslateModule.forRoot({\n loader: {\n provide: TranslateLoader,\n useValue: {\n getTranslation: (lang: string) => of(translations[lang])\n }\n },\n compiler: translationCompilerProvider\n }),\n ...(mockPipe ? [LocalizationDependencyMocks.forTest(pipeWithPrefix)] : [])\n ];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/testing",
3
- "version": "11.6.0-prerelease.9",
3
+ "version": "12.0.0-next.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,11 +18,12 @@
18
18
  "nx": "nx",
19
19
  "ng": "yarn nx",
20
20
  "build": "yarn nx build testing",
21
- "prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' dist/schematics && yarn cpy '{collection,migration}.json' dist",
22
- "prepare:publish": "prepare-publish ./dist",
23
21
  "build:schematics": "tsc -b tsconfig.schematics.json --pretty && yarn generate-cjs-manifest",
22
+ "build:source": "tsc -b tsconfig.build.json --pretty && yarn cpy ./package.json dist",
24
23
  "build:tools": "tsc -b tsconfig.build.tools.json --pretty",
25
24
  "build:utils": "tsc -b tsconfig.build.utils.json --pretty && node ./scripts/generate-esm-manifest.cjs",
25
+ "prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' dist/schematics && yarn cpy '{collection,migration}.json' dist",
26
+ "prepare:publish": "prepare-publish ./dist",
26
27
  "postbuild": "patch-package-json-main"
27
28
  },
28
29
  "exports": {
@@ -97,29 +98,30 @@
97
98
  },
98
99
  "peerDependencies": {
99
100
  "@amadeus-it-group/kassette": "^1.7.0",
100
- "@angular-devkit/core": "~18.2.0",
101
- "@angular-devkit/schematics": "~18.2.0",
102
- "@angular/animations": "~18.2.0",
103
- "@angular/cli": "~18.2.0",
104
- "@angular/common": "~18.2.0",
105
- "@angular/core": "~18.2.0",
106
- "@angular/forms": "~18.2.0",
107
- "@angular/platform-browser": "~18.2.0",
101
+ "@angular-devkit/core": "^18.2.0",
102
+ "@angular-devkit/schematics": "^18.2.0",
103
+ "@angular/animations": "^18.2.0",
104
+ "@angular/cli": "^18.2.0",
105
+ "@angular/common": "^18.2.0",
106
+ "@angular/core": "^18.2.0",
107
+ "@angular/forms": "^18.2.0",
108
+ "@angular/platform-browser": "^18.2.0",
108
109
  "@material/slider": "^14.0.0",
109
- "@ngrx/store": "~18.0.0",
110
- "@ngx-translate/core": "~15.0.0",
111
- "@o3r/core": "^11.6.0-prerelease.9",
112
- "@o3r/localization": "^11.6.0-prerelease.9",
113
- "@o3r/schematics": "^11.6.0-prerelease.9",
114
- "@playwright/test": "~1.49.0",
115
- "@schematics/angular": "~18.2.0",
110
+ "@ngrx/store": "^18.0.0",
111
+ "@ngx-translate/core": "^15.0.0",
112
+ "@o3r/core": "^12.0.0-next.0",
113
+ "@o3r/localization": "^12.0.0-next.0",
114
+ "@o3r/schematics": "^12.0.0-next.0",
115
+ "@playwright/test": "^1.49.0",
116
+ "@schematics/angular": "^18.2.0",
116
117
  "pixelmatch": "^5.2.1",
117
118
  "pngjs": "^7.0.0",
118
119
  "protractor": "^7.0.0",
119
120
  "rxjs": "^7.8.1",
120
121
  "temporal-polyfill": "^0.2.0",
121
122
  "type-fest": "^4.10.2",
122
- "typescript": "~5.5.4"
123
+ "typescript": "^5.5.4",
124
+ "ts-node": "~10.9.2"
123
125
  },
124
126
  "peerDependenciesMeta": {
125
127
  "@amadeus-it-group/kassette": {
@@ -196,14 +198,14 @@
196
198
  "@material/slider": "^14.0.0",
197
199
  "@ngrx/store": "~18.0.0",
198
200
  "@ngx-translate/core": "~15.0.0",
199
- "@nx/eslint-plugin": "~19.5.0",
200
- "@nx/jest": "~19.5.0",
201
- "@o3r/build-helpers": "^11.6.0-prerelease.9",
202
- "@o3r/core": "^11.6.0-prerelease.9",
203
- "@o3r/eslint-plugin": "^11.6.0-prerelease.9",
204
- "@o3r/localization": "^11.6.0-prerelease.9",
205
- "@o3r/schematics": "^11.6.0-prerelease.9",
206
- "@o3r/test-helpers": "^11.6.0-prerelease.9",
201
+ "@nx/eslint-plugin": "~19.8.0",
202
+ "@nx/jest": "~19.8.0",
203
+ "@o3r/build-helpers": "^12.0.0-next.0",
204
+ "@o3r/core": "^12.0.0-next.0",
205
+ "@o3r/eslint-plugin": "^12.0.0-next.0",
206
+ "@o3r/localization": "^12.0.0-next.0",
207
+ "@o3r/schematics": "^12.0.0-next.0",
208
+ "@o3r/test-helpers": "^12.0.0-next.0",
207
209
  "@playwright/test": "~1.49.0",
208
210
  "@schematics/angular": "~18.2.0",
209
211
  "@stylistic/eslint-plugin": "~2.7.0",
@@ -211,7 +213,7 @@
211
213
  "@types/node": "^20.0.0",
212
214
  "@types/pixelmatch": "^5.2.3",
213
215
  "@types/pngjs": "^6.0.0",
214
- "@typescript-eslint/parser": "~8.12.2",
216
+ "@typescript-eslint/parser": "~8.17.0",
215
217
  "angular-eslint": "~18.4.0",
216
218
  "concurrently": "^8.0.0",
217
219
  "cpy-cli": "^5.0.0",
@@ -232,7 +234,7 @@
232
234
  "jest-junit": "~16.0.0",
233
235
  "jest-preset-angular": "~14.2.0",
234
236
  "jsonc-eslint-parser": "~2.4.0",
235
- "nx": "~19.5.0",
237
+ "nx": "~19.8.0",
236
238
  "pid-from-port": "^1.1.3",
237
239
  "pixelmatch": "^5.2.1",
238
240
  "pngjs": "^7.0.0",
@@ -244,7 +246,7 @@
244
246
  "ts-node": "~10.9.2",
245
247
  "type-fest": "^4.10.2",
246
248
  "typescript": "~5.5.4",
247
- "typescript-eslint": "~8.12.2",
249
+ "typescript-eslint": "~8.17.0",
248
250
  "zone.js": "~0.14.2"
249
251
  },
250
252
  "schematics": "./collection.json",
@@ -254,7 +256,6 @@
254
256
  "engines": {
255
257
  "node": "^18.19.1 || ^20.11.1 || >=22.0.0"
256
258
  },
257
- "type": "commonjs",
258
259
  "contributors": [
259
260
  {
260
261
  "name": "Yannick Adam",
@@ -5,9 +5,25 @@ export type MethodType = 'clickOnButton' | 'getText' | 'getInputValue' | 'setInp
5
5
  /**
6
6
  * Return type associated to the MethodType
7
7
  */
8
- export declare const returnType: Record<MethodType, string>;
8
+ export declare const returnType: {
9
+ readonly clickOnButton: "Promise<void>";
10
+ readonly getText: "Promise<string | undefined>";
11
+ readonly getInputValue: "Promise<string | undefined>";
12
+ readonly setInputValue: "Promise<void>";
13
+ readonly getTextInList: "Promise<string | undefined>";
14
+ readonly clickButtonInList: "Promise<void>";
15
+ readonly getNumberOfItems: "Promise<number>";
16
+ };
9
17
  /**
10
18
  * Description associated to the MethodType
11
19
  */
12
- export declare const description: Record<MethodType, string>;
20
+ export declare const description: {
21
+ readonly clickOnButton: "\n /**\n * Click on the button\n */";
22
+ readonly getText: "\n /**\n * Get the text\n *\n * @returns text\n */";
23
+ readonly getInputValue: "\n /**\n * Get the input value\n *\n * @returns input value\n */";
24
+ readonly setInputValue: "\n /**\n * Set value into the input\n *\n * @param value\n */";
25
+ readonly getTextInList: "\n /**\n * Get the text at the index of the list\n *\n * @param index\n * @returns text\n */";
26
+ readonly clickButtonInList: "\n /**\n * Click on the button at the index of the list\n *\n * @param index\n */";
27
+ readonly getNumberOfItems: "\n /**\n * Get the number of items\n *\n * @returns number of items\n */";
28
+ };
13
29
  //# sourceMappingURL=models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/models.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,SAAS,GACT,eAAe,GACf,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAQjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CA0ClD,CAAC"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/models.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,SAAS,GACT,eAAe,GACf,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;CAQwB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;CA0CuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/models.ts"],"names":[],"mappings":";;;AAYA;;GAEG;AACU,QAAA,UAAU,GAA+B;IACpD,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,6BAA6B;IACtC,aAAa,EAAE,6BAA6B;IAC5C,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,6BAA6B;IAC5C,iBAAiB,EAAE,eAAe;IAClC,gBAAgB,EAAE,iBAAiB;CACpC,CAAC;AAEF;;GAEG;AACU,QAAA,WAAW,GAA+B;IACrD,aAAa,EAAE;;;MAGX;IACJ,OAAO,EAAE;;;;;MAKL;IACJ,aAAa,EAAE;;;;;MAKX;IACJ,aAAa,EAAE;;;;;MAKX;IACJ,aAAa,EAAE;;;;;;MAMX;IACJ,iBAAiB,EAAE;;;;;MAKf;IACJ,gBAAgB,EAAE;;;;;MAKd;CACL,CAAC"}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/models.ts"],"names":[],"mappings":";;;AAYA;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,6BAA6B;IACtC,aAAa,EAAE,6BAA6B;IAC5C,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,6BAA6B;IAC5C,iBAAiB,EAAE,eAAe;IAClC,gBAAgB,EAAE,iBAAiB;CACU,CAAC;AAEhD;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,aAAa,EAAE;;;MAGX;IACJ,OAAO,EAAE;;;;;MAKL;IACJ,aAAa,EAAE;;;;;MAKX;IACJ,aAAa,EAAE;;;;;MAKX;IACJ,aAAa,EAAE;;;;;;MAMX;IACJ,iBAAiB,EAAE;;;;;MAKf;IACJ,gBAAgB,EAAE;;;;;MAKd;CACyC,CAAC"}
@@ -1,4 +1,18 @@
1
- import type { ImportsMapping } from '@o3r/schematics';
2
1
  /** Map to be used to double check that localization mocks from o3r testing package are well imported from the /localization subentry */
3
- export declare const mapImportLocalizationMocks: ImportsMapping;
2
+ export declare const mapImportLocalizationMocks: {
3
+ readonly '@o3r/testing': {
4
+ readonly TranslatePipeMock: {
5
+ readonly newPackage: "@o3r/testing/localization";
6
+ };
7
+ readonly LocalizationDependencyMocks: {
8
+ readonly newPackage: "@o3r/testing/localization";
9
+ };
10
+ readonly MockTranslations: {
11
+ readonly newPackage: "@o3r/testing/localization";
12
+ };
13
+ readonly mockTranslationModules: {
14
+ readonly newPackage: "@o3r/testing/localization";
15
+ };
16
+ };
17
+ };
4
18
  //# sourceMappingURL=localization-imports-map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localization-imports-map.d.ts","sourceRoot":"","sources":["../../../../../schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,wIAAwI;AACxI,eAAO,MAAM,0BAA0B,EAAE,cAexC,CAAC"}
1
+ {"version":3,"file":"localization-imports-map.d.ts","sourceRoot":"","sources":["../../../../../schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts"],"names":[],"mappings":"AAIA,wIAAwI;AACxI,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;CAeJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"localization-imports-map.js","sourceRoot":"","sources":["../../../../../schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts"],"names":[],"mappings":";;;AAIA,wIAAwI;AAC3H,QAAA,0BAA0B,GAAmB;IACxD,cAAc,EAAE;QACd,iBAAiB,EAAE;YACjB,UAAU,EAAE,2BAA2B;SACxC;QACD,2BAA2B,EAAE;YAC3B,UAAU,EAAE,2BAA2B;SACxC;QACD,gBAAgB,EAAE;YAChB,UAAU,EAAE,2BAA2B;SACxC;QACD,sBAAsB,EAAE;YACtB,UAAU,EAAE,2BAA2B;SACxC;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"localization-imports-map.js","sourceRoot":"","sources":["../../../../../schematics/ng-update/v9-0/localization-imports/localization-imports-map.ts"],"names":[],"mappings":";;;AAIA,wIAAwI;AAC3H,QAAA,0BAA0B,GAAG;IACxC,cAAc,EAAE;QACd,iBAAiB,EAAE;YACjB,UAAU,EAAE,2BAA2B;SACxC;QACD,2BAA2B,EAAE;YAC3B,UAAU,EAAE,2BAA2B;SACxC;QACD,gBAAgB,EAAE;YAChB,UAAU,EAAE,2BAA2B;SACxC;QACD,sBAAsB,EAAE;YACtB,UAAU,EAAE,2BAA2B;SACxC;KACF;CACgC,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=_fetch-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_fetch-manager.d.ts","sourceRoot":"","sources":["../../../../src/tools/protractor/fetch-manager/_fetch-manager.ts"],"names":[],"mappings":""}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ /**
3
+ * Note: This file is not part of the running script, it is injected in the browser while running e2e tests.
4
+ */
5
+ (function () {
6
+ var MAX_WAITING_TIME_FOR_FETCH = 45 * 1000; // 45 seconds
7
+ var fetchManager = /** @class */ (function () {
8
+ function FetchManager() {
9
+ this.nbCurrentFetch = 0;
10
+ }
11
+ FetchManager.prototype.interceptor = function (ref, nativeFetch) {
12
+ var args = [];
13
+ for (var _i = 2; _i < arguments.length; _i++) {
14
+ args[_i - 2] = arguments[_i];
15
+ }
16
+ var promise = Promise.resolve(args);
17
+ promise = promise.then(function () {
18
+ ref.nbCurrentFetch++;
19
+ return [args[0], args[1]];
20
+ }, function (error) {
21
+ return Promise.reject(new Error(error));
22
+ });
23
+ promise = promise.then(function () { return nativeFetch.apply(void 0, args); });
24
+ promise = promise.then(function (response) {
25
+ ref.nbCurrentFetch--;
26
+ return response;
27
+ }, function (error) {
28
+ ref.nbCurrentFetch--;
29
+ return Promise.reject(new Error(error));
30
+ });
31
+ return promise;
32
+ };
33
+ /**
34
+ * Register the fetch events to count the number of pending fetch.
35
+ */
36
+ FetchManager.prototype.registerFetchInterceptor = function () {
37
+ var _this = this;
38
+ var nativeFetch = window.fetch;
39
+ // eslint-disable-next-line @typescript-eslint/no-this-alias, unicorn/no-this-assignment -- needed for the context
40
+ var that = this;
41
+ Object.assign(window, { fetch: function () {
42
+ var args = [];
43
+ for (var _i = 0; _i < arguments.length; _i++) {
44
+ args[_i] = arguments[_i];
45
+ }
46
+ return _this.interceptor.apply(_this, __spreadArray([that, nativeFetch], args, false));
47
+ } });
48
+ };
49
+ FetchManager.prototype.unregisterFetchInterceptor = function () {
50
+ Object.assign(window, { fetch: this.windowFetch });
51
+ };
52
+ /**
53
+ * Returns the single instance of FetchManager
54
+ */
55
+ FetchManager.getInstance = function () {
56
+ return this._instance || (this._instance = new this());
57
+ };
58
+ /**
59
+ * Initialize the fetch manager
60
+ */
61
+ FetchManager.prototype.init = function () {
62
+ this.nbCurrentFetch = 0;
63
+ this.registerFetchInterceptor();
64
+ };
65
+ /**
66
+ * Stop the interceptor
67
+ */
68
+ FetchManager.prototype.stop = function () {
69
+ this.nbCurrentFetch = 0;
70
+ this.unregisterFetchInterceptor();
71
+ };
72
+ /**
73
+ * Get the number of active fetchs on the page.
74
+ */
75
+ FetchManager.prototype.getPendingFetchs = function () {
76
+ return this.nbCurrentFetch;
77
+ };
78
+ /**
79
+ * This function waits for all fetchs calls to be resolved and the page to be stable to call the callback.
80
+ * It permits to easily run synchronous tests with protractor.
81
+ * This is very usefull in the case of Otter calls to backend because protractor synchronization manager do not care
82
+ * about fetchs calls. As a consequence, the `waitForAngular` method will not work.
83
+ * @param callback : Callback called when all the fetchs are finished and the page is stable.
84
+ * @param timeoutInterval : Interval in milliseconds between two checks of the number of pending fetchs
85
+ */
86
+ FetchManager.prototype.waitForFetchs = function (callback, timeoutInterval) {
87
+ var _this = this;
88
+ if (timeoutInterval === void 0) { timeoutInterval = 100; }
89
+ var interval;
90
+ var timeout;
91
+ if (!this.getPendingFetchs()) {
92
+ callback();
93
+ return;
94
+ }
95
+ var cancelPolling = function () {
96
+ if (interval) {
97
+ clearInterval(interval);
98
+ interval = undefined;
99
+ }
100
+ if (timeout) {
101
+ clearTimeout(timeout);
102
+ timeout = undefined;
103
+ }
104
+ // Handle polling result
105
+ if (_this.getPendingFetchs() > 0) {
106
+ // Error case will just log in console
107
+ // and allow to continue as o3r elements might be checking fetchManager
108
+ // concurrently
109
+ _this.nbCurrentFetch = 0;
110
+ callback();
111
+ throw new Error('Fetch timeout. Please check network requests.');
112
+ }
113
+ else {
114
+ callback();
115
+ }
116
+ };
117
+ var polling = function () { return _this.getPendingFetchs() > 0 || cancelPolling(); };
118
+ interval = setInterval(polling, timeoutInterval);
119
+ timeout = setTimeout(cancelPolling, MAX_WAITING_TIME_FOR_FETCH);
120
+ };
121
+ return FetchManager;
122
+ }());
123
+ if (!('fetchManager' in window)) {
124
+ Object.assign(window, { fetchManager: fetchManager });
125
+ }
126
+ })();
127
+ //# sourceMappingURL=_fetch-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_fetch-manager.js","sourceRoot":"","sources":["../../../../src/tools/protractor/fetch-manager/_fetch-manager.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,CAAC;IAUC,IAAM,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;IAE3D,IAAM,YAAY;QAKhB;YAHQ,mBAAc,GAAG,CAAC,CAAC;QAGJ,CAAC;QAEhB,kCAAW,GAAnB,UAAoB,GAAiB,EAAE,WAAgB;YAAE,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,6BAAc;;YACrE,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACpC,OAAO,GAAG,OAAO,CAAC,IAAI,CACpB;gBACE,GAAG,CAAC,cAAc,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC,EACD,UAAC,KAAK;gBACJ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;YACL,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,cAAM,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C;IAAD,CAAC,AAzHoB,GAyHpB,CAAC;IAEF,IAAI,CAAC,CAAC,cAAc,IAAI,MAAM,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,YAAY,cAAA,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Note: This file is not part of the running script, it is injected in the browser while running e2e tests.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=_post-message-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_post-message-interceptor.d.ts","sourceRoot":"","sources":["../../../../src/tools/protractor/post-message-interceptor/_post-message-interceptor.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /**
3
+ * Note: This file is not part of the running script, it is injected in the browser while running e2e tests.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // TODO: Move to PollyJS when the winter comes
7
+ (function () {
8
+ /**
9
+ * PostMessageInterceptor permits to intercept calls to postMessage.
10
+ */
11
+ var postMessageInterceptor = /** @class */ (function () {
12
+ function PostMessageInterceptor() {
13
+ this.lastCalls = [];
14
+ this.listening = false;
15
+ }
16
+ /**
17
+ * Logs a message in the console
18
+ * @param message
19
+ * @param {...any} args
20
+ */
21
+ PostMessageInterceptor.prototype.log = function (message) {
22
+ var args = [];
23
+ for (var _i = 1; _i < arguments.length; _i++) {
24
+ args[_i - 1] = arguments[_i];
25
+ }
26
+ // eslint-disable-next-line no-console -- this is the purpose of this method
27
+ console.log.apply(console, __spreadArray(["#postMessageInterceptor: ".concat(message)], args, false));
28
+ };
29
+ /**
30
+ * Intercepts the native postMessage call
31
+ * @param ref Singleton instance of the interceptor
32
+ * @param nativeMethod native postMessage method
33
+ * @param args all the args passed to the postMessage
34
+ */
35
+ PostMessageInterceptor.prototype.interceptor = function (ref, nativeMethod) {
36
+ var args = [];
37
+ for (var _i = 2; _i < arguments.length; _i++) {
38
+ args[_i - 2] = arguments[_i];
39
+ }
40
+ this.log('Intercepted', args);
41
+ var postCall = {
42
+ data: args[0],
43
+ targetOrigin: args[1],
44
+ timestamp: new Date()
45
+ };
46
+ if (ref.listening) {
47
+ if (ref.conditionFn && !ref.conditionFn(postCall)) {
48
+ this.log('Intercepted message does not pass the condition');
49
+ return;
50
+ }
51
+ ref.lastCalls.push(postCall);
52
+ this.log('Last call count', ref.lastCalls.length);
53
+ }
54
+ else {
55
+ this.log('Not listening');
56
+ }
57
+ nativeMethod.apply(void 0, args);
58
+ };
59
+ /**
60
+ * Register the interceptor in the window object
61
+ */
62
+ PostMessageInterceptor.prototype.registerFetchInterceptor = function () {
63
+ var _this = this;
64
+ var nativeMethod = window.postMessage;
65
+ this.nativeMethod = nativeMethod;
66
+ Object.assign(window, { postMessage: function () {
67
+ var args = [];
68
+ for (var _i = 0; _i < arguments.length; _i++) {
69
+ args[_i] = arguments[_i];
70
+ }
71
+ return _this.interceptor.apply(_this, __spreadArray([_this, nativeMethod], args, false));
72
+ } });
73
+ };
74
+ /**
75
+ * Unregister the interceptor from the window object
76
+ */
77
+ PostMessageInterceptor.prototype.unregisterFetchInterceptor = function () {
78
+ Object.assign(window, { postMessage: this.nativeMethod });
79
+ };
80
+ /**
81
+ * Returns the singleton instance of the interceptor
82
+ */
83
+ PostMessageInterceptor.getInstance = function () {
84
+ return this._instance || (this._instance = new this());
85
+ };
86
+ /**
87
+ * Initialize the interceptor
88
+ */
89
+ PostMessageInterceptor.prototype.init = function () {
90
+ this.reset();
91
+ this.log('Init');
92
+ this.registerFetchInterceptor();
93
+ };
94
+ /**
95
+ * Stops the interceptor
96
+ */
97
+ PostMessageInterceptor.prototype.stop = function () {
98
+ this.reset();
99
+ this.log('Stop');
100
+ this.unregisterFetchInterceptor();
101
+ };
102
+ /**
103
+ * Resets the stack of lastCalls
104
+ */
105
+ PostMessageInterceptor.prototype.reset = function () {
106
+ this.lastCalls = [];
107
+ };
108
+ /**
109
+ * Starts listening and saving postMessages
110
+ * @param conditionFnString The function string to be used as condition checker
111
+ */
112
+ PostMessageInterceptor.prototype.listen = function (conditionFnString) {
113
+ this.listening = false;
114
+ this.reset();
115
+ if (conditionFnString) {
116
+ // eslint-disable-next-line no-eval -- done on purpose
117
+ this.conditionFn = eval(conditionFnString);
118
+ }
119
+ this.listening = true;
120
+ };
121
+ /**
122
+ * Stops listening
123
+ * NOTE: It resets the interceptor and clears the conditionFn (if any)
124
+ */
125
+ PostMessageInterceptor.prototype.stopListening = function () {
126
+ this.listening = false;
127
+ this.reset();
128
+ this.conditionFn = undefined;
129
+ this.listening = true;
130
+ };
131
+ /**
132
+ * Get the messages stack
133
+ * @param timeoutInterval the interval, in ms, between each check
134
+ * @param retries number of tentatives if fail
135
+ * @param callback
136
+ */
137
+ PostMessageInterceptor.prototype.getMessages = function (timeoutInterval, retries, callback) {
138
+ var _this = this;
139
+ var activeMessageWatch = function (remainingRetries) {
140
+ if (remainingRetries === 0 || _this.lastCalls.length > 0) {
141
+ var copyCalls = _this.lastCalls.slice();
142
+ _this.reset();
143
+ callback(copyCalls);
144
+ return;
145
+ }
146
+ else if (remainingRetries > 0) {
147
+ remainingRetries--;
148
+ }
149
+ setTimeout(function () { return activeMessageWatch(remainingRetries); }, timeoutInterval);
150
+ };
151
+ activeMessageWatch(retries);
152
+ };
153
+ return PostMessageInterceptor;
154
+ }());
155
+ Object.assign(window, { postMessageInterceptor: postMessageInterceptor });
156
+ })();
157
+ //# sourceMappingURL=_post-message-interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_post-message-interceptor.js","sourceRoot":"","sources":["../../../../src/tools/protractor/post-message-interceptor/_post-message-interceptor.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAOH,8CAA8C;AAC9C,CAAC;IACC;;OAEG;IACH,IAAM,sBAAsB;QAO1B;YACE,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,IAAI,CAAC,SA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AC;QACxB,CAAC;QAED;;;WAGG;QACI,8CAAa,GAApB;YACE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;QAED;;;;;WAKG;QACI,4CAAW,GAAlB,UAAmB,eAAuB,EAAE,OAAe,EAAE,QAAa;YAA1E,iBAcC;YAbC,IAAM,kBAAkB,GAAG,UAAC,gBAAwB;gBAClD,IAAI,gBAAgB,KAAK,CAAC,IAAI,KAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxD,IAAM,SAAS,GAAG,KAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;oBACzC,KAAI,CAAC,KAAK,EAAE,CAAC;oBACb,QAAQ,CAAC,SAAS,CAAC,CAAC;oBACpB,OAAO;gBACT,CAAC;qBAAM,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;oBAChC,gBAAgB,EAAE,CAAC;gBACrB,CAAC;gBAED,UAAU,CAAC,cAAM,OAAA,kBAAkB,CAAC,gBAAgB,CAAC,EAApC,CAAoC,EAAE,eAAe,CAAC,CAAC;YAC1E,CAAC,CAAC;YACF,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QACH,6BAAC;IAAD,CAAC,AAhJ8B,GAgJ9B,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,sBAAsB,wBAAA,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC,EAAE,CAAC"}
@@ -14,7 +14,7 @@ export interface VisualTestMessage {
14
14
  generateMode: string;
15
15
  }
16
16
  /** Error messages in case of visual testing failure */
17
- export declare const visualTestMessages: VisualTestMessage;
17
+ export declare const visualTestMessages: Readonly<VisualTestMessage>;
18
18
  /**
19
19
  * Object returned by a visual test operation
20
20
  */
@@ -1 +1 @@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ACpB,oBAAgC,EAChC,SAAa,EACb,YAAoB,EACpB,sBAAgD;IAHhD,qCAAA,EAAA,gCAAgC;IAChC,0BAAA,EAAA,aAAa;IACb,6BAAA,EAAA,oBAAoB;IACpB,uCAAA,EAAA,gDAAgD;IAEhD,IAAI,YAAY,EAAE,CAAC;QACjB,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAC9E,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,IAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,YAAY,EAAE,MAAM,EAAE,UAAG,wBAAwB,SAAM,CAAC,CAAC;QACpH,IAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1G,OAAO,gBAAgB,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as pixelmatch from 'pixelmatch';\nimport {\n PNG,\n} from 'pngjs';\n\nexport {\n prepareVisualTesting,\n toggleVisualTestingRender,\n} from './utils';\n\n/** Error types returned by visual testing comparison */\nexport interface VisualTestMessage {\n /** Error message when base image and actual image have different sizes */\n imagesSize: string;\n /** Error message when base screensot not found */\n baseImgNotFound: string;\n /** Error message when the threshold is passed */\n diffMessage: string;\n /** The message in case of success */\n success: string;\n /** The message in case of generate mode run */\n generateMode: string;\n}\n\n/** Error messages in case of visual testing failure */\nexport const visualTestMessages: VisualTestMessage = {\n imagesSize: 'Image sizes do not match for:',\n diffMessage: 'Diff between images is greater than threshold for:',\n baseImgNotFound: 'Base screenshot file not found:',\n success: 'Visual test successful',\n generateMode: 'Run in generate screenshot mode'\n};\n\n/**\n * Object returned by a visual test operation\n */\nexport interface VisualTestResult {\n /** Error object when base image and actual image have different sizes; Contains the screenshot ffile name */\n imagesSize?: { screenshotName: string };\n /** Error object when base screensot not found. Contains the not found path as a string */\n baseScreenshotNotFound?: { baseScreenshotPath: string };\n /** Object containing the actual diff between images as percentage, the threshold and screenshot file name */\n diff?: { actualDiff: number; threshold: number; screenshotName: string };\n /** Run only generation of screenshots */\n generateMode?: boolean;\n}\n\n/**\n * Visual test matcher\n * Based on the VisualTestResult object return by compareScreenshots function, this matcher will compute the error messages\n */\nexport function toBeVisuallySimilar() {\n return {\n compare: (actual: VisualTestResult, _expected: VisualTestResult) => {\n if (actual.generateMode) {\n return {\n pass: true,\n message: visualTestMessages.generateMode\n };\n }\n if (actual.baseScreenshotNotFound) {\n return {\n pass: false,\n message: `${visualTestMessages.baseImgNotFound} ${actual.baseScreenshotNotFound.baseScreenshotPath}` };\n }\n if (actual.imagesSize) {\n return {\n pass: false,\n message: `${visualTestMessages.imagesSize} ${actual.imagesSize.screenshotName}`\n };\n }\n if (actual.diff && actual.diff.actualDiff > actual.diff.threshold) {\n return {\n pass: false,\n message: `${actual.diff.actualDiff} > ${actual.diff.threshold} : ${visualTestMessages.diffMessage} ${actual.diff.screenshotName}`\n };\n }\n return {\n pass: true,\n message: visualTestMessages.success\n };\n }\n };\n}\n\n/**\n * It will create a file for the passed screenshot object.\n * The path of the new file will be calculated using the parameters\n * Ex: ./dist-screenshots\\OWBooking\\windows_chrome_91\\fare-page-after-click-on-continue-0.png\n * distScreenshotsDir/scenarionName/device/filenameWithoutExtension.png\n * @param screenshot The screenshot object captured. Ex: for protractor - browser.takeScreenshot()\n * @param scenarioName E2e Scenario class name\n * @param device Details of the platform on which the test is run. If there are spaces the helper will do the concatenation. Ex: `Windows 10 chrome 89`\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param distScreenshotsDir Name of the directory to save the screenshots\n */\nexport function saveScreenshot(screenshot: string, scenarioName: string, device: string, filenameWithoutExtension: string, distScreenshotsDir = 'dist-screenshots') {\n const screenshotsDir = path.resolve(distScreenshotsDir, scenarioName, `${device.replace(/ +/g, '_')}`);\n if (!fs.existsSync(screenshotsDir)) {\n fs.mkdirSync(screenshotsDir, { recursive: true });\n }\n const fullFileName = `${filenameWithoutExtension}.png`;\n const stream = fs.createWriteStream(path.resolve(screenshotsDir, fullFileName));\n stream.write(Buffer.from(screenshot, 'base64'));\n stream.end();\n}\n\n/**\n * Write the 3 images (base/new/diff) on the reports folder\n * The path inside the reports forlder will be calculated using the parameters\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder\n * @param screenshotsDirName Name of the directory which will contain the 3 images\n * @param diff diff image\n * @param baseImage the base image\n * @param currentImg the actual taken screenshot image\n */\nexport function writeScreenshotsDiff(pathToScenarioReport: string, screenshotsDirName: string, diff: PNG, baseImage: PNG, currentImg: PNG) {\n const destScreenshotsDiffDir = path.join(pathToScenarioReport, 'screenshots-diff', screenshotsDirName);\n if (!fs.existsSync(destScreenshotsDiffDir)) {\n fs.mkdirSync(destScreenshotsDiffDir, { recursive: true });\n }\n\n const diffPath = path.resolve(destScreenshotsDiffDir, 'diff.png');\n const oldPath = path.resolve(destScreenshotsDiffDir, 'old.png');\n const newPath = path.resolve(destScreenshotsDiffDir, 'new.png');\n fs.writeFileSync(diffPath, PNG.sync.write(diff));\n fs.writeFileSync(oldPath, PNG.sync.write(baseImage));\n fs.writeFileSync(newPath, PNG.sync.write(currentImg));\n}\n\n/**\n * Compare images helper function. If the comparison fails the 3 images (base/new/diff) will be written inside the reports folder of the actual scenario\n * @param screenshot Actual captured screenshot object\n * @param baseImagePath The path to the base screenshot\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder. Used to compute the path to write diff images in case there is a diff at comparison\n * @returns An object of visual test result type\n */\nexport function compareScreenshot(screenshot: string, baseImagePath: string, threshold: number, pathToScenarioReport: string): VisualTestResult {\n const baseImageExists = fs.existsSync(baseImagePath);\n if (baseImageExists) {\n const baseImage = PNG.sync.read(fs.readFileSync(baseImagePath));\n const { width, height } = baseImage;\n const diff = new PNG({ width, height });\n\n const screenshotBuffer = Buffer.from(screenshot, 'base64');\n const currentImg = PNG.sync.read(screenshotBuffer);\n const diffDirName = path.basename(baseImagePath, '.png');\n let result;\n try {\n result = pixelmatch(baseImage.data, currentImg.data, diff.data, width, height, { threshold: 0.1 });\n } catch (err: any) {\n if (!err.toString().includes('Image sizes do not match.')) {\n throw err;\n }\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n return { imagesSize: { screenshotName: diffDirName } };\n }\n const pr = Math.round(100 * 100 * result / (width * height)) / 100;\n if (pr > threshold) {\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n }\n return { diff: { actualDiff: pr, threshold, screenshotName: diffDirName } };\n } else {\n return { baseScreenshotNotFound: { baseScreenshotPath: baseImagePath } };\n }\n}\n\n/**\n * Helper function to perform a visual test operation\n * @param screenshotObj Ex: for protractor browser.takeScreenshot()\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param device os followed by browser version - ex: `Windows 10 chrome 89`\n * @param scenarioName E2e Scenario class name\n * @param pathToScenarioReport Path used in compare mode for saving the base,new,diff images in reports in case there is a diff\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * If the diff is bigger, 3 png files will be created: base screenshot, new screenshot and diff image\n * @param generateMode If true it will generate the screenshot file without screenshots comparison\n * @param baseScreenshotsDirPath The folder path to search base screenshots; used only in compare mode\n */\nexport function o3rVisualTest(\n screenshotObj: string,\n filenameWithoutExtension: string,\n device: string,\n scenarioName: string,\n pathToScenarioReport = 'reports',\n threshold = 0,\n generateMode = false,\n baseScreenshotsDirPath = 'dist-screenshots-base'\n) {\n if (generateMode) {\n saveScreenshot(screenshotObj, scenarioName, device, filenameWithoutExtension);\n return { generateMode: true };\n } else {\n const baseImagePath = path.resolve(baseScreenshotsDirPath, scenarioName, device, `${filenameWithoutExtension}.png`);\n const visualTestResult = compareScreenshot(screenshotObj, baseImagePath, threshold, pathToScenarioReport);\n return visualTestResult;\n }\n}\n"]}
1
+ {"version":3,"file":"visual-test.js","sourceRoot":"","sources":["../../src/visual-test/visual-test.ts"],"names":[],"mappings":";;;AAqDA,kDAgCC;AAaD,wCASC;AAWD,oDAYC;AAUD,8CA4BC;AAcD,sCAkBC;AAxMD,4BAA8B;AAC9B,gCAAkC;AAClC,uCAAyC;AACzC,+BAEe;AAEf,iCAGiB;AAFf,6GAAA,oBAAoB,OAAA;AACpB,kHAAA,yBAAyB,OAAA;AAiB3B,uDAAuD;AAC1C,QAAA,kBAAkB,GAAgC;IAC7D,UAAU,EAAE,+BAA+B;IAC3C,WAAW,EAAE,oDAAoD;IACjE,eAAe,EAAE,iCAAiC;IAClD,OAAO,EAAE,wBAAwB;IACjC,YAAY,EAAE,iCAAiC;CACvC,CAAC;AAgBX;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO;QACL,OAAO,EAAE,UAAC,MAAwB,EAAE,SAA2B;YAC7D,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;gBACxB,OAAO;oBACL,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,0BAAkB,CAAC,YAAY;iBACzC,CAAC;YACJ,CAAC;YACD,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAClC,OAAO;oBACL,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,UAAG,0BAAkB,CAAC,eAAe,cAAI,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,CAAE;iBAAE,CAAC;YAC3G,CAAC;YACD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,OAAO;oBACL,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,UAAG,0BAAkB,CAAC,UAAU,cAAI,MAAM,CAAC,UAAU,CAAC,cAAc,CAAE;iBAChF,CAAC;YACJ,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBA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AAM,CAAC;QACN,OAAO,EAAE,sBAAsB,EAAE,EAAE,kBAAkB,EAAE,aAAa,EAAE,EAAE,CAAC;IAC3E,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAC3B,aAAqB,EACrB,wBAAgC,EAChC,MAAc,EACd,YAAoB,EACpB,oBAAgC,EAChC,SAAa,EACb,YAAoB,EACpB,sBAAgD;IAHhD,qCAAA,EAAA,gCAAgC;IAChC,0BAAA,EAAA,aAAa;IACb,6BAAA,EAAA,oBAAoB;IACpB,uCAAA,EAAA,gDAAgD;IAEhD,IAAI,YAAY,EAAE,CAAC;QACjB,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAC9E,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,IAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,YAAY,EAAE,MAAM,EAAE,UAAG,wBAAwB,SAAM,CAAC,CAAC;QACpH,IAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1G,OAAO,gBAAgB,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as pixelmatch from 'pixelmatch';\nimport {\n PNG,\n} from 'pngjs';\n\nexport {\n prepareVisualTesting,\n toggleVisualTestingRender,\n} from './utils';\n\n/** Error types returned by visual testing comparison */\nexport interface VisualTestMessage {\n /** Error message when base image and actual image have different sizes */\n imagesSize: string;\n /** Error message when base screensot not found */\n baseImgNotFound: string;\n /** Error message when the threshold is passed */\n diffMessage: string;\n /** The message in case of success */\n success: string;\n /** The message in case of generate mode run */\n generateMode: string;\n}\n\n/** Error messages in case of visual testing failure */\nexport const visualTestMessages: Readonly<VisualTestMessage> = {\n imagesSize: 'Image sizes do not match for:',\n diffMessage: 'Diff between images is greater than threshold for:',\n baseImgNotFound: 'Base screenshot file not found:',\n success: 'Visual test successful',\n generateMode: 'Run in generate screenshot mode'\n} as const;\n\n/**\n * Object returned by a visual test operation\n */\nexport interface VisualTestResult {\n /** Error object when base image and actual image have different sizes; Contains the screenshot ffile name */\n imagesSize?: { screenshotName: string };\n /** Error object when base screensot not found. Contains the not found path as a string */\n baseScreenshotNotFound?: { baseScreenshotPath: string };\n /** Object containing the actual diff between images as percentage, the threshold and screenshot file name */\n diff?: { actualDiff: number; threshold: number; screenshotName: string };\n /** Run only generation of screenshots */\n generateMode?: boolean;\n}\n\n/**\n * Visual test matcher\n * Based on the VisualTestResult object return by compareScreenshots function, this matcher will compute the error messages\n */\nexport function toBeVisuallySimilar() {\n return {\n compare: (actual: VisualTestResult, _expected: VisualTestResult) => {\n if (actual.generateMode) {\n return {\n pass: true,\n message: visualTestMessages.generateMode\n };\n }\n if (actual.baseScreenshotNotFound) {\n return {\n pass: false,\n message: `${visualTestMessages.baseImgNotFound} ${actual.baseScreenshotNotFound.baseScreenshotPath}` };\n }\n if (actual.imagesSize) {\n return {\n pass: false,\n message: `${visualTestMessages.imagesSize} ${actual.imagesSize.screenshotName}`\n };\n }\n if (actual.diff && actual.diff.actualDiff > actual.diff.threshold) {\n return {\n pass: false,\n message: `${actual.diff.actualDiff} > ${actual.diff.threshold} : ${visualTestMessages.diffMessage} ${actual.diff.screenshotName}`\n };\n }\n return {\n pass: true,\n message: visualTestMessages.success\n };\n }\n };\n}\n\n/**\n * It will create a file for the passed screenshot object.\n * The path of the new file will be calculated using the parameters\n * Ex: ./dist-screenshots\\OWBooking\\windows_chrome_91\\fare-page-after-click-on-continue-0.png\n * distScreenshotsDir/scenarionName/device/filenameWithoutExtension.png\n * @param screenshot The screenshot object captured. Ex: for protractor - browser.takeScreenshot()\n * @param scenarioName E2e Scenario class name\n * @param device Details of the platform on which the test is run. If there are spaces the helper will do the concatenation. Ex: `Windows 10 chrome 89`\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param distScreenshotsDir Name of the directory to save the screenshots\n */\nexport function saveScreenshot(screenshot: string, scenarioName: string, device: string, filenameWithoutExtension: string, distScreenshotsDir = 'dist-screenshots') {\n const screenshotsDir = path.resolve(distScreenshotsDir, scenarioName, `${device.replace(/ +/g, '_')}`);\n if (!fs.existsSync(screenshotsDir)) {\n fs.mkdirSync(screenshotsDir, { recursive: true });\n }\n const fullFileName = `${filenameWithoutExtension}.png`;\n const stream = fs.createWriteStream(path.resolve(screenshotsDir, fullFileName));\n stream.write(Buffer.from(screenshot, 'base64'));\n stream.end();\n}\n\n/**\n * Write the 3 images (base/new/diff) on the reports folder\n * The path inside the reports forlder will be calculated using the parameters\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder\n * @param screenshotsDirName Name of the directory which will contain the 3 images\n * @param diff diff image\n * @param baseImage the base image\n * @param currentImg the actual taken screenshot image\n */\nexport function writeScreenshotsDiff(pathToScenarioReport: string, screenshotsDirName: string, diff: PNG, baseImage: PNG, currentImg: PNG) {\n const destScreenshotsDiffDir = path.join(pathToScenarioReport, 'screenshots-diff', screenshotsDirName);\n if (!fs.existsSync(destScreenshotsDiffDir)) {\n fs.mkdirSync(destScreenshotsDiffDir, { recursive: true });\n }\n\n const diffPath = path.resolve(destScreenshotsDiffDir, 'diff.png');\n const oldPath = path.resolve(destScreenshotsDiffDir, 'old.png');\n const newPath = path.resolve(destScreenshotsDiffDir, 'new.png');\n fs.writeFileSync(diffPath, PNG.sync.write(diff));\n fs.writeFileSync(oldPath, PNG.sync.write(baseImage));\n fs.writeFileSync(newPath, PNG.sync.write(currentImg));\n}\n\n/**\n * Compare images helper function. If the comparison fails the 3 images (base/new/diff) will be written inside the reports folder of the actual scenario\n * @param screenshot Actual captured screenshot object\n * @param baseImagePath The path to the base screenshot\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder. Used to compute the path to write diff images in case there is a diff at comparison\n * @returns An object of visual test result type\n */\nexport function compareScreenshot(screenshot: string, baseImagePath: string, threshold: number, pathToScenarioReport: string): VisualTestResult {\n const baseImageExists = fs.existsSync(baseImagePath);\n if (baseImageExists) {\n const baseImage = PNG.sync.read(fs.readFileSync(baseImagePath));\n const { width, height } = baseImage;\n const diff = new PNG({ width, height });\n\n const screenshotBuffer = Buffer.from(screenshot, 'base64');\n const currentImg = PNG.sync.read(screenshotBuffer);\n const diffDirName = path.basename(baseImagePath, '.png');\n let result;\n try {\n result = pixelmatch(baseImage.data, currentImg.data, diff.data, width, height, { threshold: 0.1 });\n } catch (err: any) {\n if (!err.toString().includes('Image sizes do not match.')) {\n throw err;\n }\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n return { imagesSize: { screenshotName: diffDirName } };\n }\n const pr = Math.round(100 * 100 * result / (width * height)) / 100;\n if (pr > threshold) {\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n }\n return { diff: { actualDiff: pr, threshold, screenshotName: diffDirName } };\n } else {\n return { baseScreenshotNotFound: { baseScreenshotPath: baseImagePath } };\n }\n}\n\n/**\n * Helper function to perform a visual test operation\n * @param screenshotObj Ex: for protractor browser.takeScreenshot()\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param device os followed by browser version - ex: `Windows 10 chrome 89`\n * @param scenarioName E2e Scenario class name\n * @param pathToScenarioReport Path used in compare mode for saving the base,new,diff images in reports in case there is a diff\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * If the diff is bigger, 3 png files will be created: base screenshot, new screenshot and diff image\n * @param generateMode If true it will generate the screenshot file without screenshots comparison\n * @param baseScreenshotsDirPath The folder path to search base screenshots; used only in compare mode\n */\nexport function o3rVisualTest(\n screenshotObj: string,\n filenameWithoutExtension: string,\n device: string,\n scenarioName: string,\n pathToScenarioReport = 'reports',\n threshold = 0,\n generateMode = false,\n baseScreenshotsDirPath = 'dist-screenshots-base'\n) {\n if (generateMode) {\n saveScreenshot(screenshotObj, scenarioName, device, filenameWithoutExtension);\n return { generateMode: true };\n } else {\n const baseImagePath = path.resolve(baseScreenshotsDirPath, scenarioName, device, `${filenameWithoutExtension}.png`);\n const visualTestResult = compareScreenshot(screenshotObj, baseImagePath, threshold, pathToScenarioReport);\n return visualTestResult;\n }\n}\n"]}