@midscene/test 1.12.10-beta-20260920031616.0 → 1.13.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,66 +1,39 @@
1
+ import { Awaitable } from '@midscene/core/internal/test-runner';
1
2
  import { CommonAgentTestRunnerApi } from '@midscene/core/agent/test';
2
- import type { z } from 'zod/v4';
3
-
4
- declare type Awaitable<T> = T | Promise<T>;
5
-
6
- declare interface CaseExecutionContext {
7
- readonly caseId: string;
8
- readonly runId: string;
9
- readonly projectName: string;
10
- readonly attemptIndex: number;
11
- readonly name: string;
12
- readonly sourcePath: string;
13
- readonly caseIndex: number;
14
- }
15
-
16
- declare type CaseNodePhase = 'beforeEach' | 'steps' | 'afterEach';
17
-
18
- declare interface CaseRunOutcome {
19
- caseId: string;
20
- projectName: string;
21
- name: string;
22
- sourcePath: string;
23
- caseIndex: number;
24
- status: CaseRunStatus;
3
+ import type * as Core from '@midscene/core/internal/test-runner';
4
+ import type { ExecutionProjectDefinition as ExecutionProjectDefinition_2 } from '@midscene/core/internal/test-runner';
5
+ import { JsonPrimitive } from '@midscene/core/internal/test-runner';
6
+ import { JsonValue } from '@midscene/core/internal/test-runner';
7
+ import { NodeRegistry as NodeRegistry_2 } from '@midscene/core/internal/test-runner';
8
+ import { ProjectRuntimeResult } from '@midscene/core/internal/test-runner';
9
+ import { ProjectSetupContext } from '@midscene/core/internal/test-runner';
10
+ import { ProjectSetupDefinition } from '@midscene/core/internal/test-runner';
11
+ import { ProjectTeardown } from '@midscene/core/internal/test-runner';
12
+ import { ProjectTeardownContext } from '@midscene/core/internal/test-runner';
13
+ import { ResolvedExecutionProject } from '@midscene/core/internal/test-runner';
14
+ import { TestFileSelection } from '@midscene/core/internal/test-runner';
15
+ import { TestTagSelection } from '@midscene/core/internal/test-runner';
16
+ import { WorkflowError } from '@midscene/core/internal/test-runner';
17
+ import { WorkflowReportSource } from '@midscene/core/internal/test-runner';
18
+
19
+ declare type CaseRunOutcome = Omit<Core.CaseRunOutcome, 'onFailure' | 'run' | 'attempts'> & {
25
20
  run?: CaseRunResult;
26
21
  attempts?: readonly CaseRunResult[];
27
- notRunReason?: 'document-start-failed' | 'project-preflight-failed' | 'project-setup-failed' | 'interrupted' | 'bail' | 'fatal-error';
28
- }
22
+ };
29
23
 
30
- declare interface CaseRunResult {
31
- caseId: string;
32
- runId: string;
33
- projectName: string;
34
- attemptIndex: number;
35
- name: string;
36
- sourcePath: string;
37
- caseIndex: number;
38
- status: 'success' | 'failed';
24
+ declare type CaseRunResult = Omit<Core.CaseRunResult, 'beforeEach' | 'steps' | 'afterEach' | 'reportSources' | 'reportScopeId'> & {
39
25
  beforeEach: StepRunResult[];
40
26
  steps: StepRunResult[];
41
27
  afterEach: StepRunResult[];
42
- teardownErrors?: WorkflowError[];
43
- reportPaths?: string[];
44
- startedAt: string;
45
- endedAt: string;
46
- durationMs: number;
47
- }
48
-
49
- declare type CaseRunStatus = 'success' | 'failed' | 'not-run';
28
+ };
50
29
 
51
30
  export declare const createTestRunId: (date?: Date, uuid?: `${string}-${string}-${string}-${string}-${string}`) => string;
52
31
 
