@unotest/web 0.49.0 → 0.49.2

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-CTMGjJIs.js';
3
+ import { E as ElementHint } from '../interfaces-mlRtu8mL.js';
4
4
  import '../config/schema.js';
5
5
  import 'zod';
6
6
 
@@ -434,6 +434,21 @@ declare function readComputedStyle(el: Element, property: string): string;
434
434
  * is not counted — waiting for it could only time out; neither is a
435
435
  * paused one, which ends only when the page resumes it. */
436
436
  declare function countRunningAnimations(el: Element): number;
437
+ /** What `getImageSize` reads off an element: its tag, whether the image
438
+ * has settled (`complete`: loaded, failed, or nothing to load), its
439
+ * natural size, and whether it is lazy — a lazy image outside the
440
+ * viewport never starts loading, which is the usual reason it never
441
+ * settles. */
442
+ interface ImageState {
443
+ tag: string;
444
+ complete: boolean;
445
+ width: number;
446
+ height: number;
447
+ lazy: boolean;
448
+ }
449
+ declare function readImageState(el: Element): ImageState;
450
+ /** Whether an `<img>` has settled — the predicate `getImageSize` waits on. */
451
+ declare function isImageComplete(el: Element): boolean;
437
452
  /** Write a localStorage item. Key and value travel as one array because
438
453
  * Playwright's `evaluate(fn, arg)` passes a SINGLE argument. */
439
454
  declare function writeLocalStorageItem([key, value]: [string, string]): void;
@@ -449,4 +464,4 @@ declare function inspectElementRaw(el: Element, args: {
449
464
  };
450
465
  }): ElementHintRaw;
451
466
 
