@unotest/web 0.52.1 → 0.54.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, A as AnimationInfo } from '../interfaces-BSGmF_Tv.js';
3
+ import { E as ElementHint, A as AnimationInfo } from '../interfaces-BU-PQbt4.js';
4
4
  import '../config/schema.js';
5
5
  import 'zod';
6
6
 
@@ -459,6 +459,9 @@ interface ImageState {
459
459
  declare function readImageState(el: Element): ImageState;
460
460
  /** Whether an `<img>` has settled — the predicate `getImageSize` waits on. */
461
461
  declare function isImageComplete(el: Element): boolean;
462
+ /** Whether any element of the document has a backdrop filter. WebKit exposes
463
+ * the property unprefixed or as `-webkit-backdrop-filter`: both are read. */
464
+ declare function pageHasBackdropFilter(): boolean;
462
465
  /** Write a localStorage item. Key and value travel as one array because
463
466
  * Playwright's `evaluate(fn, arg)` passes a SINGLE argument. */
464
467
  declare function writeLocalStorageItem([key, value]: [string, string]): void;
@@ -474,13 +477,18 @@ declare function readLocalStorageItem(key: string): string | null;
474
477
  declare function writeDocumentHidden([hidden, announce]: [boolean, boolean]): void;
475
478
  /** Make the document's scripts see the app launched in `mode` (`standalone`
476
479
  * for one added to the home screen): `matchMedia('(display-mode: …)')`
477
- * answers for that mode, and `navigator.standalone` — where the engine
478
- * has it, as WebKit does — says whether it is standalone. No engine
480
+ * answers for that mode, and with `navigatorStandalone` (WebKit)
481
+ * `navigator.standalone` says whether it is standalone. The caller names
482
+ * the engine rather than the page probing for the property: Playwright's
483
+ * WebKit has it on macOS and not on Linux, where boxes run. No engine
479
484
  * emulates the feature itself, so CSS `@media (display-mode: …)` and a
480
485
  * query combining it with other features still see the browser; the
481
486
  * config reference says so. The answer is the real list object (listeners,
482
487
  * `onchange`) of a query that is always true or always false. */
483
- declare function writeDisplayMode(mode: string): void;
488
+ declare function writeDisplayMode(args: {
489
+ mode: string;
490
+ navigatorStandalone: boolean;
491
+ }): void;
484
492
  /** Read every identifying attribute off a live element (role inferred from
485
493
  * tag + ARIA, accname approximated). Returns a structured raw hint. */
486
494
  declare function inspectElementRaw(el: Element, args: {
@@ -491,4 +499,4 @@ declare function inspectElementRaw(el: Element, args: {
491
499
  };
492
500
  }): ElementHintRaw;
493
501
 
494
- export { type ElementHintRaw, type ImageState, ariaSnapshotAlgorithm, endsByItself, findElementAlgorithm, inspectElementRaw, isImageComplete, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readAnimations, readCheckedState, readClipboardText, readComputedStyle, readDisabledState, readImageState, readLocalStorageItem, readOptionLabels, semanticDomAlgorithm, serializeRuntimeDom, writeDisplayMode, writeDocumentHidden, writeLocalStorageItem };
502
+ export { type ElementHintRaw, type ImageState, ariaSnapshotAlgorithm, endsByItself, findElementAlgorithm, inspectElementRaw, isImageComplete, outlineAlgorithm, pageHasBackdropFilter, pasteValue, pickerOverlayAlgorithm, readAnimations, readCheckedState, readClipboardText, readComputedStyle, readDisabledState, readImageState, readLocalStorageItem, readOptionLabels, semanticDomAlgorithm, serializeRuntimeDom, writeDisplayMode, writeDocumentHidden, writeLocalStorageItem };
@@ -2848,6 +2848,16 @@ function isImageComplete(el) {
2848
2848
  return el.complete;
2849
2849
  }
2850
2850
  __name(isImageComplete, "isImageComplete");
2851
+ function pageHasBackdropFilter() {
2852
+ globalThis.__name ??= (fn) => fn;
2853
+ for (const el of Array.from(document.querySelectorAll("*"))) {
2854
+ const style = getComputedStyle(el);
2855
+ const value = style.backdropFilter || style.webkitBackdropFilter;
2856
+ if (value && value !== "none") return true;
2857
+ }
2858
+ return false;
2859
+ }
2860
+ __name(pageHasBackdropFilter, "pageHasBackdropFilter");
2851
2861
  function writeLocalStorageItem([key, value]) {
2852
2862
  globalThis.__name ??= (fn) => fn;
2853
2863
  localStorage.setItem(key, value);
@@ -2873,7 +2883,8 @@ function writeDocumentHidden([hidden, announce]) {
2873
2883
  if (!hidden) window.dispatchEvent(new FocusEvent("focus"));
2874
2884
  }
2875
2885
  __name(writeDocumentHidden, "writeDocumentHidden");
2876
- function writeDisplayMode(mode) {
2886
+ function writeDisplayMode(args) {
2887
+ const { mode } = args;
2877
2888
  globalThis.__name ??= (fn) => fn;
2878
2889
  const original = window.matchMedia.bind(window);
2879
2890
  function askedMode(query) {
@@ -2891,7 +2902,7 @@ function writeDisplayMode(mode) {
2891
2902
  Object.defineProperty(list, "media", { configurable: true, value: query });
2892
2903
  return list;
2893
2904
  };
2894
- if ("standalone" in navigator) {
2905
+ if (args.navigatorStandalone) {
2895
2906
  Object.defineProperty(navigator, "standalone", { configurable: true, get: /* @__PURE__ */ __name(() => mode === "standalone", "get") });
2896
2907
  }
2897
2908
  }
@@ -3100,6 +3111,7 @@ export {
3100
3111
  inspectElementRaw,
3101
3112
  isImageComplete,
3102
3113
  outlineAlgorithm,
3114
+ pageHasBackdropFilter,
3103
3115
  pasteValue,
3104
3116
  pickerOverlayAlgorithm,
3105
3117
  readAnimations,
@@ -313,6 +313,12 @@ interface AttachOptions extends Pick<ContextOptions, "dialogPolicy"> {
313
313
  contextId?: string;
314
314
  }
315
315
 
316
+ /** How `connectShared` joins a browser. */
317
+ interface ConnectSharedOptions {
318
+ /** Give up on the connection after this long. Absent → the browser
319
+ * library's own wait (30 s for Playwright), as debug-attach has it. */
320
+ timeoutMs?: number;
321
+ }
316
322
  interface WebDriver {
317
323
  /**
318
324
  * Launch the underlying browser process. Idempotent — subsequent calls
@@ -326,6 +332,13 @@ interface WebDriver {
326
332
  * each test calls newContext() at start and ctx.close() at end.
327
333
  */
328
334
  newContext(opts?: ContextOptions): Promise<DriverContext>;
335
+ /**
336
+ * A context on its own persistent browser profile, the directory `dir`
337
+ * (absolute; the caller made it and keeps it). Its cookies and storage
338
+ * live in that directory, apart from every other context's; closing the
339
+ * context closes its browser. Several can be open at once.
340
+ */
341
+ newProfileContext(dir: string, opts?: ContextOptions): Promise<DriverContext>;
329
342
  /**
330
343
  * Tear down all open contexts and the browser process. Idempotent.
331
344
  * Errors logged but not re-thrown (must not mask test failures in
@@ -347,7 +360,7 @@ interface WebDriver {
347
360
  * Drivers that don't support sharing throw from connect/attach.
348
361
  */
349
362
  wsEndpoint(): string | undefined;
350
- connectShared(wsEndpoint: string, browser: LaunchOptions["browser"]): Promise<void>;
363
+ connectShared(wsEndpoint: string, browser: LaunchOptions["browser"], opts?: ConnectSharedOptions): Promise<void>;
351
364
  attachExisting(opts?: AttachOptions): Promise<DriverContext>;
352
365
  /** True while the browser `connectShared` joined is still there. A run
353
366
  * on `launch.profile: "per-test"` closes it with each test and starts
@@ -375,6 +388,31 @@ interface NetworkEntry {
375
388
  * aborted it. Absent for requests a mock let through. */
376
389
  mocked?: true;
377
390
  }
391
+ /** One request of the active page and what came back, kept always — from
392
+ * the page's opening — for `networkEntries` in a scenario. Bodies are read
393
+ * only for `fetch` / `xhr` with a text or JSON content type, at most
394
+ * 64 KB each (`truncated`); every other resource has its status only. */
395
+ interface PageNetworkEntry {
396
+ url: string;
397
+ method: string;
398
+ /** 0 when the request failed before any response. */
399
+ status: number;
400
+ ok: boolean;
401
+ failureText?: string;
402
+ /** A `mockRoute` answered or aborted it. */
403
+ mocked?: true;
404
+ /** The request body read as JSON; null when there is none or it is not
405
+ * JSON. As `postDataJson` of `waitForRequest`. */
406
+ requestJson: unknown;
407
+ /** The response body read as JSON; null when it is not JSON or was not read. */
408
+ responseJson: unknown;
409
+ /** The response body of a text content type; null otherwise. */
410
+ responseText: string | null;
411
+ /** A body was cut at the cap; `responseJson` is then null. */
412
+ truncated?: true;
413
+ /** When the request was sent, epoch ms (as `nowMs()`). */
414
+ at: number;
415
+ }
378
416
  /** A file a page of the context downloaded. The bytes stay with the
379
417
  * browser until `saveAs` copies them out. */
380
418
  interface DriverDownload {
@@ -651,6 +689,11 @@ interface DriverContext {
651
689
  * `network.json` for the viewer's Network tab.
652
690
  */
653
691
  networkEntries(): ReadonlyArray<NetworkEntry>;
692
+ /**
693
+ * What the active page requested and was answered, oldest first. Recorded
694
+ * always (500 entries per context), unlike `networkEntries()`.
695
+ */
696
+ pageNetwork(): ReadonlyArray<PageNetworkEntry>;
654
697
  /**
655
698
  * The first download of this context the scenario has not taken yet,
656
699
  * waiting up to `timeoutMs` (default: the navigation budget) for one.
@@ -807,6 +850,9 @@ interface DriverPage {
807
850
  * logging to persist "what did this locator actually resolve to" as
808
851
  * agent-readable proof — NOT part of the DSL / action surface. */
809
852
  outerHTML(loc: LocatorValue): Promise<string | null>;
853
+ /** Whether any element of the main frame has a computed backdrop filter.
854
+ * Read before a screenshot, to warn where the engine does not draw one. */
855
+ hasBackdropFilter(): Promise<boolean>;
810
856
  }
811
857
  /**
812
858
  * Identifying attributes of a single DOM element. Populated by
@@ -975,4 +1021,4 @@ interface PageConsole {
975
1021
  errors: readonly PageErrorEntry[];
976
1022
  }
977
1023
 
978
- export { type AnimationInfo 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 VirtualCredential as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type AttachOptions as d, type ActionTimeout as e, type CheckOptions as f, type ClickOptions as g, type CookieOptions as h, type DriverPage as i, type NavigationOptions as j, type PressOptions as k, type SelectOptions as l, type Viewport as m, type ViewportSize as n, type WaitOptions as o, type WaitState as p, type DriverDownload as q, type LocatorStep as r, appendStep as s, describeLocator as t, isLocatorValue as u, rootedAt as v };
1024
+ export { type AnimationInfo 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 VirtualCredential as V, type WebDriver as W, type CaptureRect as a, type PageNetworkEntry as b, type LaunchOptions as c, type ContextOptions as d, type AttachOptions as e, type ActionTimeout as f, type CheckOptions as g, type ClickOptions as h, type CookieOptions as i, type DriverPage as j, type NavigationOptions as k, type PressOptions as l, type SelectOptions as m, type Viewport as n, type ViewportSize as o, type WaitOptions as p, type WaitState as q, type DriverDownload as r, type LocatorStep as s, appendStep as t, describeLocator as u, isLocatorValue as v, rootedAt as w };
@@ -78,6 +78,16 @@ interface LintOptions {
78
78
  /** The file's comments (`ParsedScenario.comments`): what an author wrote
79
79
  * next to a line is read as its reason by `lint:typed-step-available`. */
80
80
  comments?: readonly LintComment[];
81
+ /** The budget of a test in this project (`resolveTestBudget`): what
82
+ * `lint:wait-exceeds-test-budget` measures a wait against when the test
83
+ * sets none of its own. Absent → the rule only knows `setTestTimeout`
84
+ * literals. */
85
+ testBudget?: TestBudgetHint;
86
+ }
87
+ /** A test's time budget and the setting it comes from. */
88
+ interface TestBudgetHint {
89
+ ms: number;
90
+ setting: string;
81
91
  }
82
92
  /** Lint a parsed file (`ParsedScenario.program`) or any node in one. */
83
93
  declare function lintAst(ast: ESTree.Node, opts?: LintOptions): LintDiagnostic[];
@@ -89,4 +99,4 @@ interface LintComment {
89
99
  text: string;
90
100
  }
91
101
 
92
- export { type ExternalVariableLookup as E, type LintDiagnostic as L, type LintSeverity as a, type LintOptions as b, lintAst as l };
102
+ export { type ExternalVariableLookup as E, type LintDiagnostic as L, type TestBudgetHint as T, type LintSeverity as a, type LintOptions as b, lintAst as l };