53
32
  export declare const DEFAULT_TEST_FILE_SELECTION: TestFileSelection;
54
33
 
55
- declare interface DefineNodeOptions<TInput = unknown, TData = unknown, TContext = unknown> {
56
- name: string;
57
- title?: string;
58
- description?: string;
59
- /** Object field populated by string shorthand. Omit or set false to disable it. */
60
- stringInputKey?: string | false;
61
- inputSchema?: NodeInputSchema;
62
- execute(execution: NodeExecutionContext<TInput, TContext>): NodeExecutionReturn<TData>;
63
- }
34
+ declare type DefineNodeOptions<TInput = unknown, TData = unknown, TContext = unknown> = Omit<Core.DefineNodeOptions<TInput, TData, TContext>, 'execute'> & {
35
+ execute(ctx: NodeExecutionContext<TInput, TContext>): Core.NodeExecutionReturn<TData>;
36
+ };
64
37
 
65
38
  export declare const defineProjectSetup: <TProjectContext>(definition: ProjectSetupDefinition<TProjectContext>) => ProjectSetupDefinition<TProjectContext>;
66
39
 
@@ -70,24 +43,13 @@ export declare const discoverTestConfig: (projectRoot: string) => string | undef
70
43
 
71
44
  export declare const discoverTestFiles: (projectRoot: string, selection?: TestFileSelection) => string[];
72
45
 
73
- declare type DocumentNodePhase = 'beforeAll' | 'afterAll';
74
-
75
- export declare interface ExecutionProjectDefinition<TProjectContext = unknown> {
76
- name: string;
77
- setup?: ProjectSetupDefinition<TProjectContext>;
78
- /** Project-local Nodes override global Nodes with the same name. */
79
- nodes?: readonly NodeDefinition<any, any, TProjectContext>[];
80
- files?: TestFileSelection;
81
- tags?: TestTagSelection;
82
- retry?: number;
83
- variables?: Readonly<Record<string, JsonValue>>;
84
- }
46
+ export declare type ExecutionProjectDefinition<TContext = unknown> = Omit<ExecutionProjectDefinition_2<TContext>, 'nodes'> & {
47
+ nodes?: readonly NodeDefinition<any, any, TContext>[];
48
+ };
85
49
 
86
- export declare type JsonPrimitive = string | number | boolean | null;
50
+ export { JsonPrimitive }
87
51
 
88
- export declare type JsonValue = JsonPrimitive | readonly JsonValue[] | {
89
- readonly [key: string]: JsonValue;
90
- };
52
+ export { JsonValue }
91
53
 
