@o3r/testing 11.0.0-next.0 → 11.0.0-next.1

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 (110) hide show
  1. package/README.md +5 -1
  2. package/core/angular/angular-materials/autocomplete-material.js.map +1 -1
  3. package/core/angular/angular-materials/select-material.js.map +1 -1
  4. package/core/angular/component-fixture.js +12 -12
  5. package/core/angular/component-fixture.js.map +1 -1
  6. package/core/angular/elements/checkbox-element.js.map +1 -1
  7. package/core/angular/elements/radio-element.js.map +1 -1
  8. package/core/angular/elements/select-element.js.map +1 -1
  9. package/core/angular/groups/radio-group.js.map +1 -1
  10. package/core/angular/page-fixture.js.map +1 -1
  11. package/core/angular-materials/autocomplete-material.js.map +1 -1
  12. package/core/angular-materials/select-material.js.map +1 -1
  13. package/core/elements/checkbox-element.js.map +1 -1
  14. package/core/elements/radio-element.js.map +1 -1
  15. package/core/elements/select-element.js.map +1 -1
  16. package/core/groups/radio-group.js.map +1 -1
  17. package/core/helpers.d.ts.map +1 -1
  18. package/core/helpers.js.map +1 -1
  19. package/core/page-fixture.js.map +1 -1
  20. package/core/playwright/angular-materials/autocomplete-material.js +3 -3
  21. package/core/playwright/angular-materials/autocomplete-material.js.map +1 -1
  22. package/core/playwright/angular-materials/select-material.js +9 -9
  23. package/core/playwright/angular-materials/select-material.js.map +1 -1
  24. package/core/playwright/component-fixture.d.ts +6 -6
  25. package/core/playwright/component-fixture.d.ts.map +1 -1
  26. package/core/playwright/component-fixture.js +60 -106
  27. package/core/playwright/component-fixture.js.map +1 -1
  28. package/core/playwright/element.d.ts.map +1 -1
  29. package/core/playwright/element.js +4 -28
  30. package/core/playwright/element.js.map +1 -1
  31. package/core/playwright/elements/checkbox-element.js +3 -3
  32. package/core/playwright/elements/checkbox-element.js.map +1 -1
  33. package/core/playwright/elements/radio-element.js +3 -3
  34. package/core/playwright/elements/radio-element.js.map +1 -1
  35. package/core/playwright/elements/select-element.js.map +1 -1
  36. package/core/playwright/groups/radio-group.js.map +1 -1
  37. package/core/playwright/page-fixture.js.map +1 -1
  38. package/core/protractor/angular-materials/autocomplete-material.js.map +1 -1
  39. package/core/protractor/angular-materials/select-material.js.map +1 -1
  40. package/core/protractor/component-fixture.js +12 -12
  41. package/core/protractor/component-fixture.js.map +1 -1
  42. package/core/protractor/elements/checkbox-element.js +3 -3
  43. package/core/protractor/elements/checkbox-element.js.map +1 -1
  44. package/core/protractor/elements/radio-element.js +3 -3
  45. package/core/protractor/elements/radio-element.js.map +1 -1
  46. package/core/protractor/elements/select-element.js.map +1 -1
  47. package/core/protractor/groups/radio-group.js.map +1 -1
  48. package/core/protractor/page-fixture.js.map +1 -1
  49. package/errors/fixture-usage-error.js.map +1 -1
  50. package/errors/transpilation-purpose-only.js.map +1 -1
  51. package/kassette/update-dates-in-mocks.js +11 -11
  52. package/kassette/update-dates-in-mocks.js.map +1 -1
  53. package/localization/localization-mock.d.ts +10 -6
  54. package/localization/localization-mock.d.ts.map +1 -1
  55. package/localization/localization-mock.js +30 -11
  56. package/localization/localization-mock.js.map +1 -1
  57. package/mocks/mock-component-generator.js.map +1 -1
  58. package/package.json +63 -57
  59. package/schematics/add-functions-to-fixture/helpers.js.map +1 -1
  60. package/schematics/add-functions-to-fixture/index.d.ts +1 -2
  61. package/schematics/add-functions-to-fixture/index.d.ts.map +1 -1
  62. package/schematics/add-functions-to-fixture/index.js +6 -3
  63. package/schematics/add-functions-to-fixture/index.js.map +1 -1
  64. package/schematics/fixture-to-component/index.d.ts +6 -2
  65. package/schematics/fixture-to-component/index.d.ts.map +1 -1
  66. package/schematics/fixture-to-component/index.js +9 -5
  67. package/schematics/fixture-to-component/index.js.map +1 -1
  68. package/schematics/ng-add/fixture/index.d.ts +1 -2
  69. package/schematics/ng-add/fixture/index.d.ts.map +1 -1
  70. package/schematics/ng-add/fixture/index.js +16 -18
  71. package/schematics/ng-add/fixture/index.js.map +1 -1
  72. package/schematics/ng-add/index.d.ts +2 -2
  73. package/schematics/ng-add/index.d.ts.map +1 -1
  74. package/schematics/ng-add/index.js +45 -30
  75. package/schematics/ng-add/index.js.map +1 -1
  76. package/schematics/ng-add/playwright/index.d.ts +3 -2
  77. package/schematics/ng-add/playwright/index.d.ts.map +1 -1
  78. package/schematics/ng-add/playwright/index.js +20 -8
  79. package/schematics/ng-add/playwright/index.js.map +1 -1
  80. package/schematics/ng-add/playwright/templates/e2e-playwright/playwright-config.sanity.ts.template +3 -3
  81. package/schematics/ng-add/playwright/templates/e2e-playwright/playwright-config.ts.template +3 -3
  82. package/schematics/ng-add/playwright/templates/e2e-playwright/scenarios/__name@dasherize__.e2e-playwright-spec.ts +2 -1
  83. package/schematics/ng-add/schema.d.ts +2 -0
  84. package/schematics/ng-add/schema.d.ts.map +1 -1
  85. package/schematics/ng-add/schema.json +5 -0
  86. package/schematics/ng-add/templates/project/jest.config.js.template +2 -2
  87. package/schematics/ng-add/templates/workspace/jest.config.ut.js.template +18 -11
  88. package/schematics/ng-update/v9-0/index.d.ts +1 -1
  89. package/schematics/ng-update/v9-0/index.d.ts.map +1 -1
  90. package/schematics/ng-update/v9-0/index.js +6 -2
  91. package/schematics/ng-update/v9-0/index.js.map +1 -1
  92. package/schematics/ng-update/v9-0/localization-imports/localization-imports.js +2 -2
  93. package/schematics/ng-update/v9-0/localization-imports/localization-imports.js.map +1 -1
  94. package/schematics/playwright/sanity/index.d.ts +1 -1
  95. package/schematics/playwright/sanity/index.d.ts.map +1 -1
  96. package/schematics/playwright/sanity/index.js +6 -2
  97. package/schematics/playwright/sanity/index.js.map +1 -1
  98. package/schematics/playwright/scenario/index.d.ts +1 -1
  99. package/schematics/playwright/scenario/index.d.ts.map +1 -1
  100. package/schematics/playwright/scenario/index.js +6 -2
  101. package/schematics/playwright/scenario/index.js.map +1 -1
  102. package/schematics/playwright/scenario/templates/__name@dasherize__.e2e-playwright-spec.ts +2 -1
  103. package/store/testable-select.js.map +1 -1
  104. package/tools/path-replacement/path-replacement.js.map +1 -1
  105. package/tools/protractor/fetch-manager/_fetch-manager.js.map +1 -1
  106. package/tools/protractor/post-message-interceptor/_post-message-interceptor.js.map +1 -1
  107. package/tools/protractor/post-message-interceptor/post-message-interceptor.js +4 -4
  108. package/tools/protractor/post-message-interceptor/post-message-interceptor.js.map +1 -1
  109. package/visual-test/utils.js.map +1 -1
  110. package/visual-test/visual-test.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,yCAAiE;AACjE,4CAAuD;AAGvD,sCAAyC;AACzC,qCAA8D;AAE9D,iCAAyC;AAIzC;;GAEG;AACH;IAME;;;;OAIG;IACH,6BAAY,WAAe;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,qDAAuB,GAAjC,UAAwD,MAAU,EAAE,QAAiB;QACnF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClE;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACa,8CAAgB,GAAhC,UAAuD,MAA8B,EAAE,OAAgB;;;;gBACrG,sBAAO,IAAA,qBAAW,EAAC,MAAM,EAAE,OAAO,CAAC;yBAChC,IAAI,CAAC,UAAC,EAAE;wBACP,IAAI,CAAC,EAAE,EAAE;4BACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;yBAClE;wBACD,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,EAAC;;;KACN;IAGD;;;;;;;;OAQG;IACa,8CAAgB,GAAhC,UACE,QAAgB,EAChB,kBAAsD,EACtD,OAIM;QAJN,wBAAA,EAAA,YAIM;;;;;;6BAG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AAC;wBAChG,qBAAM,IAAA,sBAAc,EAAC,SAAS,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;6BAE5C,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;4BACZ,MAAM,IAAI,yBAAiB,CAAC,wBAAwB,CAAC,CAAC;yBACvD;wBACD,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;4BAGhC,sBAAO,QAAQ,EAAC;;;;KACjB;IAED,kBAAkB;IACX,wCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB;IACX,8CAAgB,GAAvB;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;IACL,6CAAe,GAA5B,UAA6B,QAAgB,EAAE,QAAiB;;;;;;wBACxD,aAAa,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;wBAChE,qBAAM,CAAC,aAAa,IAAI,oBAAO,CAAC,CAAC,gBAAgB,CAAC,eAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAA;4BAA5E,sBAAO,CAAC,CAAC,SAAmE,CAAC,EAAC;;;;KAC/E;IACH,0BAAC;AAAD,CAAC,AAjND,IAiNC;AAjNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { browser, By, element, ElementFinder } from 'protractor';\nimport { FixtureUsageError } from '../../errors/index';\n\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\nimport { convertPromise } from './utils';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement?: V;\n\n /**\n * Root element of this fixture. Optional in a Protractor.\n * All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.\n * @param rootElement\n */\n constructor(rootElement?: V) {\n this.rootElement = rootElement;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param elemnt ElementProfile to test\n * @param _timeout specific timeout that will throw when reach\n */\n protected throwOnUndefinedElement<T extends O3rElement>(elemnt?: T, _timeout?: number): Promise<T> {\n if (!elemnt) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return Promise.resolve(elemnt);\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param elemnt ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(elemnt: Promise<T | undefined>, timeout?: number): Promise<T> {\n return withTimeout(elemnt, timeout)\n .then((el) => {\n if (!el) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return el;\n });\n }\n\n\n /**\n * Get the element associated to the selector if present\n * @param selector Selector to access the element\n * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options Options supported\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async queryWithOptions(\n selector: string,\n elementConstructor?: O3rElementConstructor<O3rElement>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<O3rElement | undefined> {\n let queryElement: O3rElement | undefined;\n if (options.index !== undefined) {\n queryElement = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n queryElement = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(queryElement, options.timeout);\n }\n return queryElement;\n }\n\n /**\n * Get text from the element associated to the given selector, or undefined if the element is not found or not visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async getText<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const getTextElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!getTextElement || !await getTextElement.isVisible()) {\n return;\n }\n return await getTextElement.getText();\n }\n\n /**\n * Check if the element associated to the given selector is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async isVisible<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<boolean> {\n const isVisibleElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n return !!isVisibleElement && await isVisibleElement.isVisible();\n }\n\n /**\n * Click on the element associated to the given selector if it exists and is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async click<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<void> {\n const clickElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!!clickElement && await clickElement.isVisible()) {\n await clickElement.click();\n }\n }\n\n /** @inheritdoc */\n public async query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const cssSelector = By.css(selector);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const isElPresent = await (sourceElement! || browser).isElementPresent(cssSelector);\n if (!isElPresent) {\n console.warn(`No component matching ${selector} found`);\n return;\n }\n const queriedElement = sourceElement ? sourceElement.element(cssSelector) : element(cssSelector);\n return returnType ? new returnType(queriedElement) : new O3rElement(queriedElement);\n }\n\n /** @inheritdoc */\n public async queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const item = (sourceElement || element).all(By.css(selector)).get(index);\n if (!(await item.isPresent())) {\n console.warn(`No component matching ${selector}:nth(${index}) found`);\n return;\n }\n return new (returnType || O3rElement)(item);\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n _timeout?: number\n ): Promise<(T | O3rElement)[] | K> {\n const pElements = (this.rootElement ? this.rootElement.sourceElement.all(By.css(selector)) : element.all(By.css(selector)))\n .filter((item) => typeof item !== 'undefined')\n .then((elf: ElementFinder[]) => elf.map((item) => (returnType ? new returnType(item) : new O3rElement(item))));\n const elements = await convertPromise(pElements);\n\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return Promise.resolve(group);\n }\n\n return elements;\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.rootElement;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{[componentName: string]: ComponentFixtureProfile[]}> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public async queryNotPresent(selector: string, _timeout?: number): Promise<boolean> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n return !(await (sourceElement || browser).isElementPresent(By.css(selector)));\n }\n}\n"]}
