@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.
@@ -1,20 +1,18 @@
1
- import { L as LocatorValue, o as DriverDownload, D as DriverContext, W as WebDriver, h as DriverPage } from '../interfaces-D5ePwBX6.js';
2
- export { p as LocatorStep, q as appendStep, r as describeLocator, s as isLocatorValue, t as rootedAt } from '../interfaces-D5ePwBX6.js';
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 { ExecutionWalker, ExecutionEvent, RunResult, RunOptions } from '@unotest/dsl/executor';
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-RrjB1n9R.js';
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. The DSL
13
- * parser produces these for `/pattern/flags` literals at runtime;
14
- * builders take this shape so unit tests don't need to round-trip
15
- * through the lexer. Flag validation lives in `@unotest/dsl`'s
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
- /** Snapshot for `inspect_runtime` MCP tool. */
510
- snapshotVars(): Record<string, DslValue>;
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 ExecutionWalker<TestRuntime> {
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<ExecutionEvent, RunResult>;
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: ExecutionEvent | null;
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: ExecutionEvent | null;
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<ExecutionEvent, RunResult>;
681
- runOptions: RunOptions;
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<ExecutionEvent | RunResult>;
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<ExecutionEvent | RunResult>;
707
- resume(id: string): Promise<ExecutionEvent | RunResult>;
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