@unotest/web 0.45.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.
- package/CHANGELOG.md +83 -3
- package/README.md +7 -0
- package/dist/config/schema.d.ts +260 -73
- package/dist/config/schema.js +1 -1
- package/dist/driver/index.d.ts +10 -2
- package/dist/driver/index.js +1 -1
- package/dist/dsl/index.d.ts +24 -2
- package/dist/dsl/index.js +1 -1
- package/dist/dsl/web-dsl-language-service.js +1 -1
- package/dist/inspection/page-inject.d.ts +10 -2
- package/dist/inspection/page-inject.js +12 -0
- package/dist/{interfaces-OvnJKELk.d.ts → interfaces-LE6GsJ0c.d.ts} +64 -3
- package/dist/mcp/server.js +1 -1
- package/dist/runner/cli.js +1 -1
- package/dist/runner/init/chrome-probe.js +1 -1
- package/dist/runner/init.js +1 -1
- package/dist/runner/install-chromium.js +1 -1
- package/dist/runner/prepare-fix.js +1 -1
- package/dist/runner/scaffold-workspace.js +1 -1
- package/dist/runner/serve-fixture.js +1 -1
- package/dist/runner/web-runner-adapter.js +1 -1
- package/guides/dsl-reference.md +416 -17
- package/package.json +9 -8
- package/types/unotest-dsl.d.ts +122 -10
|
@@ -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-
|
|
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,
|
|
@@ -88,6 +88,10 @@ interface LaunchOptions {
|
|
|
88
88
|
* persistent context, which every `newContext()` then returns
|
|
89
89
|
* (`config.launch.userDataDir`). */
|
|
90
90
|
userDataDir?: string;
|
|
91
|
+
/** A new browser on a new profile directory for every context
|
|
92
|
+
* (`config.launch.profile`); each `newContext()` then needs
|
|
93
|
+
* `ContextOptions.profileDir`. */
|
|
94
|
+
profile?: "per-test";
|
|
91
95
|
/** Extra browser command-line arguments (`config.launch.args`). */
|
|
92
96
|
args?: string[];
|
|
93
97
|
}
|
|
@@ -139,6 +143,10 @@ interface ContextOptions {
|
|
|
139
143
|
* `UNOTEST_DEFAULT_NAVIGATION_TIMEOUT_MS` env overrides.
|
|
140
144
|
*/
|
|
141
145
|
defaultNavigationTimeoutMs?: number;
|
|
146
|
+
/** The directory a `profile: "per-test"` browser starts on. The caller
|
|
147
|
+
* makes it and decides whether it stays; given to any other launch it
|
|
148
|
+
* is refused. */
|
|
149
|
+
profileDir?: string;
|
|
142
150
|
}
|
|
143
151
|
interface ActionTimeout {
|
|
144
152
|
/** Override default action timeout (D-7 actionability wait). Milliseconds. */
|
|
@@ -324,6 +332,11 @@ interface WebDriver {
|
|
|
324
332
|
wsEndpoint(): string | undefined;
|
|
325
333
|
connectShared(wsEndpoint: string, browser: LaunchOptions["browser"]): Promise<void>;
|
|
326
334
|
attachExisting(opts?: AttachOptions): Promise<DriverContext>;
|
|
335
|
+
/** True while the browser `connectShared` joined is still there. A run
|
|
336
|
+
* on `launch.profile: "per-test"` closes it with each test and starts
|
|
337
|
+
* the next one at the same endpoint, so a joined client asks this
|
|
338
|
+
* before it follows the run. False when nothing is joined. */
|
|
339
|
+
sharedBrowserConnected(): boolean;
|
|
327
340
|
}
|
|
328
341
|
/** One captured network request/response, recorded only under
|
|
329
342
|
* `UNOTEST_NETWORK`. `status`/`ok` come from the response; `failureText`
|
|
@@ -361,6 +374,11 @@ interface DownloadNameFilter {
|
|
|
361
374
|
}
|
|
362
375
|
/** A fake clock shared by every page of a context. Time runs by itself
|
|
363
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
|
+
}
|
|
364
382
|
interface DriverClock {
|
|
365
383
|
/** Stop time at `at`: `Date` reads it, and no timer fires until `tick`
|
|
366
384
|
* or `run`. Any instant, past or future — no timer fires on the way. */
|
|
@@ -545,10 +563,16 @@ interface DriverContext {
|
|
|
545
563
|
* runner can pull the tail when a test fails.
|
|
546
564
|
*/
|
|
547
565
|
consoleEntries(): ReadonlyArray<{
|
|
548
|
-
level:
|
|
566
|
+
level: ConsoleLevel;
|
|
549
567
|
text: string;
|
|
550
568
|
timestamp: string;
|
|
551
569
|
}>;
|
|
570
|
+
/** The console lines and uncaught errors of the ACTIVE page, oldest
|
|
571
|
+
* first. Recorded always, from the moment the page opened — unlike
|
|
572
|
+
* `consoleEntries()`, which only `UNOTEST_CONSOLE` fills — so a
|
|
573
|
+
* scenario that clicks and then asks finds what the click logged.
|
|
574
|
+
* Extension pages (`chrome-extension://`) are pages like any other. */
|
|
575
|
+
pageConsole(): PageConsole;
|
|
552
576
|
/**
|
|
553
577
|
* Snapshot of network request/response entries captured since context
|
|
554
578
|
* creation, oldest first. Populated only when `UNOTEST_NETWORK` is on (else
|
|
@@ -618,11 +642,27 @@ interface DriverPage {
|
|
|
618
642
|
isDisabled(loc: LocatorValue): Promise<boolean>;
|
|
619
643
|
/** Read a DOM attribute on the matched element. Returns null if absent. */
|
|
620
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>;
|
|
621
649
|
/** Wait for a DOM-presence state (`attached`/`detached`/`visible`/
|
|
622
650
|
* `hidden`) or an interaction state (`enabled`/`disabled`). The latter
|
|
623
651
|
* is polled against `isDisabled`, so `aria-disabled` widgets count. */
|
|
624
652
|
waitFor(loc: LocatorValue, opts?: WaitForOptions): Promise<void>;
|
|
625
|
-
|
|
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>;
|
|
626
666
|
/** Wait until ≥1 VISIBLE occurrence of `text` matches (or none, with
|
|
627
667
|
* `state: 'hidden' | 'detached'`). Accepts a regex matcher in the
|
|
628
668
|
* JSON-safe `Matcher` shape. */
|
|
@@ -787,5 +827,26 @@ interface AncestorHint {
|
|
|
787
827
|
/** A single stable, semantic class token (not a hash / utility class). */
|
|
788
828
|
className?: string;
|
|
789
829
|
}
|
|
830
|
+
type ConsoleLevel = "log" | "info" | "warn" | "error" | "debug";
|
|
831
|
+
/** One console line of a page: `url` is the page's at the time, `at`
|
|
832
|
+
* epoch ms — the scale `nowMs()` gives a scenario. */
|
|
833
|
+
interface PageConsoleEntry {
|
|
834
|
+
level: ConsoleLevel;
|
|
835
|
+
text: string;
|
|
836
|
+
url: string;
|
|
837
|
+
at: number;
|
|
838
|
+
}
|
|
839
|
+
/** An error the page threw and nothing caught (`pageerror`). `stack` is
|
|
840
|
+
* empty when the browser gave none. */
|
|
841
|
+
interface PageErrorEntry {
|
|
842
|
+
message: string;
|
|
843
|
+
stack: string;
|
|
844
|
+
url: string;
|
|
845
|
+
at: number;
|
|
846
|
+
}
|
|
847
|
+
interface PageConsole {
|
|
848
|
+
entries: readonly PageConsoleEntry[];
|
|
849
|
+
errors: readonly PageErrorEntry[];
|
|
850
|
+
}
|
|
790
851
|
|
|
791
|
-
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
|
|
852
|
+
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 };
|