452
- export { type ElementHintRaw, ariaSnapshotAlgorithm, countRunningAnimations, findElementAlgorithm, inspectElementRaw, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readCheckedState, readComputedStyle, readDisabledState, readLocalStorageItem, semanticDomAlgorithm, serializeRuntimeDom, writeLocalStorageItem };
467
+ export { type ElementHintRaw, type ImageState, ariaSnapshotAlgorithm, countRunningAnimations, findElementAlgorithm, inspectElementRaw, isImageComplete, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readCheckedState, readComputedStyle, readDisabledState, readImageState, readLocalStorageItem, semanticDomAlgorithm, serializeRuntimeDom, writeLocalStorageItem };
@@ -2775,15 +2775,21 @@ function pasteValue(el, pasted) {
2775
2775
  __name(pasteValue, "pasteValue");
2776
2776
  function readCheckedState(el) {
2777
2777
  globalThis.__name ??= (fn) => fn;
2778
- const input = el;
2779
- if (input.tagName === "INPUT" && (input.type === "checkbox" || input.type === "radio")) {
2780
- return input.checked;
2781
- }
2782
- const role = el.getAttribute("role");
2783
- if (role === "checkbox" || role === "radio" || role === "switch") {
2784
- return el.getAttribute("aria-checked") === "true";
2785
- }
2786
- return null;
2778
+ const own = /* @__PURE__ */ __name((node) => {
2779
+ const input = node;
2780
+ if (input.tagName === "INPUT" && (input.type === "checkbox" || input.type === "radio")) {
2781
+ return input.checked;
2782
+ }
2783
+ const role = node.getAttribute("role");
2784
+ if (role === "checkbox" || role === "radio" || role === "switch") {
2785
+ return node.getAttribute("aria-checked") === "true";
2786
+ }
2787
+ return null;
2788
+ }, "own");
2789
+ const state = own(el);
2790
+ if (state !== null) return state;
2791
+ const control = el.closest("label")?.control;
2792
+ return control ? own(control) : null;
2787
2793
  }
2788
2794
  __name(readCheckedState, "readCheckedState");
2789
2795
  function readDisabledState(el) {
@@ -2801,6 +2807,25 @@ function countRunningAnimations(el) {
2801
2807
  return el.getAnimations({ subtree: true }).filter((a) => a.playState === "running" && a.effect?.getComputedTiming().iterations !== Infinity).length;
2802
2808
  }
2803
2809
  __name(countRunningAnimations, "countRunningAnimations");
2810
+ function readImageState(el) {
2811
+ globalThis.__name ??= (fn) => fn;
2812
+ const tag = el.tagName.toLowerCase();
2813
+ if (tag !== "img") return { tag, complete: true, width: 0, height: 0, lazy: false };
2814
+ const img = el;
2815
+ return {
2816
+ tag,
2817
+ complete: img.complete,
2818
+ width: img.naturalWidth,
2819
+ height: img.naturalHeight,
2820
+ lazy: img.loading === "lazy"
2821
+ };
2822
+ }
2823
+ __name(readImageState, "readImageState");
2824
+ function isImageComplete(el) {
2825
+ globalThis.__name ??= (fn) => fn;
2826
+ return el.complete;
2827
+ }
2828
+ __name(isImageComplete, "isImageComplete");
2804
2829
  function writeLocalStorageItem([key, value]) {
2805
2830
  globalThis.__name ??= (fn) => fn;
2806
2831
  localStorage.setItem(key, value);
@@ -3013,12 +3038,14 @@ export {
3013
3038
  countRunningAnimations,
3014
3039
  findElementAlgorithm,
3015
3040
  inspectElementRaw,
3041
+ isImageComplete,
3016
3042
  outlineAlgorithm,
3017
3043
  pasteValue,
3018
3044
  pickerOverlayAlgorithm,
3019
3045
  readCheckedState,
3020
3046
  readComputedStyle,
3021
3047
  readDisabledState,
3048
+ readImageState,
3022
3049
  readLocalStorageItem,
3023
3050
  semanticDomAlgorithm,
3024
3051
  serializeRuntimeDom,
@@ -9,6 +9,13 @@ type LocatorStep = {
9
9
  role: string;
10
10
  name?: Matcher;
11
11
  exact?: boolean;
12
+ checked?: boolean;
13
+ disabled?: boolean;
14
+ expanded?: boolean;
15
+ includeHidden?: boolean;
16
+ level?: number;
17
+ pressed?: boolean;
18
+ selected?: boolean;
12
19
  } | {
13
20
  kind: 'getByText';
14
21
  text: Matcher;
@@ -629,6 +636,9 @@ interface DriverPage {
629
636
  clipboardPaste(loc: LocatorValue, text: string): Promise<void>;
630
637
  count(loc: LocatorValue): Promise<number>;
631
638
  textContent(loc: LocatorValue): Promise<string | null>;
639
+ /** `textContent` of every match, in DOM order; `[]` when nothing
640
+ * matches. One read, no wait — a query, not an assertion. */
641
+ textContents(loc: LocatorValue): Promise<string[]>;
632
642
  /** RENDERED text: line breaks preserved, `display:none` subtrees and
633
643
  * `<script>`/`<style>` excluded. What a human reads on screen —
634
644
  * `textContent` is the raw source-order concatenation and answers a
@@ -654,6 +664,13 @@ interface DriverPage {
654
664
  * `getComputedStyle(el).getPropertyValue(property)` gives it — custom
655
665
  * properties (`--accent`) included; "" for one that is not set. */
656
666
  computedStyle(loc: LocatorValue, property: string): Promise<string>;
667
+ /** Natural size of the matched `<img>` once it has settled (loaded or
668
+ * failed), within the action timeout; `null` when it has no pixels —
669
+ * broken, or no src. The one query that waits: "still loading" is not
670
+ * an answer, and reading too early would report a good image as broken.
671
+ * A `LocatorError` for an element that is not an `<img>`, a
672
+ * `TimeoutError` for one that never settles. */
673
+ imageSize(loc: LocatorValue): Promise<ImageSize | null>;
657
674
  /** Wait for a DOM-presence state (`attached`/`detached`/`visible`/
658
675
  * `hidden`) or an interaction state (`enabled`/`disabled`). The latter
659
676
  * is polled against `isDisabled`, so `aria-disabled` widgets count. */
@@ -729,6 +746,11 @@ interface BoundingBox {
729
746
  width: number;
730
747
  height: number;
731
748
  }
749
+ /** An image's natural size, in its own pixels. */
750
+ interface ImageSize {
751
+ width: number;
752
+ height: number;
753
+ }
732
754
  /** How `inspectElement` reads the element's `readable` text. By default
733
755
  * whitespace folded and clipped to 200 — a hint. `whole` keeps the text as
734
756
  * it is, up to `limit` characters, for a refusal that quotes it (#256). */
@@ -857,4 +879,4 @@ interface PageConsole {
857
879
  errors: readonly PageErrorEntry[];
858
880
  }
859
881
 
860
- export { type AttachOptions as A, type BoundingBox as B, type CaptureFrame as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type LocatorValue as L, type NetworkEntry as N, type PageConsole as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type ActionTimeout as d, type CheckOptions as e, type ClickOptions as f, type CookieOptions as g, type DriverPage as h, type NavigationOptions as i, type PressOptions as j, type SelectOptions as k, type ViewportSize as l, type WaitOptions as m, type WaitState as n, type DriverDownload as o, type LocatorStep as p, appendStep as q, describeLocator as r, isLocatorValue as s, rootedAt as t };
882
+ export { type AttachOptions as A, type BoundingBox as B, type CaptureFrame as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type ImageSize as I, type LocatorValue as L, type NetworkEntry as N, type PageConsole as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type ActionTimeout as d, type CheckOptions as e, type ClickOptions as f, type CookieOptions as g, type DriverPage as h, type NavigationOptions as i, type PressOptions as j, type SelectOptions as k, type ViewportSize as l, type WaitOptions as m, type WaitState as n, type DriverDownload as o, type LocatorStep as p, appendStep as q, describeLocator as r, isLocatorValue as s, rootedAt as t };