92
54
  export declare interface LoadedExecutionProject<TProjectContext = unknown> extends ResolvedExecutionProject<TProjectContext> {
93
55
  /** Effective Nodes: globals plus project-local overrides. */
@@ -110,61 +72,20 @@ declare interface MidsceneExecutionRef {
110
72
  }
111
73
 
112
74
  declare type MidsceneUIAgent = CommonAgentTestRunnerApi & {
75
+ _prepareForTestRunner?(): void;
76
+ _createReportSource?(scopeId: string): Promise<WorkflowReportSource | undefined>;
77
+ flushReport?(): Promise<string | undefined>;
113
78
  addDumpUpdateListener?(listener: (dump: string, execution?: MidsceneExecutionRef) => void): () => void;
114
79
  };
115
80
 
116
- declare interface NodeCaseContext extends CaseExecutionContext {
117
- readonly phase: CaseNodePhase;
118
- readonly stepIndex: number;
119
- }
120
-
121
- declare interface NodeDefinition<TInput = unknown, TData = unknown, TContext = unknown> extends DefineNodeOptions<TInput, TData, TContext> {
122
- }
123
-
124
- declare interface NodeDocumentContext {
125
- readonly documentId: string;
126
- readonly documentRunId: string;
127
- readonly projectId: string;
128
- readonly projectName: string;
129
- readonly sourcePath: string;
130
- readonly phase: DocumentNodePhase;
131
- readonly stepIndex: number;
132
- }
133
-
134
- declare type NodeExecutionContext<TInput = unknown, TContext = unknown> = NodeExecutionContextBase<TInput, TContext> & ({
135
- /** The node is running for one case. */
136
- scope: 'case';
137
- /** Identity and phase information for the case being executed. */
138
- case: NodeCaseContext;
139
- document?: never;
140
- } | {
141
- /** The node is running for the workflow document. */
142
- scope: 'document';
143
- /** Identity and phase information for the document being executed. */
144
- document: NodeDocumentContext;
145
- case?: never;
146
- });
147
-
148
- declare interface NodeExecutionContextBase<TInput = unknown, TContext = unknown> {
149
- /** The validated node input without `$`. */
150
- input: TInput;
151
- /** The normalized engine metadata for this step. */
81
+ declare type NativeNodeContext<T> = T extends unknown ? Omit<T, '$' | 'onTeardown'> & {
152
82
  $: Readonly<NormalizedStepMeta>;
153
- /** The timeout and cancellation signal for this step. */
154
- signal: AbortSignal;
155
- /** Resources shared by the current workflow document. */
156
- context: TContext;
157
- /** Register resource cleanup for the current case attempt or document. */
158
83
  onTeardown(teardown: NodeScopeTeardown): void;
159
- /** Attach report detail references to the current Step result. */
160
- report: NodeReportCollector;
161
- }
84
+ } : never;
162
85
 
163
- declare type NodeExecutionPhase = CaseNodePhase | DocumentNodePhase;
86
+ declare type NodeDefinition<TInput = unknown, TData = unknown, TContext = unknown> = DefineNodeOptions<TInput, TData, TContext>;
164
87
 
165
- declare type NodeExecutionReturn<TData = unknown> = Promise<NodeResult<TData> | void> | NodeResult<TData> | void;
166
-
167
- declare type NodeInputSchema = z.ZodObject;
88
+ declare type NodeExecutionContext<TInput = unknown, TContext = unknown> = NativeNodeContext<Core.NodeExecutionContext<TInput, TContext>>;
168
89
 
169
90
  /** Options passed to an external package's synchronous createMidsceneTestNodes() factory. */
170
91
  export declare interface NodePackageOptions<TContext, TAgent = MidsceneUIAgent> {
@@ -172,87 +93,34 @@ export declare interface NodePackageOptions<TContext, TAgent = MidsceneUIAgent>
172
93
  getAgent(execution: NodeExecutionContext<unknown, TContext>): Awaitable<TAgent>;
173
94
  }
174
95
 
175
- declare class NodeRegistry {
176
- #private;
177
- constructor(nodes?: readonly NodeDefinition<any, any>[]);
178
- register<TInput, TData>(node: NodeDefinition<TInput, TData>): this;
96
+ declare type NodeRegistry = Omit<NodeRegistry_2, 'get' | 'require' | 'register' | 'definitions'> & {
179
97
  get(name: string): NodeDefinition<any, any> | undefined;
180
98
  require(name: string): NodeDefinition<any, any>;
181
- has(name: string): boolean;
182
- names(): string[];
99
+ register<TInput, TData>(node: NodeDefinition<TInput, TData>): NodeRegistry;
183
100
  definitions(): readonly NodeDefinition<any, any, any>[];
184
- }
185
-
186
- /** Collects report references produced while the current Step is executing. */
187
- declare interface NodeReportCollector {
188
- addTrace(trace: NodeReportTrace): void;
189
- }
190
-
191
- /** A stable reference from one test Step to report detail data. */
192
- declare interface NodeReportTrace {
193
- type: 'midscene-execution';
194
- executionId: string;
195
- }
101
+ };
196
102
 
197
- declare interface NodeResult<TData = unknown> {
198
- /** Human-readable summary for reports. */
199
- summary?: string;
200
- /** Structured data included in the step result. */
201
- data?: TData;
202
- }
103
+ declare const NodeRegistry: {
104
+ new (nodes?: readonly NodeDefinition<any, any>[]): NodeRegistry;
105
+ };
203
106
 
204
- declare type NodeScopeTeardown = () => Awaitable<NodeScopeTeardownResult | void>;
107
+ declare type NodeScopeTeardown = () => Core.Awaitable<NodeScopeTeardownOutput>;
205
108
 
206
- declare interface NodeScopeTeardownResult {
207
- /** Absolute paths to Midscene reports produced by this execution scope. */
208
- reportPaths?: readonly string[];
209
- }
109
+ declare type NodeScopeTeardownOutput = NodeScopeTeardownResult | void;
210
110
 
211
- declare interface NormalizedStepMeta {
212
- timeoutMs?: number;
213
- continueOnError: boolean;
214
- }
111
+ declare type NodeScopeTeardownResult = Omit<Core.NodeScopeTeardownResult, 'reportSources'>;
215
112
 
216
- declare interface ProjectRuntimeResult<TProjectContext = unknown> {
217
- projectName: string;
218
- status: 'success' | 'failed';
219
- setupError?: WorkflowError;
220
- teardownErrors?: readonly WorkflowError[];
221
- startedAt: string;
222
- endedAt: string;
223
- durationMs: number;
224
- }
113
+ declare type NormalizedStepMeta = Omit<Core.NormalizedStepMeta, 'captureResult' | 'resultName'>;
225
114
 
226
- export declare interface ProjectSetupContext<TProjectContext = unknown> {
227
- readonly project: ResolvedExecutionProject<TProjectContext>;
228
- readonly env: Readonly<NodeJS.ProcessEnv>;
229
- readonly signal: AbortSignal;
230
- onTeardown(teardown: ProjectTeardown<TProjectContext>): void;
231
- }
115
+ export { ProjectSetupContext }
232
116
 
233
- export declare interface ProjectSetupDefinition<TProjectContext = unknown> {
234
- name: string;
235
- setup(ctx: ProjectSetupContext<TProjectContext>): Awaitable<TProjectContext>;
236
- }
117
+ export { ProjectSetupDefinition }
237
118
 
238
- export declare type ProjectTeardown<TProjectContext = unknown> = (ctx: ProjectTeardownContext<TProjectContext>) => Awaitable<void>;
119
+ export { ProjectTeardown }
239
120
 
240
- export declare interface ProjectTeardownContext<TProjectContext = unknown> {
241
- readonly project: ResolvedExecutionProject<TProjectContext>;
242
- readonly context: TProjectContext | undefined;
243
- readonly status: 'success' | 'failed';
244
- readonly setupError?: WorkflowError;
245
- }
121
+ export { ProjectTeardownContext }
246
122
 
247
- export declare interface ResolvedExecutionProject<TProjectContext = unknown> {
248
- readonly projectId: string;
249
- readonly name: string;
250
- readonly setup?: ProjectSetupDefinition<TProjectContext>;
251
- readonly files?: TestFileSelection;
252
- readonly tags: Readonly<Required<TestTagSelection>>;
253
- readonly retry: number;
254
- readonly variables: Readonly<Record<string, JsonValue>>;
255
- }
123
+ export { ResolvedExecutionProject }
256
124
 
257
125
  export declare interface ResolvedTestOptions {
258
126
  maxConcurrency: number;
@@ -264,29 +132,17 @@ export declare interface ResolvedTestOutputDefinition {
264
132
  reportDir: string;
265
133
  }
266
134
 
135
+ /** Native Test entry for cases/steps workflow documents. */
267
136
  export declare function runTestProject(options?: TestProjectRunOptions): Promise<TestProjectRunResult>;
268
137
 
269
- declare interface StepRunResult<TOutputData = unknown> {
270
- phase: NodeExecutionPhase;
271
- stepIndex: number;
272
- node: string;
273
- input: unknown;
138
+ declare type StepRunResult<TData = unknown> = Omit<Core.StepRunResult<TData>, 'meta'> & {
274
139
  meta: NormalizedStepMeta;
275
- status: 'success' | 'failed';
276
- continuedAfterError: boolean;
277
- startedAt: string;
278
- endedAt: string;
279
- durationMs: number;
280
- output?: NodeResult<TOutputData>;
281
- error?: WorkflowError;
282
- report?: {
283
- traces: readonly NodeReportTrace[];
284
- };
285
- }
140
+ };
286
141
 
287
142
  export declare interface TestExecutionProjectRunResult {
288
143
  projectId: string;
289
144
  name: string;
145
+ platform: string;
290
146
  status: 'success' | 'failed';
291
147
  retry: number;
292
148
  fileSelection: TestFileSelection;
@@ -300,10 +156,7 @@ export declare interface TestExecutionProjectRunResult {
300
156
  collectionErrors: readonly TestProjectCollectionError[];
301
157
  }
302
158
 
303
- export declare interface TestFileSelection {
304
- include: readonly string[];
305
- exclude?: readonly string[];
306
- }
159
+ export { TestFileSelection }
307
160
 
308
161
  export declare interface TestOptions {
309
162
  maxConcurrency?: number;
@@ -317,6 +170,7 @@ export declare interface TestOutputDefinition {
317
170
 
318
171
  export declare type TestProjectCaseRunResult = CaseRunOutcome & {
319
172
  documentId: string;
173
+ documentRunId?: string;
320
174
  };
321
175
 
322
176
  export declare interface TestProjectCollectionError {
@@ -361,6 +215,8 @@ export declare interface TestProjectRunResult {
361
215
  cases: readonly TestProjectCaseRunResult[];
362
216
  documents: readonly WorkflowDocumentRunResult[];
363
217
  collectionErrors: readonly TestProjectCollectionError[];
218
+ /** Infrastructure/publication failures; completed Case results stay intact. */
219
+ errors?: readonly WorkflowError[];
364
220
  }
365
221
 
366
222
  export declare interface TestProjectRunSummary {
@@ -374,40 +230,13 @@ export declare interface TestProjectRunSummary {
374
230
  projectFailures: number;
375
231
  }
376
232
 
377
- export declare interface TestTagSelection {
378
- include?: readonly string[];
379
- exclude?: readonly string[];
380
- }
233
+ export { TestTagSelection }
381
234
 
382
235
  export declare const validateTestFileSelection: (value: unknown, label?: string) => TestFileSelection | undefined;
383
236
 
384
- declare interface WorkflowDocumentRunResult {
385
- documentId: string;
386
- documentRunId: string;
387
- projectId: string;
388
- projectName: string;
389
- sourcePath: string;
390
- status: 'success' | 'failed';
391
- startedAt: string;
392
- endedAt: string;
393
- durationMs: number;
237
+ declare type WorkflowDocumentRunResult = Omit<Core.WorkflowDocumentRunResult, 'beforeAll' | 'afterAll' | 'reportSources' | 'reportScopeId'> & {
394
238
  beforeAll: StepRunResult[];
395
239
  afterAll: StepRunResult[];
396
- teardownErrors?: WorkflowError[];
397
- reportPaths?: string[];
398
- }
399
-
400
- declare class WorkflowError extends Error {
401
- readonly code: string;
402
- readonly details?: unknown;
403
- constructor(message: string, options?: WorkflowErrorOptions);
404
- toJSON(): Record<string, unknown>;
405
- }
406
-
407
- declare interface WorkflowErrorOptions {
408
- code?: string;
409
- details?: unknown;
410
- cause?: unknown;
411
- }
240
+ };
412
241
 
413
242
  export { }