{"version":3,"file":"ngx-com-components-dialog-testing.mjs","sources":["../../../projects/com/components/dialog/testing/dialog.harness.ts","../../../projects/com/components/dialog/testing/index.ts","../../../projects/com/components/dialog/testing/ngx-com-components-dialog-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 ComDialogContainerHarness. */\nexport type ComDialogContainerHarnessFilters = BaseHarnessFilters;\n\n/**\n * Harness for interacting with a dialog container in tests.\n *\n * Because dialogs render inside a CDK overlay (outside the component tree),\n * obtain this harness via `TestbedHarnessEnvironment.documentRootLoader(fixture)`.\n */\nexport class ComDialogContainerHarness extends ComponentHarness {\n  static hostSelector = 'com-dialog-container';\n\n  private readonly panel = this.locatorFor('[role=\"dialog\"], [role=\"alertdialog\"]');\n  private readonly titleEl = this.locatorForOptional('[comDialogTitle]');\n  private readonly contentEl = this.locatorForOptional('[comDialogContent]');\n  private readonly actionsEl = this.locatorForOptional('[comDialogActions]');\n  private readonly closeButton = this.locatorForOptional('[comDialogClose]');\n\n  /**\n   * Gets a HarnessPredicate for matching dialog containers.\n   * @param options Filter options.\n   */\n  static with(\n    options: ComDialogContainerHarnessFilters = {},\n  ): HarnessPredicate<ComDialogContainerHarness> {\n    return new HarnessPredicate(ComDialogContainerHarness, options);\n  }\n\n  /** Gets the dialog panel's `aria-label` attribute. */\n  async getAriaLabel(): Promise<string | null> {\n    const el = await this.panel();\n    return el.getAttribute('aria-label');\n  }\n\n  /** Gets the dialog panel's `aria-labelledby` attribute. */\n  async getAriaLabelledby(): Promise<string | null> {\n    const el = await this.panel();\n    return el.getAttribute('aria-labelledby');\n  }\n\n  /** Gets the dialog panel's `aria-describedby` attribute. */\n  async getAriaDescribedby(): Promise<string | null> {\n    const el = await this.panel();\n    return el.getAttribute('aria-describedby');\n  }\n\n  /** Gets the role attribute on the dialog panel. */\n  async getRole(): Promise<string | null> {\n    const el = await this.panel();\n    return el.getAttribute('role');\n  }\n\n  /** Gets the text content of the `[comDialogTitle]` element, or null if none exists. */\n  async getTitleText(): Promise<string | null> {\n    const el = await this.titleEl();\n    return el ? el.text() : null;\n  }\n\n  /** Gets the text content of the `[comDialogContent]` element, or null if none exists. */\n  async getContentText(): Promise<string | null> {\n    const el = await this.contentEl();\n    return el ? el.text() : null;\n  }\n\n  /** Gets the text content of the `[comDialogActions]` element, or null if none exists. */\n  async getActionsText(): Promise<string | null> {\n    const el = await this.actionsEl();\n    return el ? el.text() : null;\n  }\n\n  /** Gets the `data-state` attribute on the dialog panel. */\n  async getState(): Promise<string | null> {\n    const el = await this.panel();\n    return el.getAttribute('data-state');\n  }\n\n  /**\n   * Closes the dialog by clicking the `[comDialogClose]` button.\n   * Throws if no close button is found.\n   */\n  async close(): Promise<void> {\n    const btn = await this.closeButton();\n    if (!btn) {\n      throw new Error(\n        'Could not find a [comDialogClose] element. ' +\n          'Make sure the dialog template includes a button with the comDialogClose directive.',\n      );\n    }\n    await btn.click();\n  }\n\n  /** Sends an Escape key press to the dialog panel to close it. */\n  async sendEscapeKey(): Promise<void> {\n    const el = await this.panel();\n    await el.sendKeys(TestKey.ESCAPE);\n  }\n\n  /** Whether the dialog container is disabled. */\n  async isDisabled(): Promise<boolean> {\n    const host = await this.host();\n    return (await host.getAttribute('aria-disabled')) === 'true';\n  }\n\n  /** Whether the dialog panel is focused. */\n  async isFocused(): Promise<boolean> {\n    const el = await this.panel();\n    return el.isFocused();\n  }\n\n  /** Focuses the dialog panel. */\n  async focus(): Promise<void> {\n    const el = await this.panel();\n    return el.focus();\n  }\n\n  /** Blurs the dialog panel. */\n  async blur(): Promise<void> {\n    const el = await this.panel();\n    return el.blur();\n  }\n}\n","// Testing utilities for the dialog component\n\nexport { ComDialogContainerHarness } from './dialog.harness';\n\nexport type { ComDialogContainerHarnessFilters } from './dialog.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":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