{"version":3,"file":"ngx-com-components-popover-testing.mjs","sources":["../../../projects/com/components/popover/testing/popover.harness.ts","../../../projects/com/components/popover/testing/index.ts","../../../projects/com/components/popover/testing/ngx-com-components-popover-testing.ts"],"sourcesContent":["import {\n  ComponentHarness,\n  HarnessPredicate,\n  TestKey,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComPopoverContentHarness. */\nexport type ComPopoverContentHarnessFilters = BaseHarnessFilters;\n\n/** Harness filters for ComPopoverTriggerHarness. */\nexport interface ComPopoverTriggerHarnessFilters extends BaseHarnessFilters {\n  /** Filter by the trigger element's text. */\n  text?: string | RegExp;\n}\n\n/**\n * Harness for interacting with popover content in tests.\n * This harness targets the `com-popover-content` element rendered in the overlay.\n */\nexport class ComPopoverContentHarness extends ComponentHarness {\n  static hostSelector = 'com-popover-content';\n\n  private readonly dialogPanel = this.locatorFor('[role=\"dialog\"]');\n\n  /**\n   * Gets a HarnessPredicate for matching popover content.\n   * @param options Filter options.\n   */\n  static with(options: ComPopoverContentHarnessFilters = {}): HarnessPredicate<ComPopoverContentHarness> {\n    return new HarnessPredicate(ComPopoverContentHarness, options);\n  }\n\n  /** Gets the popover dialog panel's aria-label. */\n  async getAriaLabel(): Promise<string | null> {\n    const panel = await this.dialogPanel();\n    return panel.getAttribute('aria-label');\n  }\n\n  /** Gets the text content of the popover dialog panel. */\n  async getText(): Promise<string> {\n    const panel = await this.dialogPanel();\n    return panel.text();\n  }\n\n  /** Gets the `data-side` attribute from the popover wrapper. */\n  async getSide(): Promise<string | null> {\n    const wrapper = await this.locatorFor('[data-side]')();\n    return wrapper.getAttribute('data-side');\n  }\n\n  /** Gets the `data-state` attribute from the popover wrapper. */\n  async getState(): Promise<string | null> {\n    const wrapper = await this.locatorFor('[data-state]')();\n    return wrapper.getAttribute('data-state');\n  }\n}\n\n/**\n * Harness for interacting with a popover trigger in tests.\n */\nexport class ComPopoverTriggerHarness extends ComponentHarness {\n  static hostSelector = '[comPopoverTrigger]';\n\n  private readonly documentRootLocator = this.documentRootLocatorFactory();\n\n  /**\n   * Gets a HarnessPredicate for matching popover triggers.\n   * @param options Filter options.\n   */\n  static with(options: ComPopoverTriggerHarnessFilters = {}): HarnessPredicate<ComPopoverTriggerHarness> {\n    return new HarnessPredicate(ComPopoverTriggerHarness, options)\n      .addOption('text', options.text, async (harness, text) => {\n        const triggerText = await harness.getText();\n        return HarnessPredicate.stringMatches(triggerText, text);\n      });\n  }\n\n  /** Gets the trigger element's text. */\n  async getText(): Promise<string> {\n    const host = await this.host();\n    return host.text();\n  }\n\n  /** Whether the popover is currently open. */\n  async isOpen(): Promise<boolean> {\n    const host = await this.host();\n    return (await host.getAttribute('aria-expanded')) === 'true';\n  }\n\n  /** Opens the popover if it's closed. */\n  async open(): Promise<void> {\n    if (!(await this.isOpen())) {\n      const host = await this.host();\n      await host.click();\n    }\n  }\n\n  /** Closes the popover if it's open. */\n  async close(): Promise<void> {\n    if (await this.isOpen()) {\n      const host = await this.host();\n      await host.sendKeys(TestKey.ESCAPE);\n    }\n  }\n\n  /** Toggles the popover open/close state by clicking the trigger. */\n  async toggle(): Promise<void> {\n    const host = await this.host();\n    return host.click();\n  }\n\n  /** Gets the popover content harness, or null if the popover is closed. */\n  async getPopoverContent(): Promise<ComPopoverContentHarness | null> {\n    if (!(await this.isOpen())) {\n      return null;\n    }\n    return this.documentRootLocator.locatorForOptional(ComPopoverContentHarness.with({}))();\n  }\n\n  /** Focuses the trigger element. */\n  async focus(): Promise<void> {\n    const host = await this.host();\n    return host.focus();\n  }\n\n  /** Blurs the trigger element. */\n  async blur(): Promise<void> {\n    const host = await this.host();\n    return host.blur();\n  }\n\n  /** Whether the trigger element is focused. */\n  async isFocused(): Promise<boolean> {\n    const host = await this.host();\n    return host.isFocused();\n  }\n}\n","// Testing utilities for the popover component\n\nexport {\n  ComPopoverContentHarness,\n  ComPopoverTriggerHarness,\n} from './popover.harness';\n\nexport type {\n  ComPopoverContentHarnessFilters,\n  ComPopoverTriggerHarnessFilters,\n} from './popover.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAgBA;;;AAGG;AACG,MAAO,wBAAyB,SAAQ,gBAAgB,CAAA;AAC5D,IAAA,OAAO,YAAY,GAAG,qBAAqB;AAE1B,IAAA,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;AAEjE;;;AAGG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GAA2C,EAAE,EAAA;AACvD,QAAA,OAAO,IAAI,gBAAgB,CAAC,wBAAwB,EAAE,OAAO,CAAC;IAChE;;AAGA,IAAA,MAAM,YAAY,GAAA;AAChB,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE;AACtC,QAAA,OAAO,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC;IACzC;;AAGA,IAAA,MAAM,OAAO,GAAA;AACX,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE;AACtC,QAAA,OAAO,KAAK,CAAC,IAAI,EAAE;IACrB;;AAGA,IAAA,MAAM,OAAO,GAAA;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;AACtD,QAAA,OAAO,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;IAC1C;;AAGA,IAAA,MAAM,QAAQ,GAAA;QACZ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;AACvD,QAAA,OAAO,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC;IAC3C;;AAGF;;AAEG;AACG,MAAO,wBAAyB,SAAQ,gBAAgB,CAAA;AAC5D,IAAA,OAAO,YAAY,GAAG,qBAAqB;AAE1B,IAAA,mBAAmB,GAAG,IAAI,CAAC,0BAA0B,EAAE;AAExE;;;AAGG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GA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