{"version":3,"file":"aposin-ng-aquila-dropdown-testing.mjs","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","../../../projects/ng-aquila/src/dropdown/testing/aposin-ng-aquila-dropdown-testing.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) => HarnessPredicate.stringMatches(harness.getText(), text))\n            .addOption('isSelected', options.isSelected, async (harness, isSelected) => (await harness.isSelected()) === isSelected);\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('label', options.label, (harness, label) =>\n            HarnessPredicate.stringMatches(harness.getLabel(), label),\n        );\n    }\n\n    private _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 { type BaseHarnessFilters, HarnessPredicate, parallel, TestKey } from '@angular/cdk/testing';\nimport { NxFormfieldControlHarness } from '@aposin/ng-aquila/formfield/testing/control';\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) => HarnessPredicate.stringMatches(harness.getValueText(), text))\n            .addOption('readonly', options.readonly, async (harness, readonly) => (await harness.isReadonly()) === readonly)\n            .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n    }\n\n    private documentRootLocator = this.documentRootLocatorFactory();\n    private _panelBodyQuery = `.nx-dropdown__panel-body`;\n    private _valueText = this.locatorFor('.nx-dropdown__rendered');\n    private _trigger = this.locatorFor('.nx-dropdown__container');\n    private _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(filter?: Omit<NxDropdownItemFilters, 'ancestor'>): 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(filter?: Omit<NxDropdownGroupHarnessFilters, 'ancestor'>): 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 = (await parallel(() => unfilteredItems.map(o => o.getText()))).join(', ');\n            throw Error(`Select does not have options matching the specified filter, available items: ${unfilteredItemTexts}.`);\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAOM,MAAO,qBAAsB,SAAQ,gBAAgB,CAAA;aAChD,IAAY,CAAA,YAAA,GAAG,kBAAkB,CAAC;AAEzC,IAAA,OAAO,IAAI,CAAC,OAAA,GAAiC,EAAE,EAAA;AAC3C,QAAA,OAAO,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,OAAO;aACrD,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC;aAC1G,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,OAAO,EAAE,UAAU,KAAK,CAAC,MAAM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