import { test as base } from './coverage-fixture'; import type { Locator, Page } from '@playwright/test'; import type { E2ELocator } from '@stencil/playwright'; export interface SetupOptions { html: string; } /** * Loads the given markup into the Stencil dev-server page and installs the `TectonElements.loc` * mock, then waits for the network to settle. * * CALL AT MOST ONCE PER TEST. `@stencil/playwright`'s `setContent()` serves the markup by * `page.route()`-ing the dev-server base URL and then `page.goto('#')`. Because the page * is already sitting on that exact URL after the first call, a second call is a same-document * navigation — it resolves successfully but the document is never replaced, so the new markup is * silently ignored and the previous test state (including any properties already assigned) stays * live. * * The `TectonElements.loc` mock is installed via `addInitScript()`, BEFORE `setContent()` * navigates, for the same reason `setTestStrings()` is: any prop baked into `options.html` itself * (e.g. a `chart-name` attribute) can trigger a component's first-render `loc()` call as part of * that same navigation, before a plain post-navigation `page.evaluate()` would get a chance to run. * Installing the mock first closes that race regardless of whether the caller sets a translatable * prop via the initial HTML or via a later property assignment. * * Any `setTestStrings()` call must come BEFORE this, since the loc mock resolves keys against * `window.TEST_STRINGS` from the component's first render onward. * * @param page The Playwright Page instance to load. * @param options.html The markup to place in the document body. */ export declare function setup(page: Page, options: SetupOptions): Promise; /** * Seeds `window.TEST_STRINGS`, the lookup table `setup()`'s `TectonElements.loc` mock reads from. * * MUST be called BEFORE `setup()`. `@stencil/playwright`'s `setContent()` performs a real * `page.goto()` against the dev server, so anything assigned onto `window` beforehand is * discarded on navigation. `addInitScript()` survives it — it re-runs on every new document, so * the strings are in place before the component's first render reads them. * * @param page The Playwright Page instance to seed. * @param strings The loc key/value pairs the `loc()` mock should resolve. */ export declare function setTestStrings(page: Page, strings: Record): Promise; /** * Returns `page.locator(selector)` typed as `@stencil/playwright`'s `E2ELocator`, which adds * `spyOnEvent(eventName)`, the element-scoped equivalent of `page.spyOnEvent()`. * * Upstream typing bug, not a coverage-fixture artifact: `@stencil/playwright` * really does patch `spyOnEvent` onto every locator its `page` fixture hands out at runtime, but * the type never surfaces. Its `E2EPage` interface re-declares `locator` as a *property* while * `Page` declares it as a *method*, so on the resulting `Page & E2EPage` the base method signature * wins and the inferred return type is a plain `Locator` with no `spyOnEvent`. (Reproducible with * `@stencil/playwright`'s own bare `test` export, so nothing in this repo causes it.) Page-scoped * `page.spyOnEvent()` is unaffected and can be used directly. Keeping the cast here means one * documented workaround instead of a cast at every call site. * * @param page The Playwright Page instance to query. * @param selector CSS selector for the element (Playwright's CSS engine pierces open shadow roots, * so the legacy Stencil `>>>` combinator is not needed). * @returns The locator, typed with `spyOnEvent()`. */ export declare function e2eLocator(page: Page, selector: string): E2ELocator; /** * Simulates a browser-native paste of `pastedValue` into the given field. * * Dispatches a real `ClipboardEvent('paste', { clipboardData })` (built from an in-page * `DataTransfer`, so `event.clipboardData.getData('text')` resolves exactly like a real paste) at * `fieldSelector`. Then, unless `hostSelector`'s `type` attribute is `currency` (where the * component itself fully handles the paste and calls `preventDefault()`), it also simulates the * browser's own default paste action — which a scripted event does not trigger — by appending * `pastedValue` onto the field's current value and firing a plain `input` event. * * Needed because Playwright's own `Locator.dispatchEvent()` has no 'paste' * entry in its built-in event-type map (unmapped types fall back to a plain `Event`, which cannot * carry a `clipboardData` property — see e.g. q2-message's migration notes for the same gap on * other unmapped event names). * * @param page The Playwright Page instance. * @param hostSelector CSS selector for the custom element whose `type` attribute decides whether * the paste is already fully handled in-component (e.g. `type="currency"` on `q2-input`). * @param fieldSelector CSS selector (may pierce shadow roots) for the actual input/field element * to dispatch the paste event at. * @param pastedValue The text to simulate pasting. */ export declare function dispatchPaste(page: Page, hostSelector: string, fieldSelector: string, pastedValue: string): Promise; /** * Returns the `test-id` attribute of the currently focused element, descending one shadow root if * the top-level active element itself hosts one (e.g. a custom element whose internal focusable * node is what actually has focus). * * @param page The Playwright Page instance to query. * @returns The focused element's `test-id` attribute, or `null` if it has none. */ export declare function getActiveElementTestId(page: Page): Promise; /** * Returns the given attribute of the currently focused element, descending one shadow root if the * top-level active element itself hosts one (same descent rule as `getActiveElementTestId()`). * * @param page The Playwright Page instance to query. * @param attribute The attribute name to read off the focused element. * @returns The focused element's attribute value, or `null` if it has none. */ export declare function getFocusedAttribute(page: Page, attribute: string): Promise; /** * Waits for a focused `q2-option` to appear, then returns its `value` attribute. * * @param page The Playwright Page instance to query. * @returns The focused `q2-option`'s `value` attribute. */ export declare function getFocusedOptionValue(page: Page): Promise; /** * Resolves a slot by descending through shadow roots (one `querySelector` per selector, piercing * into the next element's shadow root each time), then returns how many elements are assigned to * it, mirroring `HTMLSlotElement.assignedElements().length`. * * @param page The Playwright Page instance to query. * @param selectors A single selector, or an ordered chain of selectors where each one is resolved * inside the previous element's shadow root. * @returns The number of assigned elements, or `undefined` if the resolved node isn't a slot (or * doesn't exist). */ export declare function getNestedAssignedElementLength(page: Page, selectors: string | string[]): Promise; /** * Waits for the next two animation frames to elapse, via a double `requestAnimationFrame` * round-trip in-page. * * Stencil's `@Prop()` writes (and any geometry/positioning recalculation a component does in * response to one) commit on the next animation frame, not synchronously with the property * assignment. A raw `locator.evaluate()` read taken immediately after a property write can race * that commit and return a stale pre-write value. Needed only before a * one-shot, non-retrying read (e.g. a geometry read, or a CSS custom property read via * `getComputedStyle`); a retrying Playwright locator assertion (`toHaveCSS`, `toContainClass`, * etc.) doesn't need it, since it already re-samples until it matches or times out. * * @param page The Playwright Page instance to wait on. */ export declare function waitForRender(page: Page): Promise; /** * Returns whether an element is visible: after waiting two animation frames (needed because a * class/style change triggering the opacity isn't guaranteed to have been computed within the * same microtask), computed `display` is not `'none'`, `visibility` is not `'hidden'`, AND * `opacity` is not `'0'`. Playwright's own native `Locator.isVisible()` does NOT check opacity * (an element with `opacity: 0` is considered "visible" under Playwright's own actionability * definition). Needed by any test asserting on an opacity-0 hidden state (e.g. q2-pill's close * button, which uses `opacity: 0` rather than `display: none` to hide/reveal itself). * * @param locator The Playwright Locator to check. * @returns Whether the element passes this visibility definition. */ export declare function isVisible(locator: Locator): Promise; /** * Returns a color-valued CSS custom property of an element, resolved to the browser's computed * `rgb()` form. `getComputedStyle().getPropertyValue()` returns a custom property in whatever color * syntax it was written in (e.g. `#d20a0a`), so this applies the value to a temporary probe * element's `color` and reads that back, making values comparable regardless of how they were set. * * @param locator The element to read the custom property from. * @param property The custom property name, e.g. `--comp-status-color`. * @returns The resolved color, e.g. `rgb(210, 10, 10)`. */ export declare function getResolvedColorProperty(locator: Locator, property: string): Promise; export { base as test }; /** * Evaluates accessibility violations on the provided page using axe-core. * * @param page The Playwright Page instance to evaluate. * @param selector Optional CSS selector to scope the aXe analysis to. * @param disabledRuleIds Optional additional axe rule IDs to disable, beyond the always-disabled * `PAGE_LEVEL_RULES`. `@axe-core/playwright`'s `AxeBuilder` only supports whole-rule disabling * via `disableRules()`, not message-substring-level exemptions — this param is for a known, * accepted exemption that is narrow in practice (e.g. a single component's `aria-controls` * target not existing yet at analysis time) — used by q2-search's loading/open-popover a11y * tests, which disable `aria-required-attr` entirely for that case. * @returns `true` if any accessibility violations were found, `false` otherwise. */ export declare function evaluateA11y(page: Page, selector?: string, disabledRuleIds?: string[]): Promise; /** * Finds CSS rules in a component's adopted stylesheets that still contain unresolved * `var-list(`/`var-prefixer(` compilation markers, indicating a style compilation issue. * * @param page The Playwright Page instance to evaluate. * @param selector CSS selector identifying the component to inspect. * @returns An array of selector texts for rules with unresolved compilation markers. */ export declare function getListOfStyleCompilationIssues(page: Page, selector: string): Promise;