@unotest/web 0.49.1 → 0.50.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/.claude/skills/write-e2e-test/SKILL.md +6 -7
- package/.claude/skills/write-e2e-test-ground/SKILL.md +6 -7
- package/CHANGELOG.md +294 -3
- package/README.md +5 -4
- package/bin/unotest-web.js +10 -9
- package/dist/config/schema.d.ts +11 -11
- package/dist/config/schema.js +1 -1
- package/dist/driver/index.d.ts +4 -2
- package/dist/driver/index.js +1 -1
- package/dist/dsl/index.d.ts +43 -28
- package/dist/dsl/index.js +1 -1
- package/dist/dsl/web-dsl-language-service.d.ts +18 -6
- package/dist/dsl/web-dsl-language-service.js +1 -1
- package/dist/inspection/page-inject.d.ts +1 -1
- package/dist/inspection/page-inject.js +15 -9
- package/dist/{interfaces-D5ePwBX6.d.ts → interfaces--zgFOUB6.d.ts} +17 -0
- package/dist/{linter-RrjB1n9R.d.ts → linter-Ci17V2Sr.d.ts} +13 -5
- package/dist/mcp/server.js +1 -1
- package/dist/runner/cli.d.ts +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/agent-integration.md +15 -1
- package/guides/dsl-reference.md +416 -259
- package/package.json +8 -8
- package/types/unotest-dsl.d.ts +115 -84
- package/types/unotest-lib.d.ts +1289 -0
package/dist/dsl/index.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { L as LocatorValue, o as DriverDownload, D as DriverContext, W as WebDriver, h as DriverPage } from '../interfaces
|
|
2
|
-
export { p as LocatorStep, q as appendStep, r as describeLocator, s as isLocatorValue, t as rootedAt } from '../interfaces
|
|
1
|
+
import { L as LocatorValue, o as DriverDownload, D as DriverContext, W as WebDriver, h as DriverPage } from '../interfaces--zgFOUB6.js';
|
|
2
|
+
export { p as LocatorStep, q as appendStep, r as describeLocator, s as isLocatorValue, t as rootedAt } from '../interfaces--zgFOUB6.js';
|
|
3
3
|
import { Matcher, RegexLiteral, JudgeRequest, JudgeVerdict, VisualFailureRecord, SoftFailureRecord, TeardownStateRecord, TeardownFailureRecord } from '@unotest/protocol';
|
|
4
|
-
import {
|
|
5
|
-
export { ExecutionError, ExecutionEvent, RunOptions, RunResult } from '@unotest/dsl/executor';
|
|
4
|
+
import { ScenarioInterpreter, ScenarioEvent, RunResult, ScenarioRunOptions } from '@unotest/dsl/executor';
|
|
5
|
+
export { ExecutionError, ScenarioEvent as ExecutionEvent, ScenarioRunOptions as RunOptions, RunResult } from '@unotest/dsl/executor';
|
|
6
6
|
import { SandboxConfig } from '../config/schema.js';
|
|
7
7
|
import { UnotestError, RuntimeExecState } from '@unotest/core';
|
|
8
|
-
export { L as LintDiagnostic, b as LintOptions, a as LintSeverity, l as lintAst } from '../linter-
|
|
8
|
+
export { L as LintDiagnostic, b as LintOptions, a as LintSeverity, l as lintAst } from '../linter-Ci17V2Sr.js';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@unotest/dsl';
|
|
11
11
|
|
|
12
|
-
/** Test/codegen convenience: build a RegexLiteral inline
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* RegExpValue; this helper trusts its caller because TS already
|
|
17
|
-
* constrains `flags: string`. */
|
|
12
|
+
/** Test/codegen convenience: build a RegexLiteral inline — the shape
|
|
13
|
+
* `coerceMatcher` turns a scenario's `/pattern/flags` into, so unit
|
|
14
|
+
* tests don't need to round-trip through the parser. Pattern and flags
|
|
15
|
+
* are the parser's to check; this helper trusts its caller. */
|
|
18
16
|
declare function re(source: string, flags?: string): RegexLiteral;
|
|
19
17
|
declare function locator(selector: string): LocatorValue;
|
|
20
18
|
declare function getByRole(role: string, options?: {
|
|
@@ -119,6 +117,11 @@ interface Logger {
|
|
|
119
117
|
error(msg: string, ...rest: unknown[]): void;
|
|
120
118
|
debug(msg: string, ...rest: unknown[]): void;
|
|
121
119
|
step(msg: string, ...rest: unknown[]): void;
|
|
120
|
+
/** An error line under a word of its own instead of `error` — a test
|
|
121
|
+
* result reads `failed` or `errored`, the words of the run's summary.
|
|
122
|
+
* Optional so a test's logger literal need not grow it; `labeledError`
|
|
123
|
+
* is how a caller prints one. */
|
|
124
|
+
labeled?(label: string, msg: string, ...rest: unknown[]): void;
|
|
122
125
|
child(prefix: string): Logger;
|
|
123
126
|
}
|
|
124
127
|
|
|
@@ -141,6 +144,12 @@ interface VariableStore {
|
|
|
141
144
|
* cannot tell (test fakes) leaves it out, and a caller that must not
|
|
142
145
|
* hand a secret out then refuses rather than guess. */
|
|
143
146
|
isSecret?(name: string): boolean;
|
|
147
|
+
/** Why `name` is refused although the environment may hold it — the
|
|
148
|
+
* runner's own credential (`withOwnSecretsDenied`,
|
|
149
|
+
* config/own-secrets-deny.ts). Optional like `describeSources`; a
|
|
150
|
+
* caller that reports a missing name asks this first, so the reader
|
|
151
|
+
* learns whose the name is instead of hunting a typo. */
|
|
152
|
+
denial?(name: string): string | undefined;
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
interface Judge {
|
|
@@ -469,7 +478,6 @@ declare class TestRuntime {
|
|
|
469
478
|
readonly visual?: VisualAssertDeps;
|
|
470
479
|
private readonly variables;
|
|
471
480
|
private readonly nowFn;
|
|
472
|
-
private readonly scope;
|
|
473
481
|
private _callDepth;
|
|
474
482
|
constructor(deps: TestRuntimeDeps);
|
|
475
483
|
/** The ACTIVE context — what every DSL function acts on. `setContext`
|
|
@@ -484,9 +492,6 @@ declare class TestRuntime {
|
|
|
484
492
|
/** The active DriverPage. Tracks DriverContext.activePage which is mutated
|
|
485
493
|
* by `setPage()` for multi-tab scenarios (Phase 2 Track A). */
|
|
486
494
|
page(): DriverPage;
|
|
487
|
-
/** Variable scope stack — push/pop on user-function call boundaries. */
|
|
488
|
-
pushScope(): void;
|
|
489
|
-
popScope(): void;
|
|
490
495
|
/** User-function call depth — separate budget from maxSteps. */
|
|
491
496
|
enterCall(maxCallDepth: number): void;
|
|
492
497
|
exitCall(): void;
|
|
@@ -496,9 +501,7 @@ declare class TestRuntime {
|
|
|
496
501
|
* NOT a separate injected field: a field the two runtime-building
|
|
497
502
|
* sites could forget to pass is a rule that switches itself off. */
|
|
498
503
|
get hostPolicy(): HostPolicy | undefined;
|
|
499
|
-
setVar(name: string, value: DslValue): void;
|
|
500
504
|
getVar(name: string): DslValue;
|
|
501
|
-
hasVar(name: string): boolean;
|
|
502
505
|
/** Direct external-variable lookup (`unotest/.env` / `.secrets`), no
|
|
503
506
|
* scope fallback, no throw. Used by shell() to resolve the
|
|
504
507
|
* `sandbox.exportSecrets` allowlist into subprocess env. */
|
|
@@ -506,8 +509,10 @@ declare class TestRuntime {
|
|
|
506
509
|
/** Whether external variable `name` is a secret; undefined when the
|
|
507
510
|
* variable store cannot tell. Used by `env()`, which never hands one out. */
|
|
508
511
|
externalVarIsSecret(name: string): boolean | undefined;
|
|
509
|
-
/**
|
|
510
|
-
|
|
512
|
+
/** Why external variable `name` is refused to scenarios (the runner's
|
|
513
|
+
* own credential), or undefined. Used by shell(), whose child must not
|
|
514
|
+
* inherit what getVar refuses. */
|
|
515
|
+
externalVarDenial(name: string): string | undefined;
|
|
511
516
|
}
|
|
512
517
|
|
|
513
518
|
type DslArgType = 'string' | 'number' | 'boolean' | 'locator' | 'object' | 'any';
|
|
@@ -535,9 +540,11 @@ declare class FunctionRegistry {
|
|
|
535
540
|
/** The run-time half of the validator's `suggestForUnknown`: the walker
|
|
536
541
|
* quotes it in "Unknown DSL function", from the same table. */
|
|
537
542
|
suggestForUnknown(name: string): string | null;
|
|
543
|
+
/** The run-time half of the validator's `suggestForLambdaArgument`. */
|
|
544
|
+
suggestForLambdaArgument(name: string): string | null;
|
|
538
545
|
}
|
|
539
546
|
|
|
540
|
-
declare class AstExecutor extends
|
|
547
|
+
declare class AstExecutor extends ScenarioInterpreter<TestRuntime> {
|
|
541
548
|
constructor(registry: FunctionRegistry);
|
|
542
549
|
}
|
|
543
550
|
|
|
@@ -547,9 +554,11 @@ interface ActiveRuntime {
|
|
|
547
554
|
scenarioName: string;
|
|
548
555
|
testFn: string;
|
|
549
556
|
testRuntime: TestRuntime;
|
|
550
|
-
generator: AsyncGenerator<
|
|
557
|
+
generator: AsyncGenerator<ScenarioEvent, RunResult>;
|
|
558
|
+
/** The variables visible where the run stands (`inspectScope`). */
|
|
559
|
+
scope: () => Record<string, unknown>;
|
|
551
560
|
state: RuntimeState;
|
|
552
|
-
lastEvent:
|
|
561
|
+
lastEvent: ScenarioEvent | null;
|
|
553
562
|
/**
|
|
554
563
|
* The most recent failure event. Distinct from `lastEvent` because the
|
|
555
564
|
* immediately-following `paused` event would otherwise overwrite it —
|
|
@@ -580,6 +589,8 @@ interface ActiveRuntime {
|
|
|
580
589
|
notes?: readonly NoteRecord[];
|
|
581
590
|
error: {
|
|
582
591
|
message: string;
|
|
592
|
+
name?: string;
|
|
593
|
+
checkFailure?: true;
|
|
583
594
|
stack?: string;
|
|
584
595
|
details?: unknown;
|
|
585
596
|
};
|
|
@@ -637,7 +648,7 @@ interface RuntimeSnapshot {
|
|
|
637
648
|
vars: Record<string, unknown>;
|
|
638
649
|
/** Active page index in the DriverContext (web-specific, vs. mobile's deviceSlot). */
|
|
639
650
|
activePageIndex: number | null;
|
|
640
|
-
lastEvent:
|
|
651
|
+
lastEvent: ScenarioEvent | null;
|
|
641
652
|
lastFailure: ActiveRuntime['lastFailure'];
|
|
642
653
|
softFailures: readonly SoftFailureRecord[];
|
|
643
654
|
lastResult: RunResult | null;
|
|
@@ -677,8 +688,12 @@ declare class TestRuntimeManager {
|
|
|
677
688
|
scenarioName: string;
|
|
678
689
|
testFn: string;
|
|
679
690
|
testRuntime: TestRuntime;
|
|
680
|
-
generator: AsyncGenerator<
|
|
681
|
-
|
|
691
|
+
generator: AsyncGenerator<ScenarioEvent, RunResult>;
|
|
692
|
+
/** The interpreter's `inspectScope` — what `inspect()` reports as
|
|
693
|
+
* `vars`. The scenario's variables live in the interpreter, not in
|
|
694
|
+
* the runtime. */
|
|
695
|
+
scope: () => Record<string, unknown>;
|
|
696
|
+
runOptions: ScenarioRunOptions;
|
|
682
697
|
/** Last thing this runtime gets to do when it is aborted, awaited
|
|
683
698
|
* inside `abort()`. It exists because an abort on a PAUSE never comes
|
|
684
699
|
* back through the orchestrator: the CLI kills the process right
|
|
@@ -690,7 +705,7 @@ declare class TestRuntimeManager {
|
|
|
690
705
|
* runtime.json) while it plays. */
|
|
691
706
|
teardown?: TeardownProgress;
|
|
692
707
|
}): string;
|
|
693
|
-
pump(id: string): Promise<
|
|
708
|
+
pump(id: string): Promise<ScenarioEvent | RunResult>;
|
|
694
709
|
/** The run's verdict — the executor's own, corrected for the one thing
|
|
695
710
|
* it cannot see: that a failure it paused on was resumed rather than
|
|
696
711
|
* fixed.
|
|
@@ -703,8 +718,8 @@ declare class TestRuntimeManager {
|
|
|
703
718
|
private verdict;
|
|
704
719
|
/** The run's final verdict, rollback included — see `pump`. */
|
|
705
720
|
finish(id: string, result: RunResult): void;
|
|
706
|
-
step(id: string): Promise<
|
|
707
|
-
resume(id: string): Promise<
|
|
721
|
+
step(id: string): Promise<ScenarioEvent | RunResult>;
|
|
722
|
+
resume(id: string): Promise<ScenarioEvent | RunResult>;
|
|
708
723
|
abort(id: string): Promise<void>;
|
|
709
724
|
private abortOnce;
|
|
710
725
|
/** The second Stop: give up on the rest of the run's rollback pass. The
|