@unotest/web 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { InjectedDomHelpers } from '@unotest/grounder-client/dom-walker';
2
2
  import { PickerMode } from '@unotest/protocol';
3
- import { E as ElementHint } from '../interfaces-CYoL4Taq.js';
3
+ import { E as ElementHint } from '../interfaces-LE6GsJ0c.js';
4
4
  import '../config/schema.js';
5
5
  import 'zod';
6
6
 
@@ -426,6 +426,14 @@ declare function readCheckedState(el: Element): boolean | null;
426
426
  /** Disabled state — native `:disabled` (covers `<fieldset disabled>`
427
427
  * inheritance) or `aria-disabled` on a custom widget. */
428
428
  declare function readDisabledState(el: Element): boolean;
429
+ /** Computed value of one CSS property — custom properties included, which
430
+ * `getPropertyValue` returns with the whitespace after their colon. */
431
+ declare function readComputedStyle(el: Element, property: string): string;
432
+ /** How many animations of the element and its descendants are still
433
+ * playing towards an end. An infinite one (a spinner) never ends, so it
434
+ * is not counted — waiting for it could only time out; neither is a
435
+ * paused one, which ends only when the page resumes it. */
436
+ declare function countRunningAnimations(el: Element): number;
429
437
  /** Write a localStorage item. Key and value travel as one array because
430
438
  * Playwright's `evaluate(fn, arg)` passes a SINGLE argument. */
431
439
  declare function writeLocalStorageItem([key, value]: [string, string]): void;
@@ -441,4 +449,4 @@ declare function inspectElementRaw(el: Element, args: {
441
449
  };
442
450
  }): ElementHintRaw;
443
451
 
444
- export { type ElementHintRaw, ariaSnapshotAlgorithm, findElementAlgorithm, inspectElementRaw, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readCheckedState, readDisabledState, readLocalStorageItem, semanticDomAlgorithm, serializeRuntimeDom, writeLocalStorageItem };
452
+ export { type ElementHintRaw, ariaSnapshotAlgorithm, countRunningAnimations, findElementAlgorithm, inspectElementRaw, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readCheckedState, readComputedStyle, readDisabledState, readLocalStorageItem, semanticDomAlgorithm, serializeRuntimeDom, writeLocalStorageItem };
@@ -2791,6 +2791,16 @@ function readDisabledState(el) {
2791
2791
  return el.matches(":disabled") || el.getAttribute("aria-disabled") === "true";
2792
2792
  }
2793
2793
  __name(readDisabledState, "readDisabledState");
2794
+ function readComputedStyle(el, property) {
2795
+ globalThis.__name ??= (fn) => fn;
2796
+ return getComputedStyle(el).getPropertyValue(property).trim();
2797
+ }
2798
+ __name(readComputedStyle, "readComputedStyle");
2799
+ function countRunningAnimations(el) {
2800
+ globalThis.__name ??= (fn) => fn;
2801
+ return el.getAnimations({ subtree: true }).filter((a) => a.playState === "running" && a.effect?.getComputedTiming().iterations !== Infinity).length;
2802
+ }
2803
+ __name(countRunningAnimations, "countRunningAnimations");
2794
2804
  function writeLocalStorageItem([key, value]) {
2795
2805
  globalThis.__name ??= (fn) => fn;
2796
2806
  localStorage.setItem(key, value);
@@ -3000,12 +3010,14 @@ function inspectElementRaw(el, args) {
3000
3010
  __name(inspectElementRaw, "inspectElementRaw");
3001
3011
  export {
3002
3012
  ariaSnapshotAlgorithm,
3013
+ countRunningAnimations,
3003
3014
  findElementAlgorithm,
3004
3015
  inspectElementRaw,
3005
3016
  outlineAlgorithm,
3006
3017
  pasteValue,
3007
3018
  pickerOverlayAlgorithm,
3008
3019
  readCheckedState,
3020
+ readComputedStyle,
3009
3021
  readDisabledState,
3010
3022
  readLocalStorageItem,
3011
3023
  semanticDomAlgorithm,
@@ -374,6 +374,11 @@ interface DownloadNameFilter {
374
374
  }
375
375
  /** A fake clock shared by every page of a context. Time runs by itself
376
376
  * until `freeze`, and again after `run`. */
377
+ /** Media features a page can be made to report — Playwright's values. */
378
+ interface EmulatedMedia {
379
+ reducedMotion?: "reduce" | "no-preference";
380
+ colorScheme?: "light" | "dark" | "no-preference";
381
+ }
377
382
  interface DriverClock {
378
383
  /** Stop time at `at`: `Date` reads it, and no timer fires until `tick`
379
384
  * or `run`. Any instant, past or future — no timer fires on the way. */
@@ -637,11 +642,27 @@ interface DriverPage {
637
642
  isDisabled(loc: LocatorValue): Promise<boolean>;
638
643
  /** Read a DOM attribute on the matched element. Returns null if absent. */
639
644
  getAttribute(loc: LocatorValue, name: string): Promise<string | null>;
645
+ /** The matched element's computed value of a CSS property, as
646
+ * `getComputedStyle(el).getPropertyValue(property)` gives it — custom
647
+ * properties (`--accent`) included; "" for one that is not set. */
648
+ computedStyle(loc: LocatorValue, property: string): Promise<string>;
640
649
  /** Wait for a DOM-presence state (`attached`/`detached`/`visible`/
641
650
  * `hidden`) or an interaction state (`enabled`/`disabled`). The latter
642
651
  * is polled against `isDisabled`, so `aria-disabled` widgets count. */
643
652
  waitFor(loc: LocatorValue, opts?: WaitForOptions): Promise<void>;
644
- waitForUrl(pattern: string | RegExp, opts?: NavigationOptions): Promise<void>;
653
+ /** How many finite animations of the matched element and its
654
+ * descendants are still running. Infinite ones (spinners) and paused
655
+ * ones are not counted: neither is going to end by itself. */
656
+ runningAnimations(loc: LocatorValue): Promise<number>;
657
+ /** Wait until `runningAnimations(loc)` is 0. Times out with a
658
+ * `TimeoutError` naming the locator and how many were left. */
659
+ waitForAnimations(loc: LocatorValue, timeoutMs: number): Promise<void>;
660
+ /** A string matches as a substring of the URL, a regex unanchored. */
661
+ waitForUrl(pattern: Matcher, opts?: NavigationOptions): Promise<void>;
662
+ /** Change the media features this page reports, from now on: what
663
+ * `matchMedia` and CSS `@media` see. A feature left out keeps its
664
+ * current value. This page only — a tab opened later starts without it. */
665
+ emulateMedia(media: EmulatedMedia): Promise<void>;
645
666
  /** Wait until ≥1 VISIBLE occurrence of `text` matches (or none, with
646
667
  * `state: 'hidden' | 'detached'`). Accepts a regex matcher in the
647
668
  * JSON-safe `Matcher` shape. */