1
+ {"version":3,"file":"component-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/component-fixture.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,yCAAiE;AACjE,4CAAuD;AAGvD,sCAAyC;AACzC,qCAA8D;AAE9D,iCAAyC;AAIzC;;GAEG;AACH;IAME;;;;OAIG;IACH,6BAAY,WAAe;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,qDAAuB,GAAjC,UAAwD,MAAU,EAAE,QAAiB;QACnF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,OAAO,CAAC,OAAO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GAA5B,UAA6B,QAAgB,EAAE,QAAiB;;;;;;wBACxD,aAAa,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;wBAChE,qBAAM,CAAC,aAAa,IAAI,oBAAO,CAAC,CAAC,gBAAgB,CAAC,eAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAA;4BAA5E,sBAAO,CAAC,CAAC,SAAmE,CAAC,EAAC;;;;KAC/E;IACH,0BAAC;AAAD,CAAC,AAjND,IAiNC;AAjNY,kDAAmB","sourcesContent":["/* eslint-disable new-cap */\nimport { browser, By, element, ElementFinder } from 'protractor';\nimport { FixtureUsageError } from '../../errors/index';\n\nimport type { ComponentFixtureProfile } from '../component-fixture';\nimport { withTimeout } from '../helpers';\nimport { O3rElement, O3rElementConstructor } from './element';\nimport { O3rGroup, O3rGroupConstructor } from './group';\nimport { convertPromise } from './utils';\n\nexport type { ComponentFixtureProfile, Constructable, FixtureWithCustom } from '../component-fixture';\n\n/**\n * Implementation of the fixture dedicated to protractor, hence using the webdriver to interact with the dom.\n */\nexport class O3rComponentFixture<V extends O3rElement = O3rElement> implements ComponentFixtureProfile<V> {\n /**\n * DOM element linked to the fixture.\n */\n protected rootElement?: V;\n\n /**\n * Root element of this fixture. Optional in a Protractor.\n * All further queries will be applied to the element tree if any, otherwise they will be applied to the whole DOM.\n * @param rootElement\n */\n constructor(rootElement?: V) {\n this.rootElement = rootElement;\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param elemnt ElementProfile to test\n * @param _timeout specific timeout that will throw when reach\n */\n protected throwOnUndefinedElement<T extends O3rElement>(elemnt?: T, _timeout?: number): Promise<T> {\n if (!elemnt) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return Promise.resolve(elemnt);\n }\n\n /**\n * Throws an exception if the element is undefined.\n * Otherwise returns the element.\n * @param elemnt ElementProfile to test\n * @param timeout specific timeout that will throw when reach\n */\n protected async throwOnUndefined<T extends O3rElement>(elemnt: Promise<T | undefined>, timeout?: number): Promise<T> {\n return withTimeout(elemnt, timeout)\n .then((el) => {\n if (!el) {\n throw new Error('Element not found in ' + this.constructor.name);\n }\n return el;\n });\n }\n\n\n /**\n * Get the element associated to the selector if present\n * @param selector Selector to access the element\n * @param elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options Options supported\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async queryWithOptions(\n selector: string,\n elementConstructor?: O3rElementConstructor<O3rElement>,\n options: {\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}\n ): Promise<O3rElement | undefined> {\n let queryElement: O3rElement | undefined;\n if (options.index !== undefined) {\n queryElement = await this.queryNth(selector, options.index, elementConstructor as any);\n } else {\n queryElement = await this.query(selector, elementConstructor as any);\n }\n if (options.shouldThrowIfNotPresent) {\n return this.throwOnUndefinedElement<O3rElement>(queryElement, options.timeout);\n }\n return queryElement;\n }\n\n /**\n * Get text from the element associated to the given selector, or undefined if the element is not found or not visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async getText<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<string | undefined> {\n const getTextElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!getTextElement || !await getTextElement.isVisible()) {\n return;\n }\n return await getTextElement.getText();\n }\n\n /**\n * Check if the element associated to the given selector is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async isVisible<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<boolean> {\n const isVisibleElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n return !!isVisibleElement && await isVisibleElement.isVisible();\n }\n\n /**\n * Click on the element associated to the given selector if it exists and is visible\n * @param selector Selector to access the element\n * @param options Options supported\n * @param options.elementConstructor Constructor that will be used to create the Element, defaults to O3rElement\n * @param options.index index Select the element associated to the index\n * @param options.shouldThrowIfNotPresent If set to true the function will throw if the element is not present\n * @param options.timeout Duration to wait for the element to be present before it throws\n */\n protected async click<T extends O3rElement>(selector: string, options: {\n elementConstructor?: O3rElementConstructor<T> | undefined;\n index?: number;\n shouldThrowIfNotPresent?: boolean;\n timeout?: number;\n } = {}): Promise<void> {\n const clickElement = await this.queryWithOptions(selector, options.elementConstructor, options);\n if (!!clickElement && await clickElement.isVisible()) {\n await clickElement.click();\n }\n }\n\n /** @inheritdoc */\n public async query(selector: string, returnType?: undefined): Promise<O3rElement | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async query<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const cssSelector = By.css(selector);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const isElPresent = await (sourceElement! || browser).isElementPresent(cssSelector);\n if (!isElPresent) {\n console.warn(`No component matching ${selector} found`);\n return;\n }\n const queriedElement = sourceElement ? sourceElement.element(cssSelector) : element(cssSelector);\n return returnType ? new returnType(queriedElement) : new O3rElement(queriedElement);\n }\n\n /** @inheritdoc */\n public async queryNth(selector: string, index: number, returnType?: undefined): Promise<O3rElement | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T>): Promise<T | undefined>;\n public async queryNth<T extends O3rElement>(selector: string, index: number, returnType: O3rElementConstructor<T> | undefined): Promise<T | O3rElement | undefined> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n const item = (sourceElement || element).all(By.css(selector)).get(index);\n if (!(await item.isPresent())) {\n console.warn(`No component matching ${selector}:nth(${index}) found`);\n return;\n }\n return new (returnType || O3rElement)(item);\n }\n\n /** @inheritdoc */\n public async queryAll(_selector: string, _returnType?: undefined, groupType?: undefined, timeout?: number): Promise<O3rElement[]>;\n public async queryAll<T extends O3rElement>(selector: string, returnType: O3rElementConstructor<T>, groupType?: undefined, timeout?: number): Promise<T[]>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(selector: string, returnType: O3rElementConstructor<T>, groupType: O3rGroupConstructor<K, T>, timeout?: number): Promise<K>;\n public async queryAll<T extends O3rElement, K extends O3rGroup<T>>(\n selector: string,\n returnType: O3rElementConstructor<T> | undefined,\n groupType: O3rGroupConstructor<K, T> | undefined,\n _timeout?: number\n ): Promise<(T | O3rElement)[] | K> {\n const pElements = (this.rootElement ? this.rootElement.sourceElement.all(By.css(selector)) : element.all(By.css(selector)))\n .filter((item) => typeof item !== 'undefined')\n .then((elf: ElementFinder[]) => elf.map((item) => (returnType ? new returnType(item) : new O3rElement(item))));\n const elements = await convertPromise(pElements);\n\n if (groupType) {\n const group = new groupType(elements as T[]);\n const isValid = await group.isValidGroup();\n\n if (!isValid) {\n throw new FixtureUsageError('invalid group of items');\n }\n return Promise.resolve(group);\n }\n\n return elements;\n }\n\n /** @inheritdoc */\n public getElement() {\n return this.rootElement;\n }\n\n /** @inheritdoc */\n public getSubComponents(): Promise<{[componentName: string]: ComponentFixtureProfile[]}> {\n return Promise.resolve({block: [this]});\n }\n\n /** @inheritDoc */\n public async queryNotPresent(selector: string, _timeout?: number): Promise<boolean> {\n const sourceElement = this.rootElement && this.rootElement.sourceElement;\n return !(await (sourceElement || browser).isElementPresent(By.css(selector)));\n }\n}\n"]}
@@ -12,10 +12,10 @@ var O3rCheckboxElement = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritDoc */
15
- O3rCheckboxElement.prototype.check = function (value, associatedLabel) {
16
- if (value === void 0) { value = true; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ O3rCheckboxElement.prototype.check = function () {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (value, associatedLabel) {
18
17
  var currentValue;
18
+ if (value === void 0) { value = true; }
19
19
  return tslib_1.__generator(this, function (_a) {
20
20
  switch (_a.label) {
21
21
  case 0: return [4 /*yield*/, this.isChecked()];
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/checkbox-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAwC,8CAAU;IAChD,4BAAY,aAA4B;eACtC,kBAAM,aAAa,CAAC;IACtB,CAAC;IAED,kBAAkB;IACL,kCAAK,GAAlB,UAAmB,KAAY,EAAE,eAA4B;QAA1C,sBAAA,EAAA,YAAY;;;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE;4BAC1B,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;yBAC1B;wBAED,sBAAO,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACjE;IAED,kBAAkB;IACX,oCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,sCAAS,GAAtB;;;;;4BACgB,qBAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAA;;wBAA7C,KAAK,GAAG,SAAqC;wBACnD,sBAAO,KAAK,EAAC;;;;KACd;IACH,yBAAC;AAAD,CAAC,AAzBD,CAAwC,oBAAU,GAyBjD;AAzBY,gDAAkB","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {CheckboxElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rCheckboxElement extends O3rElement implements CheckboxElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true, associatedLabel?: O3rElement) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n return Promise.resolve();\n }\n\n return associatedLabel ? associatedLabel.click() : this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const value = await this.sourceElement.isSelected();\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"checkbox-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/checkbox-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAwC,8CAAU;IAChD,4BAAY,aAA4B;QACtC,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,kCAAK,GAAlB;oEAAmB,KAAY,EAAE,eAA4B;;YAA1C,sBAAA,EAAA,YAAY;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBAED,sBAAO,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACjE;IAED,kBAAkB;IACX,oCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,sCAAS,GAAtB;;;;;4BACgB,qBAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAA;;wBAA7C,KAAK,GAAG,SAAqC;wBACnD,sBAAO,KAAK,EAAC;;;;KACd;IACH,yBAAC;AAAD,CAAC,AAzBD,CAAwC,oBAAU,GAyBjD;AAzBY,gDAAkB","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {CheckboxElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rCheckboxElement extends O3rElement implements CheckboxElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true, associatedLabel?: O3rElement) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n return Promise.resolve();\n }\n\n return associatedLabel ? associatedLabel.click() : this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const value = await this.sourceElement.isSelected();\n return value;\n }\n}\n"]}
@@ -12,10 +12,10 @@ var O3rRadioElement = /** @class */ (function (_super) {
12
12
  return _super.call(this, sourceElement) || this;
13
13
  }
14
14
  /** @inheritDoc */
15
- O3rRadioElement.prototype.check = function (value) {
16
- if (value === void 0) { value = true; }
17
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ O3rRadioElement.prototype.check = function () {
16
+ return tslib_1.__awaiter(this, arguments, void 0, function (value) {
18
17
  var currentValue;
18
+ if (value === void 0) { value = true; }
19
19
  return tslib_1.__generator(this, function (_a) {
20
20
  switch (_a.label) {
21
21
  case 0: return [4 /*yield*/, this.isChecked()];
@@ -1 +1 @@
1
- {"version":3,"file":"radio-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/radio-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAA4B;eACtC,kBAAM,aAAa,CAAC;IACtB,CAAC;IAED,kBAAkB;IACL,+BAAK,GAAlB,UAAmB,KAAY;QAAZ,sBAAA,EAAA,YAAY;;;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE;4BAC1B,OAAO,CAAC,IAAI,CAAC,qCAA8B,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;yBAC1B;wBAED,sBAAO,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACrB;IAED,kBAAkB;IACX,iCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,mCAAS,GAAtB;;;;;4BACkB,qBAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA;;wBAA5C,OAAO,GAAG,SAAkC;wBAClD,sBAAO,OAAO,KAAK,SAAS,EAAC;;;;KAC9B;IACH,sBAAC;AAAD,CAAC,AA1BD,CAAqC,oBAAU,GA0B9C;AA1BY,0CAAe","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {RadioElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rRadioElement extends O3rElement implements RadioElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n console.warn(`O3rRadioElement is already ${value ? 'checked' : 'unchecked'}`);\n return Promise.resolve();\n }\n\n return this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const checked = await this.getAttribute('checked');\n return checked !== undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"radio-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/radio-element.ts"],"names":[],"mappings":";;;;AAEA,sCAAsC;AAEtC;;GAEG;AACH;IAAqC,2CAAU;IAC7C,yBAAY,aAA4B;QACtC,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,+BAAK,GAAlB;oEAAmB,KAAY;;YAAZ,sBAAA,EAAA,YAAY;;;4BACR,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAArC,YAAY,GAAG,SAAsB;wBAC3C,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;4BAC3B,OAAO,CAAC,IAAI,CAAC,qCAA8B,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAE,CAAC,CAAC;4BAC9E,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;wBAC3B,CAAC;wBAED,sBAAO,IAAI,CAAC,KAAK,EAAE,EAAC;;;;KACrB;IAED,kBAAkB;IACX,iCAAO,GAAd;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kBAAkB;IACL,mCAAS,GAAtB;;;;;4BACkB,qBAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA;;wBAA5C,OAAO,GAAG,SAAkC;wBAClD,sBAAO,OAAO,KAAK,SAAS,EAAC;;;;KAC9B;IACH,sBAAC;AAAD,CAAC,AA1BD,CAAqC,oBAAU,GA0B9C;AA1BY,0CAAe","sourcesContent":["import {ElementFinder} from 'protractor';\nimport {RadioElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\n/**\n * Implementation dedicated to karma / TestBed.\n */\nexport class O3rRadioElement extends O3rElement implements RadioElementProfile {\n constructor(sourceElement: ElementFinder) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async check(value = true) {\n const currentValue = await this.isChecked();\n if (currentValue === value) {\n console.warn(`O3rRadioElement is already ${value ? 'checked' : 'unchecked'}`);\n return Promise.resolve();\n }\n\n return this.click();\n }\n\n /** @inheritDoc */\n public uncheck() {\n return this.check(false);\n }\n\n /** @inheritDoc */\n public async isChecked(): Promise<boolean> {\n const checked = await this.getAttribute('checked');\n return checked !== undefined;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"select-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/select-element.ts"],"names":[],"mappings":";;;;AAAA,yCAA6C;AAE7C,sCAAsC;AAItC;;GAEG;AACH;IAAsC,4CAAU;IAC9C,0BAAY,aAAyC;eACnD,kBAAM,aAAa,CAAC;IACtB,CAAC;IAED,kBAAkB;IACL,wCAAa,GAA1B,UAA2B,KAAa,EAAE,QAAiB;;;;;4BACzD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,eAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAC7D,sBAAO,IAAI,oBAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,EAAC;;;;KACnD;IAED,kBAAkB;IACL,wCAAa,GAA1B,UAA2B,KAAa,EAAE,QAAiB;;;;;4BACzD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,eAAE,CAAC,GAAG,CAAC,wBAAiB,KAAK,OAAI,CAAC,CAAC,CAAC;wBAC9E,sBAAO,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAC;;;;KACvC;IACH,uBAAC;AAAD,CAAC,AAlBD,CAAsC,oBAAU,GAkB/C;AAlBY,4CAAgB","sourcesContent":["import {By, ElementFinder} from 'protractor';\nimport {SelectElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\nexport {SelectElementProfile} from '../../elements';\n\n/**\n * Implementation dedicated to Protractor.\n */\nexport class O3rSelectElement extends O3rElement implements SelectElementProfile {\n constructor(sourceElement: ElementFinder | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByIndex(index: number, _timeout?: number) {\n await this.click();\n const options = this.sourceElement.all(By.tagName('option'));\n return new O3rElement(options.get(index)).click();\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, _timeout?: number) {\n await this.click();\n const option = this.sourceElement.element(By.css(`option[value='${value}']`));\n return new O3rElement(option).click();\n }\n}\n"]}
1
+ {"version":3,"file":"select-element.js","sourceRoot":"","sources":["../../../../src/core/protractor/elements/select-element.ts"],"names":[],"mappings":";;;;AAAA,yCAA6C;AAE7C,sCAAsC;AAItC;;GAEG;AACH;IAAsC,4CAAU;IAC9C,0BAAY,aAAyC;QACnD,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,wCAAa,GAA1B,UAA2B,KAAa,EAAE,QAAiB;;;;;4BACzD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,eAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAC7D,sBAAO,IAAI,oBAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,EAAC;;;;KACnD;IAED,kBAAkB;IACL,wCAAa,GAA1B,UAA2B,KAAa,EAAE,QAAiB;;;;;4BACzD,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;wBAAlB,SAAkB,CAAC;wBACb,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,eAAE,CAAC,GAAG,CAAC,wBAAiB,KAAK,OAAI,CAAC,CAAC,CAAC;wBAC9E,sBAAO,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAC;;;;KACvC;IACH,uBAAC;AAAD,CAAC,AAlBD,CAAsC,oBAAU,GAkB/C;AAlBY,4CAAgB","sourcesContent":["import {By, ElementFinder} from 'protractor';\nimport {SelectElementProfile} from '../../elements';\nimport {O3rElement} from '../element';\n\nexport {SelectElementProfile} from '../../elements';\n\n/**\n * Implementation dedicated to Protractor.\n */\nexport class O3rSelectElement extends O3rElement implements SelectElementProfile {\n constructor(sourceElement: ElementFinder | O3rElement) {\n super(sourceElement);\n }\n\n /** @inheritdoc */\n public async selectByIndex(index: number, _timeout?: number) {\n await this.click();\n const options = this.sourceElement.all(By.tagName('option'));\n return new O3rElement(options.get(index)).click();\n }\n\n /** @inheritdoc */\n public async selectByValue(value: string, _timeout?: number) {\n await this.click();\n const option = this.sourceElement.element(By.css(`option[value='${value}']`));\n return new O3rElement(option).click();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../../src/core/protractor/groups/radio-group.ts"],"names":[],"mappings":";;;;AAEA,kCAAoC;AAEpC;;GAEG;AACH;IAAmC,yCAAyB;IAC1D,uBAAY,aAAgC;eAC1C,kBAAM,aAAa,CAAC;IACtB,CAAC;IAED,kBAAkB;IACL,oCAAY,GAAzB;;;;;;wBACM,IAAI,GAAG,EAAE,CAAC;8BAEe,EAAV,KAAA,IAAI,CAAC,KAAK;;;6BAAV,CAAA,cAAU,CAAA;wBAAlB,IAAI;wBACI,qBAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAChD,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE;4BACpC,OAAO,CAAC,IAAI,CAAC,uFAAgF,IAAI,kBAAQ,QAAQ,IAAI,WAAW,CAAE,CAAC,CAAC;4BACpI,sBAAO,KAAK,EAAC;yBACd;wBACD,IAAI,QAAQ,KAAK,SAAS,EAAE;4BAC1B,IAAI,GAAG,QAAQ,CAAC;yBACjB;;;wBARgB,IAAU,CAAA;;4BAW7B,sBAAO,IAAI,EAAC;;;;KACb;IAED;;OAEG;IACU,uCAAe,GAA5B;;;;;;8BAE+B,EAAV,KAAA,IAAI,CAAC,KAAK;;;6BAAV,CAAA,cAAU,CAAA;wBAAlB,IAAI;wBACM,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAAnC,UAAU,GAAG,SAAsB;wBACzC,IAAI,UAAU,EAAE;4BACd,sBAAO,IAAI,EAAC;yBACb;;;wBAJgB,IAAU,CAAA;;4BAO7B,sBAAO,SAAS,EAAC;;;;KAClB;IACH,oBAAC;AAAD,CAAC,AArCD,CAAmC,gBAAQ,GAqC1C;AArCY,sCAAa","sourcesContent":["import { RadioGroupProfile } from '../../groups/radio-group';\nimport { O3rRadioElement } from '../elements/radio-element';\nimport { O3rGroup } from '../group';\n\n/**\n * Group element to manage a radio group\n */\nexport class O3rRadioGroup extends O3rGroup<O3rRadioElement> implements RadioGroupProfile {\n constructor(sourceElement: O3rRadioElement[]) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async isValidGroup() {\n let name = '';\n\n for (const item of this.items) {\n const itemName = await item.getAttribute('name');\n if (name !== '' && name !== itemName) {\n console.warn(`Items in this radio group are not consistent, incompatible input names found ${name} and ${itemName || 'undefined'}`);\n return false;\n }\n if (itemName !== undefined) {\n name = itemName;\n }\n }\n\n return true;\n }\n\n /**\n * Get the selected radio\n */\n public async getSelectedItem() {\n\n for (const item of this.items) {\n const isSelected = await item.isChecked();\n if (isSelected) {\n return item;\n }\n }\n\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../../src/core/protractor/groups/radio-group.ts"],"names":[],"mappings":";;;;AAEA,kCAAoC;AAEpC;;GAEG;AACH;IAAmC,yCAAyB;IAC1D,uBAAY,aAAgC;QAC1C,OAAA,MAAK,YAAC,aAAa,CAAC,SAAC;IACvB,CAAC;IAED,kBAAkB;IACL,oCAAY,GAAzB;;;;;;wBACM,IAAI,GAAG,EAAE,CAAC;8BAEe,EAAV,KAAA,IAAI,CAAC,KAAK;;;6BAAV,CAAA,cAAU,CAAA;wBAAlB,IAAI;wBACI,qBAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAChD,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;4BACrC,OAAO,CAAC,IAAI,CAAC,uFAAgF,IAAI,kBAAQ,QAAQ,IAAI,WAAW,CAAE,CAAC,CAAC;4BACpI,sBAAO,KAAK,EAAC;wBACf,CAAC;wBACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;4BAC3B,IAAI,GAAG,QAAQ,CAAC;wBAClB,CAAC;;;wBARgB,IAAU,CAAA;;4BAW7B,sBAAO,IAAI,EAAC;;;;KACb;IAED;;OAEG;IACU,uCAAe,GAA5B;;;;;;8BAE+B,EAAV,KAAA,IAAI,CAAC,KAAK;;;6BAAV,CAAA,cAAU,CAAA;wBAAlB,IAAI;wBACM,qBAAM,IAAI,CAAC,SAAS,EAAE,EAAA;;wBAAnC,UAAU,GAAG,SAAsB;wBACzC,IAAI,UAAU,EAAE,CAAC;4BACf,sBAAO,IAAI,EAAC;wBACd,CAAC;;;wBAJgB,IAAU,CAAA;;4BAO7B,sBAAO,SAAS,EAAC;;;;KAClB;IACH,oBAAC;AAAD,CAAC,AArCD,CAAmC,gBAAQ,GAqC1C;AArCY,sCAAa","sourcesContent":["import { RadioGroupProfile } from '../../groups/radio-group';\nimport { O3rRadioElement } from '../elements/radio-element';\nimport { O3rGroup } from '../group';\n\n/**\n * Group element to manage a radio group\n */\nexport class O3rRadioGroup extends O3rGroup<O3rRadioElement> implements RadioGroupProfile {\n constructor(sourceElement: O3rRadioElement[]) {\n super(sourceElement);\n }\n\n /** @inheritDoc */\n public async isValidGroup() {\n let name = '';\n\n for (const item of this.items) {\n const itemName = await item.getAttribute('name');\n if (name !== '' && name !== itemName) {\n console.warn(`Items in this radio group are not consistent, incompatible input names found ${name} and ${itemName || 'undefined'}`);\n return false;\n }\n if (itemName !== undefined) {\n name = itemName;\n }\n }\n\n return true;\n }\n\n /**\n * Get the selected radio\n */\n public async getSelectedItem() {\n\n for (const item of this.items) {\n const isSelected = await item.isChecked();\n if (isSelected) {\n return item;\n }\n }\n\n return undefined;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"page-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/page-fixture.ts"],"names":[],"mappings":";;;;AAAA,yCAAmC;AAEnC,yDAAwD;AAExD,iCAAuC;AAIvC;;GAEG;AACH;IAAuE,0CAAsB;IAC3F,wBAAY,WAAe;eACzB,kBAAM,WAAW,CAAC;IACpB,CAAC;IAEM,iCAAQ,GAAf;QACE,OAAO,IAAA,sBAAc,EAAC,oBAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IACH,qBAAC;AAAD,CAAC,AARD,CAAuE,uCAAmB,GAQzF;AARY,wCAAc","sourcesContent":["import {browser} from 'protractor';\nimport {PageFixtureProfile} from '../page-fixture';\nimport {O3rComponentFixture} from './component-fixture';\nimport {O3rElement} from './element';\nimport {convertPromise} from './utils';\n\nexport {PageFixtureProfile} from '../page-fixture';\n\n/**\n * Implementation of the page fixture dedicated to protractor.\n */\nexport class O3rPageFixture<V extends O3rElement = O3rElement> extends O3rComponentFixture<V> implements PageFixtureProfile<V> {\n constructor(rootElement?: V) {\n super(rootElement);\n }\n\n public getTitle() {\n return convertPromise(browser.getTitle());\n }\n}\n"]}
1
+ {"version":3,"file":"page-fixture.js","sourceRoot":"","sources":["../../../src/core/protractor/page-fixture.ts"],"names":[],"mappings":";;;;AAAA,yCAAmC;AAEnC,yDAAwD;AAExD,iCAAuC;AAIvC;;GAEG;AACH;IAAuE,0CAAsB;IAC3F,wBAAY,WAAe;QACzB,OAAA,MAAK,YAAC,WAAW,CAAC,SAAC;IACrB,CAAC;IAEM,iCAAQ,GAAf;QACE,OAAO,IAAA,sBAAc,EAAC,oBAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IACH,qBAAC;AAAD,CAAC,AARD,CAAuE,uCAAmB,GAQzF;AARY,wCAAc","sourcesContent":["import {browser} from 'protractor';\nimport {PageFixtureProfile} from '../page-fixture';\nimport {O3rComponentFixture} from './component-fixture';\nimport {O3rElement} from './element';\nimport {convertPromise} from './utils';\n\nexport {PageFixtureProfile} from '../page-fixture';\n\n/**\n * Implementation of the page fixture dedicated to protractor.\n */\nexport class O3rPageFixture<V extends O3rElement = O3rElement> extends O3rComponentFixture<V> implements PageFixtureProfile<V> {\n constructor(rootElement?: V) {\n super(rootElement);\n }\n\n public getTitle() {\n return convertPromise(browser.getTitle());\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fixture-usage-error.js","sourceRoot":"","sources":["../../src/errors/fixture-usage-error.ts"],"names":[],"mappings":";;;;AAAA;;GAEG;AACH;IAAuC,6CAAK;IAC1C,2BAAY,OAA+B;QAA/B,wBAAA,EAAA,+BAA+B;QAA3C,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;;IAClC,CAAC;IACH,wBAAC;AAAD,CAAC,AALD,CAAuC,KAAK,GAK3C;AALY,8CAAiB","sourcesContent":["/**\n * Exception to indicate that a fixture is being used with invalid parameters.\n */\nexport class FixtureUsageError extends Error {\n constructor(message = 'Fixture usage error') {\n super(message);\n this.name = 'FixtureUsageError';\n }\n}\n"]}
1
+ {"version":3,"file":"fixture-usage-error.js","sourceRoot":"","sources":["../../src/errors/fixture-usage-error.ts"],"names":[],"mappings":";;;;AAAA;;GAEG;AACH;IAAuC,6CAAK;IAC1C,2BAAY,OAA+B;QAA/B,wBAAA,EAAA,+BAA+B;QACzC,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QACf,KAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;;IAClC,CAAC;IACH,wBAAC;AAAD,CAAC,AALD,CAAuC,KAAK,GAK3C;AALY,8CAAiB","sourcesContent":["/**\n * Exception to indicate that a fixture is being used with invalid parameters.\n */\nexport class FixtureUsageError extends Error {\n constructor(message = 'Fixture usage error') {\n super(message);\n this.name = 'FixtureUsageError';\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transpilation-purpose-only.js","sourceRoot":"","sources":["../../src/errors/transpilation-purpose-only.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH;IAAmD,yDAAK;IACtD,uCAAY,OAAsC;QAAtC,wBAAA,EAAA,sCAAsC;QAAlD,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;;IACzC,CAAC;IACH,oCAAC;AAAD,CAAC,AALD,CAAmD,KAAK,GAKvD;AALY,sEAA6B","sourcesContent":["/**\n * Exception to indicate that the code run is for transpilation purpose only.\n * It should not be used during runtime process\n */\nexport class TranspilationPurposeOnlyError extends Error {\n constructor(message = 'Transpilation purpose only') {\n super(message);\n this.name = 'TranspilationPurposeOnly';\n }\n}\n"]}
1
+ {"version":3,"file":"transpilation-purpose-only.js","sourceRoot":"","sources":["../../src/errors/transpilation-purpose-only.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH;IAAmD,yDAAK;IACtD,uCAAY,OAAsC;QAAtC,wBAAA,EAAA,sCAAsC;QAChD,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QACf,KAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;;IACzC,CAAC;IACH,oCAAC;AAAD,CAAC,AALD,CAAmD,KAAK,GAKvD;AALY,sEAA6B","sourcesContent":["/**\n * Exception to indicate that the code run is for transpilation purpose only.\n * It should not be used during runtime process\n */\nexport class TranspilationPurposeOnlyError extends Error {\n constructor(message = 'Transpilation purpose only') {\n super(message);\n this.name = 'TranspilationPurposeOnly';\n }\n}\n"]}
@@ -8,11 +8,11 @@ var temporal_polyfill_1 = require("temporal-polyfill");
8
8
  * @param mock the mock instance provided by the hook method of Kassette
9
9
  * @param inputOptions default options will extract ISO strings and use 'day-offset' mode
10
10
  */
11
- function updateDatesInMocks(mock, inputOptions) {
12
- var _a, _b;
13
- if (inputOptions === void 0) { inputOptions = {}; }
14
- return tslib_1.__awaiter(this, void 0, void 0, function () {
15
- var plainDateLength, options, todayTime, replaceDatesInInput, checksum, _c, localPayload, referenceTime, timeOffset_1, replaceDatesInOutput, wrappedPayload;
11
+ function updateDatesInMocks(mock_1) {
12
+ return tslib_1.__awaiter(this, arguments, void 0, function (mock, inputOptions) {
13
+ var plainDateLength, options, todayTime, replaceDatesInInput, checksum, _a, localPayload, referenceTime, timeOffset_1, replaceDatesInOutput, wrappedPayload;
14
+ var _b, _c;
15
+ if (inputOptions === void 0) { inputOptions = {}; }
16
16
  return tslib_1.__generator(this, function (_d) {
17
17
  switch (_d.label) {
18
18
  case 0:
@@ -53,17 +53,17 @@ function updateDatesInMocks(mock, inputOptions) {
53
53
  case 1:
54
54
  checksum = _d.sent();
55
55
  mock.setLocalPath([mock.localPath, checksum]);
56
- _c = /get|post/.test(mock.request.method);
57
- if (!_c) return [3 /*break*/, 3];
56
+ _a = /get|post/.test(mock.request.method);
57
+ if (!_a) return [3 /*break*/, 3];
58
58
  return [4 /*yield*/, mock.hasLocalMock()];
59
59
  case 2:
60
- _c = (_d.sent());
60
+ _a = (_d.sent());
61
61
  _d.label = 3;
62
62
  case 3:
63
- if (!_c) return [3 /*break*/, 6];
63
+ if (!_a) return [3 /*break*/, 6];
64
64
  return [4 /*yield*/, mock.readLocalPayload()];
65
65
  case 4:
66
- localPayload = (_a = (_d.sent())) === null || _a === void 0 ? void 0 : _a.payload;
66
+ localPayload = (_b = (_d.sent())) === null || _b === void 0 ? void 0 : _b.payload;
67
67
  if (!(localPayload && localPayload.data.creationDateTime)) return [3 /*break*/, 6];
68
68
  referenceTime = temporal_polyfill_1.Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));
69
69
  timeOffset_1 = temporal_polyfill_1.Temporal.PlainDate.from(referenceTime).until(todayTime, { smallestUnit: 'days', largestUnit: 'days' });
@@ -83,7 +83,7 @@ function updateDatesInMocks(mock, inputOptions) {
83
83
  };
84
84
  wrappedPayload = mock.createPayload({
85
85
  data: localPayload.data,
86
- body: replaceDatesInOutput(((_b = localPayload.body) === null || _b === void 0 ? void 0 : _b.toString()) || '')
86
+ body: replaceDatesInOutput(((_c = localPayload.body) === null || _c === void 0 ? void 0 : _c.toString()) || '')
87
87
  });
88
88
  mock.fillResponseFromPayload(wrappedPayload);
89
89
  return [4 /*yield*/, mock.sendResponse()];
@@ -1 +1 @@
1
- {"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;;;AACA,uDAA2C;AAiC3C;;;;GAIG;AACH,SAAsB,kBAAkB,CAAC,IAAW,EAAE,YAAqD;;IAArD,6BAAA,EAAA,iBAAqD;;;;;;oBACnG,eAAe,GAAG,qBAAqB,CAAC,MAAM,CAAC;oBAC/C,OAAO,sBACX,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,6BAA6B,EACxC,SAAS,EAAE;4BACT,QAAQ,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,EAA7C,CAA6C;4BACjE,MAAM,EAAE,UAAC,KAAK;gCACZ,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gCAC1D,OAAO,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC;oCACrC,4BAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,UAAG,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EC","sourcesContent":["import type {IMock} from '@amadeus-it-group/kassette';\nimport {Temporal} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options: UpdateDatesInMocksOptions = {\n mode: 'day-offset',\n extractor: /\\b(\\d{4}-\\d{2}-\\d{2})[^\"]*/g,\n converter: {\n fromDate: (date) => date.toString().substring(0, plainDateLength),\n toDate: (input) => {\n input = input.replace(/\\.\\d+/, '').replace(/Z/, '+00:00');\n return input.length > plainDateLength ?\n Temporal.ZonedDateTime.from(`${input.replace(/(\\.\\d+)/, '')}[${input.replace(/^.*(\\+\\d{2}:\\d{2}).*$/, '$1') || '+00:00'}]`) :\n Temporal.PlainDate.from(input);\n }\n },\n ...inputOptions\n };\n const todayTime = Temporal.Now.plainDateISO();\n\n // Update request\n const replaceDatesInInput = (input: string): string => {\n switch (options.mode) {\n case 'any': {\n return input.replace(options.extractor, '<any>');\n }\n case 'day-offset': {\n return input.replace(options.extractor, (match) => `<t+${Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);\n }\n case 'same-day-of-week': {\n return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);\n }\n }\n return input;\n };\n const checksum = await mock.checksum({\n headers: false,\n body: {filter: (body) => replaceDatesInInput(body.toString())},\n query: {filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)]))},\n customData: {updateDatesMode: options.mode}\n });\n mock.setLocalPath([mock.localPath, checksum]);\n\n // Update response\n if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {\n const localPayload = (await mock.readLocalPayload())?.payload;\n if (localPayload && localPayload.data.creationDateTime) {\n const referenceTime = Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));\n const timeOffset = Temporal.PlainDate.from(referenceTime).until(todayTime, {smallestUnit: 'days', largestUnit: 'days'});\n if (timeOffset.days !== 0) {\n mock.setMode('manual');\n const replaceDatesInOutput = (output: string): string => {\n switch (options.mode) {\n case 'any':\n case 'day-offset': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));\n }\n case 'same-day-of-week': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));\n }\n }\n return output;\n };\n const wrappedPayload = mock.createPayload({\n data: localPayload.data,\n body: replaceDatesInOutput(localPayload.body?.toString() || '')\n });\n mock.fillResponseFromPayload(wrappedPayload);\n await mock.sendResponse();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"update-dates-in-mocks.js","sourceRoot":"","sources":["../../src/kassette/update-dates-in-mocks.ts"],"names":[],"mappings":";;;;AACA,uDAA2C;AAiC3C;;;;GAIG;AACH,SAAsB,kBAAkB;gEAAC,IAAW,EAAE,YAAqD;;;Q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O,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,CAAC,YAAU,CAAC,IAAI,GAAG,CAAC,CAAC,MAAG,CAAC,CAAC,EAAtG,CAAsG,CAAC,CAAC;4BAC9J,CAAC;wBACH,CAAC;wBACD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC;oBACI,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;wBACxC,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,IAAI,EAAE,oBAAoB,CAAC,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC;qBAChE,CAAC,CAAC;oBACH,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;oBAC7C,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;oBAAzB,SAAyB,CAAC;;;;;;CAIjC;AAtED,gDAsEC","sourcesContent":["import type {IMock} from '@amadeus-it-group/kassette';\nimport {Temporal} from 'temporal-polyfill';\n\n/**\n * Options to be passed to `updateDatesInMocks`\n */\nexport interface UpdateDatesInMocksOptions {\n /**\n * 'any': dates in inputs will be ignored when computing checksum, the dates on the output will be updated to keep the same day offset\n * 'day-offset': dates in inputs will be converted to day offsets, the dates on the output will be updated to keep the same day offset\n * 'same-day-of-week': dates in inputs will be converted to day of week, the dates on the output will be updated to keep the same day of week but increment the week\n */\n mode: 'any' | 'day-offset' | 'same-day-of-week';\n /**\n * RegExp used to extract dates from request and response\n */\n extractor: RegExp;\n /**\n * Functions to be used to convert from Temporal objects to strings, and strings to temporal objects\n */\n converter: {\n /**\n * Converter from Temporal to string\n * @param input\n */\n fromDate: (input: Temporal.ZonedDateTime | Temporal.PlainDate) => string;\n /**\n * Converter from string to Temporal\n * @param input\n */\n toDate: (input: string) => Temporal.ZonedDateTime | Temporal.PlainDate;\n };\n}\n\n/**\n * Update mock checksum and response body to keep using the same mocks every day with updated dates\n * @param mock the mock instance provided by the hook method of Kassette\n * @param inputOptions default options will extract ISO strings and use 'day-offset' mode\n */\nexport async function updateDatesInMocks(mock: IMock, inputOptions: Partial<UpdateDatesInMocksOptions> = {}) {\n const plainDateLength = 'YYYY-MM-DDThh:mm:ss'.length;\n const options: UpdateDatesInMocksOptions = {\n mode: 'day-offset',\n extractor: /\\b(\\d{4}-\\d{2}-\\d{2})[^\"]*/g,\n converter: {\n fromDate: (date) => date.toString().substring(0, plainDateLength),\n toDate: (input) => {\n input = input.replace(/\\.\\d+/, '').replace(/Z/, '+00:00');\n return input.length > plainDateLength ?\n Temporal.ZonedDateTime.from(`${input.replace(/(\\.\\d+)/, '')}[${input.replace(/^.*(\\+\\d{2}:\\d{2}).*$/, '$1') || '+00:00'}]`) :\n Temporal.PlainDate.from(input);\n }\n },\n ...inputOptions\n };\n const todayTime = Temporal.Now.plainDateISO();\n\n // Update request\n const replaceDatesInInput = (input: string): string => {\n switch (options.mode) {\n case 'any': {\n return input.replace(options.extractor, '<any>');\n }\n case 'day-offset': {\n return input.replace(options.extractor, (match) => `<t+${Temporal.PlainDate.from(todayTime).until(options.converter.toDate(match)).toString()}>`);\n }\n case 'same-day-of-week': {\n return input.replace(options.extractor, (match) => `<day ${options.converter.toDate(match).dayOfWeek} next week>`);\n }\n }\n return input;\n };\n const checksum = await mock.checksum({\n headers: false,\n body: {filter: (body) => replaceDatesInInput(body.toString())},\n query: {filter: (params) => Object.fromEntries(Object.entries(params).map(([key, value]) => [key, replaceDatesInInput(value)]))},\n customData: {updateDatesMode: options.mode}\n });\n mock.setLocalPath([mock.localPath, checksum]);\n\n // Update response\n if (/get|post/.test(mock.request.method) && (await mock.hasLocalMock())) {\n const localPayload = (await mock.readLocalPayload())?.payload;\n if (localPayload && localPayload.data.creationDateTime) {\n const referenceTime = Temporal.PlainDate.from(localPayload.data.creationDateTime.toISOString().substring(0, 10));\n const timeOffset = Temporal.PlainDate.from(referenceTime).until(todayTime, {smallestUnit: 'days', largestUnit: 'days'});\n if (timeOffset.days !== 0) {\n mock.setMode('manual');\n const replaceDatesInOutput = (output: string): string => {\n switch (options.mode) {\n case 'any':\n case 'day-offset': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(timeOffset)));\n }\n case 'same-day-of-week': {\n return output.replace(options.extractor, (match) => options.converter.fromDate(options.converter.toDate(match).add(`P${Math.ceil(timeOffset.days / 7)}W`)));\n }\n }\n return output;\n };\n const wrappedPayload = mock.createPayload({\n data: localPayload.data,\n body: replaceDatesInOutput(localPayload.body?.toString() || '')\n });\n mock.fillResponseFromPayload(wrappedPayload);\n await mock.sendResponse();\n }\n }\n }\n}\n"]}
@@ -3,8 +3,11 @@ import { LocalizationConfiguration, LocalizationModule } from '@o3r/localization
3
3
  export declare class TranslatePipeMock implements PipeTransform {
4
4
  transform(...args: any[]): string | undefined;
5
5
  }
6
+ export declare class O3rTranslatePipeMock implements PipeTransform {
7
+ transform(...args: any[]): string | undefined;
8
+ }
6
9
  export declare class LocalizationDependencyMocks {
7
- static forTest(): ModuleWithProviders<LocalizationDependencyMocks>;
10
+ static forTest(pipeWithPrefix?: boolean): ModuleWithProviders<LocalizationDependencyMocks>;
8
11
  }
9
12
  /** Mock to provide to the MockTranslation module */
10
13
  export interface MockTranslations {
@@ -15,10 +18,11 @@ export interface MockTranslations {
15
18
  /**
16
19
  * Function to get the list of modules required to test component using Localization module
17
20
  * @param localizationConfiguration Localization configuration
18
- * @param translations Translations to use
19
- * @param translationCompilerProvider
20
- * @param mockPipe Enable Translation pipe mocking
21
- * @returns List of modules to import in your TestBed
21
+ * @param translations Translations to use
22
+ * @param translationCompilerProvider Provider for translations compiler
23
+ * @param mockPipe Enable translation pipe mocking
24
+ * @param pipeWithPrefix Enable pipe with prefix
25
+ * @returns List of modules to import in the TestBed
22
26
  */
23
- export declare function mockTranslationModules(localizationConfiguration?: Partial<LocalizationConfiguration>, translations?: MockTranslations, translationCompilerProvider?: Provider, mockPipe?: boolean): ModuleWithProviders<LocalizationModule>[];
27
+ export declare function mockTranslationModules(localizationConfiguration?: Partial<LocalizationConfiguration>, translations?: MockTranslations, translationCompilerProvider?: Provider, mockPipe?: boolean, pipeWithPrefix?: boolean): ModuleWithProviders<LocalizationModule>[];
24
28
  //# sourceMappingURL=localization-mock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localization-mock.d.ts","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAkB,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAA6B,MAAM,mBAAmB,CAAC;AAU7G,qBACa,iBAAkB,YAAW,aAAa;IAC9C,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED,qBAIa,2BAA2B;WACxB,OAAO,IAAI,mBAAmB,CAAC,2BAA2B,CAAC;CAM1E;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,yBAAyB,GAAE,OAAO,CAAC,yBAAyB,CAAoC,EAChG,YAAY,GAAE,gBAAqB,EACnC,2BAA2B,CAAC,EAAE,QAAQ,EACtC,QAAQ,UAAQ,GACf,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,CAc3C"}
1
+ {"version":3,"file":"localization-mock.d.ts","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAkB,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAA6B,MAAM,mBAAmB,CAAC;AAU7G,qBACa,iBAAkB,YAAW,aAAa;IAC9C,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED,qBACa,oBAAqB,YAAW,aAAa;IACjD,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,SAAS;CAGrD;AAED,qBAIa,2BAA2B;WACxB,OAAO,CAAC,cAAc,UAAQ,GAAG,mBAAmB,CAAC,2BAA2B,CAAC;CAMhG;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,yBAAyB,GAAE,OAAO,CAAC,yBAAyB,CAAoC,EAChG,YAAY,GAAE,gBAAqB,EACnC,2BAA2B,CAAC,EAAE,QAAQ,EACtC,QAAQ,UAAQ,EAChB,cAAc,UAAQ,GACrB,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,CAc3C"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mockTranslationModules = exports.LocalizationDependencyMocks = exports.TranslatePipeMock = void 0;
3
+ exports.mockTranslationModules = exports.LocalizationDependencyMocks = exports.O3rTranslatePipeMock = exports.TranslatePipeMock = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var core_1 = require("@angular/core");
6
6
  var core_2 = require("@ngx-translate/core");
@@ -28,21 +28,38 @@ var TranslatePipeMock = /** @class */ (function () {
28
28
  return TranslatePipeMock;
29
29
  }());
30
30
  exports.TranslatePipeMock = TranslatePipeMock;
31
+ var O3rTranslatePipeMock = /** @class */ (function () {
32
+ function O3rTranslatePipeMock() {
33
+ }
34
+ O3rTranslatePipeMock.prototype.transform = function () {
35
+ var args = [];
36
+ for (var _i = 0; _i < arguments.length; _i++) {
37
+ args[_i] = arguments[_i];
38
+ }
39
+ return args && args.map(function (arg) { return JSON.parse(arg); }).join(', ');
40
+ };
41
+ O3rTranslatePipeMock = tslib_1.__decorate([
42
+ (0, core_1.Pipe)({ name: 'o3rTranslate' })
43
+ ], O3rTranslatePipeMock);
44
+ return O3rTranslatePipeMock;
45
+ }());
46
+ exports.O3rTranslatePipeMock = O3rTranslatePipeMock;
31
47
  var LocalizationDependencyMocks = /** @class */ (function () {
32
48
  function LocalizationDependencyMocks() {
33
49
  }
34
50
  LocalizationDependencyMocks_1 = LocalizationDependencyMocks;
35
- LocalizationDependencyMocks.forTest = function () {
51
+ LocalizationDependencyMocks.forTest = function (pipeWithPrefix) {
52
+ if (pipeWithPrefix === void 0) { pipeWithPrefix = false; }
36
53
  return {
37
54
  ngModule: LocalizationDependencyMocks_1,
38
- providers: [{ provide: localization_1.LocalizationTranslatePipe, useClass: TranslatePipeMock }]
55
+ providers: [{ provide: localization_1.LocalizationTranslatePipe, useClass: pipeWithPrefix ? O3rTranslatePipeMock : TranslatePipeMock }]
39
56
  };
40
57
  };
41
58
  var LocalizationDependencyMocks_1;
42
59
  LocalizationDependencyMocks = LocalizationDependencyMocks_1 = tslib_1.__decorate([
43
60
  (0, core_1.NgModule)({
44
- declarations: [TranslatePipeMock],
45
- exports: [TranslatePipeMock]
61
+ declarations: [TranslatePipeMock, O3rTranslatePipeMock],
62
+ exports: [TranslatePipeMock, O3rTranslatePipeMock]
46
63
  })
47
64
  ], LocalizationDependencyMocks);
48
65
  return LocalizationDependencyMocks;
@@ -51,15 +68,17 @@ exports.LocalizationDependencyMocks = LocalizationDependencyMocks;
51
68
  /**
52
69
  * Function to get the list of modules required to test component using Localization module
53
70
  * @param localizationConfiguration Localization configuration
54
- * @param translations Translations to use
55
- * @param translationCompilerProvider
56
- * @param mockPipe Enable Translation pipe mocking
57
- * @returns List of modules to import in your TestBed
71
+ * @param translations Translations to use
72
+ * @param translationCompilerProvider Provider for translations compiler
73
+ * @param mockPipe Enable translation pipe mocking
74
+ * @param pipeWithPrefix Enable pipe with prefix
75
+ * @returns List of modules to import in the TestBed
58
76
  */
59
- function mockTranslationModules(localizationConfiguration, translations, translationCompilerProvider, mockPipe) {
77
+ function mockTranslationModules(localizationConfiguration, translations, translationCompilerProvider, mockPipe, pipeWithPrefix) {
60
78
  if (localizationConfiguration === void 0) { localizationConfiguration = defaultLocalizationConfiguration; }
61
79
  if (translations === void 0) { translations = {}; }
62
80
  if (mockPipe === void 0) { mockPipe = false; }
81
+ if (pipeWithPrefix === void 0) { pipeWithPrefix = false; }
63
82
  return tslib_1.__spreadArray([
64
83
  localization_1.LocalizationModule.forRoot(function () { return localizationConfiguration; }),
65
84
  core_2.TranslateModule.forRoot({
@@ -71,7 +90,7 @@ function mockTranslationModules(localizationConfiguration, translations, transla
71
90
  },
72
91
  compiler: translationCompilerProvider
73
92
  })
74
- ], (mockPipe ? [LocalizationDependencyMocks.forTest()] : []), true);
93
+ ], (mockPipe ? [LocalizationDependencyMocks.forTest(pipeWithPrefix)] : []), true);
75
94
  }
76
95
  exports.mockTranslationModules = mockTranslationModules;
77
96
  //# sourceMappingURL=localization-mock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"localization-mock.js","sourceRoot":"","sources":["../../src/localization/localization-mock.ts"],"names":[],"mappings":";;;;AAAA,sCAA6F;AAC7F,4CAAuE;AACvE,kDAA6G;AAC7G,6BAA0B;AAE1B,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,CAA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CAAC,CAAC,CAAC,EAAE,CAAC,QAC5D;AACJ,CAAC;AAnBD,wDAmBC","sourcesContent":["import { ModuleWithProviders, NgModule, Pipe, PipeTransform, Provider } from '@angular/core';\nimport { TranslateLoader, TranslateModule } from '@ngx-translate/core';\nimport { LocalizationConfiguration, LocalizationModule, LocalizationTranslatePipe } from '@o3r/localization';\nimport { of } 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@NgModule({\n declarations: [TranslatePipeMock],\n exports: [TranslatePipeMock]\n})\nexport class LocalizationDependencyMocks {\n public static forTest(): ModuleWithProviders<LocalizationDependencyMocks> {\n return {\n ngModule: LocalizationDependencyMocks,\n providers: [{ provide: LocalizationTranslatePipe, useClass: 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\n * @param mockPipe Enable Translation pipe mocking\n * @returns List of modules to import in your TestBed\n */\nexport function mockTranslationModules(\n localizationConfiguration: Partial<LocalizationConfiguration> = defaultLocalizationConfiguration,\n translations: MockTranslations = {},\n translationCompilerProvider?: Provider,\n mockPipe = 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()] : [])\n ];\n}\n"]}
1
+ {"version":3,"file":"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sBAAsB;QAC1C,OAAO;YACL,QAAQ,EAAE,6BAA2B;YACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,wCAAyB,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;SACzH,CAAC;IACJ,CAAC;;IANU,2BAA2B;QAJvC,IAAA,eAAQ,EAAC;YACR,YAAY,EAAE,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;YACvD,OAAO,EAAE,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;SACnD,CAAC;OACW,2BAA2B,CAOvC;IAAD,kCAAC;CAAA,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;AApBD,wDAoBC","sourcesContent":["import { ModuleWithProviders, NgModule, Pipe, PipeTransform, Provider } from '@angular/core';\nimport { TranslateLoader, TranslateModule } from '@ngx-translate/core';\nimport { LocalizationConfiguration, LocalizationModule, LocalizationTranslatePipe } from '@o3r/localization';\nimport { of } 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 +1 @@
1
- {"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;;;AAAA,sCAA0E;AAC1E,wCAAmD;AAEnD,+BAAiC;AAEjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,WAAoB,EAAE,SAAuB,EAAE,MAAqB;IACrF,IAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACtG,IAAI,eAAe,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE;QACzC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;KAC3B;SAAM;QACL,IAAI,MAAwB,CAAC;QAC7B,WAAW,CAAC,YAAY,CAAC,UAAC,IAAI;YAC5B,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;gBACzB,MAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAC7B;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAI,CAAC;KACb;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,UAAmB,EAAE,MAAqB;IACzD,IAA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AC;IACpD,IAAM,IAAI;QAKR;YAAA,iBAQC;YAPC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;iBACjB,OAAO,CAAC,UAAC,UAAU,IAAK,OAAC,KAAY,CAAC,UAAU,CAAC,GAAG,IAAI,mBAAY,EAAO,EAAnD,CAAmD,CAAC,CAAC;YAChF,IAAI,MAAM,IAAI,MAAM,CAAC,sBAAsB,EAAE;gBAC3C,IAAI,CAAC,UAAU,GAAG,cAAQ,CAAC,CAAC;gBAC5B,IAAI,CAAC,gBAAgB,GAAG,cAAQ,CAAC,CAAC;gBAClC,IAAI,CAAC,iBAAiB,GAAG,cAAQ,CAAC,CAAC;aACpC;QACH,CAAC;QACH,cAAC;IAAD,CAAC,AAdY,GAcZ,CAAC;IAEF,OAAO,IAAA,gBAAS,qBACd,QAAQ,EAAE,MAAM,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,EACzC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,EAC3C,MAAM,QAAA,EACN,OAAO,SAAA,IACJ,CAAC,MAAM,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAC7C,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,yBAAiB;gBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;gBACnC,KAAK,EAAE,IAAI;aACZ;SACF;KACF,CAAC,CAAC,CAAC,EAAE,EACN,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC;AAvCD,sDAuCC","sourcesContent":["import { Component, EventEmitter, forwardRef, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Input/.test(node.getText(source));\n}\n\n/**\n * Determine if the node in an output field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Output/.test(node.getText(source));\n}\n\n/**\n * Get the name of the input / output\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(Input|Ouput) *\\( *(['\"](.*)['\"])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/['\"]/ig, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * ```typescript\n * // hero.component.ts\n * \\@Component({selector: 'hero'})\n * class HeroComponent {\n * \\@Input() name: string;\n * \\@Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.component.ts') {}\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport function generateMockComponent<T extends unknown = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => { };\n this.registerOnChange = () => { };\n this.registerOnTouched = () => { };\n }\n }\n };\n\n return Component({\n template: config && config.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor) ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n } : {}\n })(mock) as Type<T>;\n}\n"]}
1
+ {"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;;;AAAA,sCAA0E;AAC1E,wCAAmD;AAEnD,+BAAiC;AAEjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,WAAoB,EAAE,SAAuB,EAAE,MAAqB;IACrF,IAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACtG,IAAI,eAAe,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,IAAI,MAAwB,CAAC;QAC7B,WAAW,CAAC,YAAY,CAAC,UAAC,IAAI;YAC5B,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,MAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,UAAmB,EAAE,MAAqB;IACzD,IAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAM,MAAM,GA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AA,KAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAA3C,OAAO,aAAA,EAAE,MAAM,YAA4B,CAAC;IACpD,IAAM,IAAI;QAKR;YAAA,iBAQC;YAPC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;iBACjB,OAAO,CAAC,UAAC,UAAU,IAAK,OAAC,KAAY,CAAC,UAAU,CAAC,GAAG,IAAI,mBAAY,EAAO,EAAnD,CAAmD,CAAC,CAAC;YAChF,IAAI,MAAM,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAC5C,IAAI,CAAC,UAAU,GAAG,cAAQ,CAAC,CAAC;gBAC5B,IAAI,CAAC,gBAAgB,GAAG,cAAQ,CAAC,CAAC;gBAClC,IAAI,CAAC,iBAAiB,GAAG,cAAQ,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QACH,cAAC;IAAD,CAAC,AAdY,GAcZ,CAAC;IAEF,OAAO,IAAA,gBAAS,qBACd,QAAQ,EAAE,MAAM,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,EACzC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,EAC3C,MAAM,QAAA,EACN,OAAO,SAAA,IACJ,CAAC,MAAM,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAC7C,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,yBAAiB;gBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;gBACnC,KAAK,EAAE,IAAI;aACZ;SACF;KACF,CAAC,CAAC,CAAC,EAAE,EACN,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC;AAvCD,sDAuCC","sourcesContent":["import { Component, EventEmitter, forwardRef, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Input/.test(node.getText(source));\n}\n\n/**\n * Determine if the node in an output field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && /^@Output/.test(node.getText(source));\n}\n\n/**\n * Get the name of the input / output\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(Input|Ouput) *\\( *(['\"](.*)['\"])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/['\"]/ig, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * ```typescript\n * // hero.component.ts\n * \\@Component({selector: 'hero'})\n * class HeroComponent {\n * \\@Input() name: string;\n * \\@Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.component.ts') {}\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport function generateMockComponent<T extends unknown = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => { };\n this.registerOnChange = () => { };\n this.registerOnTouched = () => { };\n }\n }\n };\n\n return Component({\n template: config && config.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor) ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n } : {}\n })(mock) as Type<T>;\n}\n"]}