{"version":3,"file":"allianz-ng-aquila-dropdown-testing.mjs","names":[],"sources":["../../../projects/ng-aquila/src/dropdown/testing/nx-dropdown-item-harness.ts","../../../projects/ng-aquila/src/dropdown/testing/nx-dropdown-group-harness.ts","../../../projects/ng-aquila/src/dropdown/testing/nx-dropdown-harness.ts"],"sourcesContent":["import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nexport interface NxDropdownItemFilters extends BaseHarnessFilters {\n  text?: string | RegExp;\n  isSelected?: boolean;\n}\n\nexport class NxDropdownItemHarness extends ComponentHarness {\n  static hostSelector = 'nx-dropdown-item';\n\n  static with(options: NxDropdownItemFilters = {}) {\n    return new HarnessPredicate(NxDropdownItemHarness, options)\n      .addOption('text', options.text, (harness, text) =>\n        HarnessPredicate.stringMatches(harness.getText(), text),\n      )\n      .addOption(\n        'isSelected',\n        options.isSelected,\n        async (harness, isSelected) => (await harness.isSelected()) === isSelected,\n      );\n  }\n\n  /** Click the option */\n  async click(): Promise<void> {\n    return (await this.host()).click();\n  }\n\n  /** Get the option's label text */\n  async getText(): Promise<string> {\n    return (await this.host()).text();\n  }\n\n  /** Get whether the option is disabled */\n  async isDisabled(): Promise<boolean> {\n    return (await this.host()).hasClass('nx-dropdown-item--disabled');\n  }\n\n  /** Get whether the option is selected */\n  async isSelected(): Promise<boolean> {\n    return (await this.host()).hasClass('nx-selected');\n  }\n\n  /** Get whether the option is active */\n  async isActive(): Promise<boolean> {\n    return (await this.host()).hasClass('nx-dropdown-item--active');\n  }\n\n  /** Get whether the option is in multiselect mode */\n  async isMultiple(): Promise<boolean> {\n    return (await this.host()).hasClass('nx-multiselect');\n  }\n}\n","import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport { NxDropdownItemFilters, NxDropdownItemHarness } from './nx-dropdown-item-harness';\n\nexport interface NxDropdownGroupHarnessFilters extends BaseHarnessFilters {\n  label?: string | RegExp;\n}\n\nexport class NxDropdownGroupHarness extends ComponentHarness {\n  static hostSelector = 'nx-dropdown-group';\n\n  static with(options: NxDropdownGroupHarnessFilters = {}) {\n    return new HarnessPredicate(NxDropdownGroupHarness, options).addOption(\n      'label',\n      options.label,\n      (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label),\n    );\n  }\n\n  private readonly _label = this.locatorFor('.nx-dropdown-results__group-label');\n\n  async getLabel(): Promise<string> {\n    return (await this._label()).text();\n  }\n\n  async getItems(filter?: NxDropdownItemFilters): Promise<NxDropdownItemHarness[]> {\n    return this.locatorForAll(NxDropdownItemHarness.with(filter))();\n  }\n}\n","import { NxFormfieldControlHarness } from '@allianz/ng-aquila/formfield/testing/control';\nimport { type BaseHarnessFilters, HarnessPredicate, parallel, TestKey } from '@angular/cdk/testing';\n\nimport { NxDropdownGroupHarness, NxDropdownGroupHarnessFilters } from './nx-dropdown-group-harness';\nimport { NxDropdownItemFilters, NxDropdownItemHarness } from './nx-dropdown-item-harness';\n\nexport interface NxDropdownFilters extends BaseHarnessFilters {\n  /** Text is either the placeholder, or the currently selected value */\n  valueText?: string | RegExp;\n  readonly?: boolean;\n  disabled?: boolean;\n}\n\nexport class NxDropdownHarness extends NxFormfieldControlHarness {\n  static hostSelector = 'nx-dropdown';\n\n  static with(options: NxDropdownFilters = {}) {\n    return new HarnessPredicate(NxDropdownHarness, options)\n      .addOption('valueText', options.valueText, (harness, text) =>\n        HarnessPredicate.stringMatches(harness.getValueText(), text),\n      )\n      .addOption(\n        'readonly',\n        options.readonly,\n        async (harness, readonly) => (await harness.isReadonly()) === readonly,\n      )\n      .addOption(\n        'disabled',\n        options.disabled,\n        async (harness, disabled) => (await harness.isDisabled()) === disabled,\n      );\n  }\n\n  private readonly documentRootLocator = this.documentRootLocatorFactory();\n  private readonly _panelBodyQuery = `.nx-dropdown__panel-body`;\n  private readonly _valueText = this.locatorFor('.nx-dropdown__rendered');\n  private readonly _trigger = this.locatorFor('.nx-dropdown__container');\n  private readonly _filter = this.documentRootLocator.locatorFor(`.nx-dropdown__filter-input`);\n\n  /** Get the current value text when dropdown is not empty */\n  async getValueText(): Promise<string> {\n    return (await this._valueText()).text();\n  }\n\n  async isDisabled(): Promise<boolean> {\n    return (await this.host()).hasClass('nx-dropdown--disabled');\n  }\n\n  async isReadonly(): Promise<boolean> {\n    return (await this.host()).hasClass('is-readonly');\n  }\n\n  async focus(): Promise<void> {\n    return (await this.host()).focus();\n  }\n\n  async blur(): Promise<void> {\n    return (await this.host()).blur();\n  }\n\n  async isFocused(): Promise<boolean> {\n    const newVar = await this.host();\n    newVar.matchesSelector(':focus-within');\n    return newVar.isFocused();\n  }\n\n  async isEmpty(): Promise<boolean> {\n    return (await (await this.host()).hasClass('is-filled')) === false;\n  }\n\n  async isOpen(): Promise<boolean> {\n    return !!(await this.documentRootLocator.locatorForOptional(this._panelBodyQuery)());\n  }\n\n  async open(): Promise<void> {\n    if (!(await this.isOpen())) {\n      (await this._trigger()).click();\n      await this.waitForTasksOutsideAngular();\n    }\n  }\n\n  /** Close the dropdown if it is opened */\n  async close(): Promise<void> {\n    if (await this.isOpen()) {\n      return (await this.host()).sendKeys(TestKey.ESCAPE);\n    }\n  }\n\n  /** Get items inside the dropdown panel. Only returns items when the panel body is opened */\n  async getItems(\n    filter?: Omit<NxDropdownItemFilters, 'ancestor'>,\n  ): Promise<NxDropdownItemHarness[]> {\n    return this.documentRootLocator.locatorForAll(\n      // There is currently no way to specifically get this dropdown's panel body, so multiple instances of the dropdown harness could\n      NxDropdownItemHarness.with({ ...(filter ?? {}), ancestor: '.nx-dropdown__panel-body' }),\n    )();\n  }\n\n  async getGroups(\n    filter?: Omit<NxDropdownGroupHarnessFilters, 'ancestor'>,\n  ): Promise<NxDropdownGroupHarness[]> {\n    return this.documentRootLocator.locatorForAll(\n      // There is currently no way to specifically get this dropdown's panel body, so multiple instances of the dropdown harness could\n      NxDropdownGroupHarness.with({ ...(filter ?? {}), ancestor: '.nx-dropdown__panel-body' }),\n    )();\n  }\n\n  /** Open the dropdown and click the first item matching the filter */\n  async clickItem(filter?: NxDropdownItemFilters): Promise<void> {\n    await this.open();\n    const items = await this.documentRootLocator.locatorForAll(\n      // There is currently no way to specifically get this dropdown's panel body, but per implementation there should only be one in total\n      NxDropdownItemHarness.with({ ...(filter ?? {}), ancestor: '.nx-dropdown__panel-body' }),\n    )();\n\n    if (items.length === 0) {\n      const unfilteredItems = await this.getItems();\n      const unfilteredItemTexts = (\n        await parallel(() => unfilteredItems.map((o) => o.getText()))\n      ).join(', ');\n      throw Error(\n        `Select does not have options matching the specified filter, available items: ${unfilteredItemTexts}.`,\n      );\n    }\n\n    await items[0].click();\n    // Wait for focus to be restored to dropdown host after select\n    // This is necessary as long as setTimeout is used in the implementation\n    await this.waitForTasksOutsideAngular();\n    await this.forceStabilize();\n  }\n\n  /** Get whether the dropdown has a filter input. The dropdown panel must be open */\n  async hasFilter(): Promise<boolean> {\n    return !!(await this._filter());\n  }\n\n  /** Get the current filter value. The dropdown panel must be open */\n  async getFilterValue(): Promise<string> {\n    const filter = await this._filter();\n    return (await filter.getProperty('value')) ?? '';\n  }\n\n  /** Set the filter value. The dropdown panel must be open */\n  async setFilterValue(value: string): Promise<void> {\n    const filter = await this._filter();\n    await filter.clear();\n\n    if (value.length > 0) {\n      await filter.sendKeys(value);\n    }\n  }\n}\n"],"mappings":";;AAOA,IAAa,wBAAb,MAAa,8BAA8B,iBAAgB;CAClD;EAAA,KAAA,eAAe;CAAmB;CAEzC,OAAO,KAAK,UAAiC,CAAA,GAAE;EAC7C,OAAO,IAAI,iBAAiB,uBAAuB,OAAO,CAAC,CACxD,UAAU,QAAQ,QAAQ,OAAO,SAAS,SACzC,iBAAiB,cAAc,QAAQ,QAAO,GAAI,IAAI,CAAC,CACxD,CACA,UACC,cACA,QAAQ,YACR,OAAO,SAAS,eAAgB,MAAM,QAAQ,WAAU,MAAQ,UAAU;CAEhF;CAGA,MAAM,QAAK;EACT,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,MAAK;CAClC;CAG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