@solidxai/core 0.1.22-beta.3 → 0.1.22-beta.5
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 +44 -0
- package/dist/constants/error-messages.d.ts +1 -1
- package/dist/constants/error-messages.d.ts.map +1 -1
- package/dist/constants/error-messages.js +1 -1
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/controllers/admin-embed.controller.d.ts +5 -0
- package/dist/controllers/admin-embed.controller.d.ts.map +1 -0
- package/dist/controllers/admin-embed.controller.js +58 -0
- package/dist/controllers/admin-embed.controller.js.map +1 -0
- package/dist/controllers/agent-registry.controller.d.ts +2 -0
- package/dist/controllers/agent-registry.controller.d.ts.map +1 -1
- package/dist/controllers/agent-registry.controller.js +14 -0
- package/dist/controllers/agent-registry.controller.js.map +1 -1
- package/dist/controllers/agent-session.controller.d.ts +8 -1
- package/dist/controllers/agent-session.controller.d.ts.map +1 -1
- package/dist/controllers/agent-session.controller.js +88 -2
- package/dist/controllers/agent-session.controller.js.map +1 -1
- package/dist/controllers/authentication.controller.d.ts +12 -1
- package/dist/controllers/authentication.controller.d.ts.map +1 -1
- package/dist/controllers/authentication.controller.js +26 -2
- package/dist/controllers/authentication.controller.js.map +1 -1
- package/dist/controllers/test-data.controller.d.ts +12 -0
- package/dist/controllers/test-data.controller.d.ts.map +1 -0
- package/dist/controllers/test-data.controller.js +66 -0
- package/dist/controllers/test-data.controller.js.map +1 -0
- package/dist/controllers/test-data.controller.spec.d.ts +2 -0
- package/dist/controllers/test-data.controller.spec.d.ts.map +1 -0
- package/dist/controllers/test-data.controller.spec.js +78 -0
- package/dist/controllers/test-data.controller.spec.js.map +1 -0
- package/dist/dtos/create-agent-job.dto.d.ts +1 -0
- package/dist/dtos/create-agent-job.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-job.dto.js +8 -1
- package/dist/dtos/create-agent-job.dto.js.map +1 -1
- package/dist/dtos/create-agent-process.dto.d.ts +5 -0
- package/dist/dtos/create-agent-process.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-process.dto.js +37 -1
- package/dist/dtos/create-agent-process.dto.js.map +1 -1
- package/dist/dtos/create-agent-registry.dto.d.ts +5 -0
- package/dist/dtos/create-agent-registry.dto.d.ts.map +1 -1
- package/dist/dtos/create-agent-registry.dto.js +39 -1
- package/dist/dtos/create-agent-registry.dto.js.map +1 -1
- package/dist/dtos/create-agent-session.dto.js +1 -1
- package/dist/dtos/create-agent-session.dto.js.map +1 -1
- package/dist/dtos/test-run-request.dto.d.ts +1 -0
- package/dist/dtos/test-run-request.dto.d.ts.map +1 -1
- package/dist/dtos/test-run-request.dto.js +7 -1
- package/dist/dtos/test-run-request.dto.js.map +1 -1
- package/dist/dtos/update-agent-deployment.dto.d.ts +8 -0
- package/dist/dtos/update-agent-deployment.dto.d.ts.map +1 -0
- package/dist/dtos/update-agent-deployment.dto.js +60 -0
- package/dist/dtos/update-agent-deployment.dto.js.map +1 -0
- package/dist/dtos/update-agent-job.dto.d.ts +1 -0
- package/dist/dtos/update-agent-job.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-job.dto.js +8 -1
- package/dist/dtos/update-agent-job.dto.js.map +1 -1
- package/dist/dtos/update-agent-process.dto.d.ts +5 -0
- package/dist/dtos/update-agent-process.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-process.dto.js +37 -1
- package/dist/dtos/update-agent-process.dto.js.map +1 -1
- package/dist/dtos/update-agent-registry.dto.d.ts +5 -0
- package/dist/dtos/update-agent-registry.dto.d.ts.map +1 -1
- package/dist/dtos/update-agent-registry.dto.js +39 -1
- package/dist/dtos/update-agent-registry.dto.js.map +1 -1
- package/dist/dtos/update-agent-session.dto.js +1 -1
- package/dist/dtos/update-agent-session.dto.js.map +1 -1
- package/dist/entities/agent-job.entity.d.ts +1 -0
- package/dist/entities/agent-job.entity.d.ts.map +1 -1
- package/dist/entities/agent-job.entity.js +7 -2
- package/dist/entities/agent-job.entity.js.map +1 -1
- package/dist/entities/agent-process.entity.d.ts +8 -0
- package/dist/entities/agent-process.entity.d.ts.map +1 -1
- package/dist/entities/agent-process.entity.js +38 -1
- package/dist/entities/agent-process.entity.js.map +1 -1
- package/dist/entities/agent-registry.entity.d.ts +5 -0
- package/dist/entities/agent-registry.entity.d.ts.map +1 -1
- package/dist/entities/agent-registry.entity.js +22 -1
- package/dist/entities/agent-registry.entity.js.map +1 -1
- package/dist/entities/agent-session.entity.d.ts.map +1 -1
- package/dist/entities/agent-session.entity.js +3 -1
- package/dist/entities/agent-session.entity.js.map +1 -1
- package/dist/guards/access-token.guard.d.ts +3 -1
- package/dist/guards/access-token.guard.d.ts.map +1 -1
- package/dist/guards/access-token.guard.js +11 -2
- package/dist/guards/access-token.guard.js.map +1 -1
- package/dist/helpers/agent-config-version-name.d.ts +2 -0
- package/dist/helpers/agent-config-version-name.d.ts.map +1 -0
- package/dist/helpers/agent-config-version-name.js +17 -0
- package/dist/helpers/agent-config-version-name.js.map +1 -0
- package/dist/helpers/agent-config-version-name.spec.d.ts +2 -0
- package/dist/helpers/agent-config-version-name.spec.d.ts.map +1 -0
- package/dist/helpers/agent-config-version-name.spec.js +31 -0
- package/dist/helpers/agent-config-version-name.spec.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/active-user-data.interface.d.ts +1 -0
- package/dist/interfaces/active-user-data.interface.d.ts.map +1 -1
- package/dist/interfaces/active-user-data.interface.js.map +1 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js +8 -4
- package/dist/jobs/database/test-run-queue-subscriber-database.service.js.map +1 -1
- package/dist/resources/admin-embed/solid-admin-embed.js +133 -0
- package/dist/resources/agent-embed/solid-agent-embed.js +243 -4
- package/dist/seeders/module-test-data.service.d.ts +19 -0
- package/dist/seeders/module-test-data.service.d.ts.map +1 -1
- package/dist/seeders/module-test-data.service.js +95 -15
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/seeders/module-test-data.service.spec.d.ts +2 -0
- package/dist/seeders/module-test-data.service.spec.d.ts.map +1 -0
- package/dist/seeders/module-test-data.service.spec.js +158 -0
- package/dist/seeders/module-test-data.service.spec.js.map +1 -0
- package/dist/seeders/seed-data/solid-core-metadata.json +375 -11
- package/dist/services/agent-hub-process-manager.service.d.ts +16 -0
- package/dist/services/agent-hub-process-manager.service.d.ts.map +1 -1
- package/dist/services/agent-hub-process-manager.service.js +27 -3
- package/dist/services/agent-hub-process-manager.service.js.map +1 -1
- package/dist/services/agent-registry.service.d.ts +2 -0
- package/dist/services/agent-registry.service.d.ts.map +1 -1
- package/dist/services/agent-registry.service.js +36 -1
- package/dist/services/agent-registry.service.js.map +1 -1
- package/dist/services/api-key-portal-session.spec.d.ts +2 -0
- package/dist/services/api-key-portal-session.spec.d.ts.map +1 -0
- package/dist/services/api-key-portal-session.spec.js +71 -0
- package/dist/services/api-key-portal-session.spec.js.map +1 -0
- package/dist/services/api-key.service.d.ts +12 -0
- package/dist/services/api-key.service.d.ts.map +1 -1
- package/dist/services/api-key.service.js +58 -0
- package/dist/services/api-key.service.js.map +1 -1
- package/dist/services/authentication.service.d.ts +1 -0
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +14 -1
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/crud.service.d.ts +1 -0
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js +26 -2
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +16 -6
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +9 -3
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +5 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/testing/adapters/ui/browser-provisioner.d.ts +11 -0
- package/dist/testing/adapters/ui/browser-provisioner.d.ts.map +1 -1
- package/dist/testing/adapters/ui/browser-provisioner.js +51 -1
- package/dist/testing/adapters/ui/browser-provisioner.js.map +1 -1
- package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts +2 -0
- package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts.map +1 -0
- package/dist/testing/adapters/ui/browser-provisioner.spec.js +137 -0
- package/dist/testing/adapters/ui/browser-provisioner.spec.js.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +7 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
- package/dist/testing/adapters/ui/playwright-adapter.js +40 -9
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
- package/dist/testing/adapters/ui/run-video.d.ts +40 -0
- package/dist/testing/adapters/ui/run-video.d.ts.map +1 -0
- package/dist/testing/adapters/ui/run-video.js +113 -0
- package/dist/testing/adapters/ui/run-video.js.map +1 -0
- package/dist/testing/adapters/ui/run-video.spec.d.ts +2 -0
- package/dist/testing/adapters/ui/run-video.spec.d.ts.map +1 -0
- package/dist/testing/adapters/ui/run-video.spec.js +62 -0
- package/dist/testing/adapters/ui/run-video.spec.js.map +1 -0
- package/dist/testing/contracts/runtime-context.types.d.ts +7 -0
- package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -1
- package/dist/testing/contracts/runtime-context.types.js.map +1 -1
- package/dist/testing/contracts/testing-metadata.types.d.ts +1 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -1
- package/dist/testing/contracts/testing-metadata.types.js.map +1 -1
- package/dist/testing/core/interpolation.d.ts.map +1 -1
- package/dist/testing/core/interpolation.js +14 -2
- package/dist/testing/core/interpolation.js.map +1 -1
- package/dist/testing/core/step-data.d.ts +5 -0
- package/dist/testing/core/step-data.d.ts.map +1 -0
- package/dist/testing/core/step-data.js +14 -0
- package/dist/testing/core/step-data.js.map +1 -0
- package/dist/testing/core/step-data.spec.d.ts +2 -0
- package/dist/testing/core/step-data.spec.d.ts.map +1 -0
- package/dist/testing/core/step-data.spec.js +48 -0
- package/dist/testing/core/step-data.spec.js.map +1 -0
- package/dist/testing/core/testing-engine.d.ts +1 -1
- package/dist/testing/core/testing-engine.d.ts.map +1 -1
- package/dist/testing/core/testing-engine.js +27 -4
- package/dist/testing/core/testing-engine.js.map +1 -1
- package/dist/testing/reporter/lifecycle-events.types.d.ts +3 -2
- package/dist/testing/reporter/lifecycle-events.types.d.ts.map +1 -1
- package/dist/testing/reporter/lifecycle-events.types.js.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts +2 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts.map +1 -1
- package/dist/testing/reporter/lifecycle-webhook-reporter.js +3 -0
- package/dist/testing/reporter/lifecycle-webhook-reporter.js.map +1 -1
- package/dist/testing/reporter/reporter.types.d.ts +2 -1
- package/dist/testing/reporter/reporter.types.d.ts.map +1 -1
- package/dist/testing/reporter/reporter.types.js.map +1 -1
- package/dist/testing/runner/read-scenarios-file.d.ts +1 -0
- package/dist/testing/runner/read-scenarios-file.d.ts.map +1 -1
- package/dist/testing/runner/read-scenarios-file.js +20 -0
- package/dist/testing/runner/read-scenarios-file.js.map +1 -1
- package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
- package/dist/testing/runner/run-from-metadata.js +48 -10
- package/dist/testing/runner/run-from-metadata.js.map +1 -1
- package/dist/testing/runner/run-from-metadata.spec.js +41 -1
- package/dist/testing/runner/run-from-metadata.spec.js.map +1 -1
- package/dist/testing/runner/scenario-graph.d.ts +9 -0
- package/dist/testing/runner/scenario-graph.d.ts.map +1 -1
- package/dist/testing/runner/scenario-graph.js +47 -13
- package/dist/testing/runner/scenario-graph.js.map +1 -1
- package/dist/testing/steps/ui/navigation.step.d.ts.map +1 -1
- package/dist/testing/steps/ui/navigation.step.js +4 -1
- package/dist/testing/steps/ui/navigation.step.js.map +1 -1
- package/dist/testing/steps/util/random.step.d.ts.map +1 -1
- package/dist/testing/steps/util/random.step.js +4 -1
- package/dist/testing/steps/util/random.step.js.map +1 -1
- package/package.json +1 -1
- package/resources/admin-embed/solid-admin-embed.js +133 -0
- package/resources/agent-embed/solid-agent-embed.js +243 -4
- package/src/constants/error-messages.ts +2 -1
- package/src/controllers/admin-embed.controller.ts +34 -0
- package/src/controllers/agent-registry.controller.ts +8 -1
- package/src/controllers/agent-session.controller.ts +53 -2
- package/src/controllers/authentication.controller.ts +20 -1
- package/src/controllers/test-data.controller.spec.ts +94 -0
- package/src/controllers/test-data.controller.ts +58 -0
- package/src/dtos/create-agent-job.dto.ts +6 -0
- package/src/dtos/create-agent-process.dto.ts +32 -1
- package/src/dtos/create-agent-registry.dto.ts +34 -1
- package/src/dtos/create-agent-session.dto.ts +1 -1
- package/src/dtos/test-run-request.dto.ts +6 -0
- package/src/dtos/update-agent-deployment.dto.ts +37 -0
- package/src/dtos/update-agent-job.dto.ts +6 -0
- package/src/dtos/update-agent-process.dto.ts +32 -1
- package/src/dtos/update-agent-registry.dto.ts +34 -1
- package/src/dtos/update-agent-session.dto.ts +1 -1
- package/src/entities/agent-job.entity.ts +5 -1
- package/src/entities/agent-process.entity.ts +28 -0
- package/src/entities/agent-registry.entity.ts +15 -0
- package/src/entities/agent-session.entity.ts +3 -0
- package/src/guards/access-token.guard.ts +11 -1
- package/src/helpers/agent-config-version-name.spec.ts +35 -0
- package/src/helpers/agent-config-version-name.ts +16 -0
- package/src/index.ts +5 -0
- package/src/interfaces/active-user-data.interface.ts +3 -0
- package/src/jobs/database/test-run-queue-subscriber-database.service.ts +10 -6
- package/src/seeders/module-test-data.service.spec.ts +184 -0
- package/src/seeders/module-test-data.service.ts +136 -20
- package/src/seeders/seed-data/solid-core-metadata.json +376 -12
- package/src/services/agent-hub-process-manager.service.ts +35 -4
- package/src/services/agent-registry.service.ts +38 -2
- package/src/services/api-key-portal-session.spec.ts +75 -0
- package/src/services/api-key.service.ts +61 -0
- package/src/services/authentication.service.ts +16 -2
- package/src/services/crud.service.ts +30 -2
- package/src/services/settings/default-settings-provider.service.ts +13 -3
- package/src/solid-core.module.ts +5 -0
- package/src/testing/adapters/ui/browser-provisioner.spec.ts +131 -0
- package/src/testing/adapters/ui/browser-provisioner.ts +85 -2
- package/src/testing/adapters/ui/playwright-adapter.ts +53 -11
- package/src/testing/adapters/ui/run-video.spec.ts +72 -0
- package/src/testing/adapters/ui/run-video.ts +122 -0
- package/src/testing/contracts/runtime-context.types.ts +16 -0
- package/src/testing/contracts/testing-metadata.types.ts +5 -0
- package/src/testing/core/interpolation.ts +11 -2
- package/src/testing/core/step-data.spec.ts +59 -0
- package/src/testing/core/step-data.ts +14 -0
- package/src/testing/core/testing-engine.ts +33 -5
- package/src/testing/reporter/lifecycle-events.types.ts +5 -2
- package/src/testing/reporter/lifecycle-webhook-reporter.ts +4 -1
- package/src/testing/reporter/reporter.types.ts +3 -1
- package/src/testing/runner/read-scenarios-file.ts +24 -0
- package/src/testing/runner/run-from-metadata.spec.ts +48 -1
- package/src/testing/runner/run-from-metadata.ts +66 -21
- package/src/testing/runner/scenario-graph.ts +55 -12
- package/src/testing/steps/ui/navigation.step.ts +4 -1
- package/src/testing/steps/util/random.step.ts +4 -1
|
@@ -19,6 +19,16 @@ function stepPathFor(block, blockIndex, stepIndex) {
|
|
|
19
19
|
}
|
|
20
20
|
return base;
|
|
21
21
|
}
|
|
22
|
+
function withStepTimeout(step, stepTimeoutMs) {
|
|
23
|
+
if (typeof stepTimeoutMs !== "number" || !Number.isFinite(stepTimeoutMs) || stepTimeoutMs <= 0)
|
|
24
|
+
return step;
|
|
25
|
+
if (step.timeoutMs !== undefined || step.with?.timeoutMs !== undefined)
|
|
26
|
+
return step;
|
|
27
|
+
if (step.op.startsWith("ui.") || step.op.startsWith("mobile.")) {
|
|
28
|
+
return { ...step, with: { ...(step.with ?? {}), timeoutMs: stepTimeoutMs } };
|
|
29
|
+
}
|
|
30
|
+
return { ...step, timeoutMs: stepTimeoutMs };
|
|
31
|
+
}
|
|
22
32
|
const SLOW_CALL_REPORT_MS = 2000;
|
|
23
33
|
class TestingEngine {
|
|
24
34
|
constructor(registry, defaults) {
|
|
@@ -58,7 +68,7 @@ class TestingEngine {
|
|
|
58
68
|
for (const [blockIndex, block] of scenario.steps.entries()) {
|
|
59
69
|
const normalized = (0, normalize_steps_1.normalizeBlock)(block);
|
|
60
70
|
for (const [stepIndex, step] of normalized.steps.entries()) {
|
|
61
|
-
await this.runStep(normalized.phase, step, ctx, stepPathFor(block, blockIndex, stepIndex));
|
|
71
|
+
await this.runStep(normalized.phase, step, ctx, stepPathFor(block, blockIndex, stepIndex), undefined, scenario.stepTimeoutMs);
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
};
|
|
@@ -104,6 +114,15 @@ class TestingEngine {
|
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
const durationMs = Date.now() - scenarioStart;
|
|
117
|
+
if (scenario.type === "ui")
|
|
118
|
+
ctx.ui?.recordScenario({
|
|
119
|
+
scenarioId: scenario.id,
|
|
120
|
+
name: scenario.name,
|
|
121
|
+
attempt,
|
|
122
|
+
ok: !scenarioError,
|
|
123
|
+
startedAt: scenarioStart,
|
|
124
|
+
endedAt: scenarioStart + durationMs,
|
|
125
|
+
});
|
|
107
126
|
const heals = [...(ctx.ui?.getHeals() ?? []), ...(ctx.mobile?.getHeals() ?? [])];
|
|
108
127
|
reporter.onScenarioEnd(scenario, {
|
|
109
128
|
ok: !scenarioError,
|
|
@@ -133,7 +152,7 @@ class TestingEngine {
|
|
|
133
152
|
for (const [stepIndex, step] of normalized.steps.entries()) {
|
|
134
153
|
const stepPath = stepPathFor(block, blockIndex, stepIndex);
|
|
135
154
|
try {
|
|
136
|
-
await this.runStep(normalized.phase, step, partCtx, stepPath, part.kind);
|
|
155
|
+
await this.runStep(normalized.phase, step, partCtx, stepPath, part.kind, part.scenario.stepTimeoutMs);
|
|
137
156
|
}
|
|
138
157
|
catch (err) {
|
|
139
158
|
const failure = new Error(`Setup "${part.kind}" (scenario "${part.scenario.id}") failed at ${stepPath}: ${err?.message ?? err}`);
|
|
@@ -157,16 +176,17 @@ class TestingEngine {
|
|
|
157
176
|
const kept = Object.fromEntries(raw.map((field) => [field, step.with[field]]));
|
|
158
177
|
return { ...resolved, with: { ...resolved.with, ...kept } };
|
|
159
178
|
}
|
|
160
|
-
async runStep(phase, step, ctx, stepPath, setup) {
|
|
179
|
+
async runStep(phase, step, ctx, stepPath, setup, stepTimeoutMs) {
|
|
161
180
|
const reporter = ctx.reporter;
|
|
162
181
|
const stepStart = Date.now();
|
|
163
182
|
let stepError;
|
|
164
183
|
let resolvedStep;
|
|
165
184
|
let result;
|
|
166
185
|
ctx.stepPath = stepPath;
|
|
186
|
+
ctx.stepData = [];
|
|
167
187
|
reporter.onStepStart({ scenarioId: ctx.scenarioId, phase, step, stepPath, ...(setup ? { setup } : {}) });
|
|
168
188
|
try {
|
|
169
|
-
resolvedStep = this.resolveStep(step, ctx);
|
|
189
|
+
resolvedStep = withStepTimeout(this.resolveStep(step, ctx), stepTimeoutMs);
|
|
170
190
|
const handler = this.registry.get(resolvedStep.op);
|
|
171
191
|
const run = handler(ctx, resolvedStep);
|
|
172
192
|
result =
|
|
@@ -185,6 +205,8 @@ class TestingEngine {
|
|
|
185
205
|
finally {
|
|
186
206
|
const durationMs = Date.now() - stepStart;
|
|
187
207
|
const slowestCallMs = ctx.mobile?.takeSlowestCallMs() ?? 0;
|
|
208
|
+
const data = ctx.stepData ?? [];
|
|
209
|
+
ctx.stepData = undefined;
|
|
188
210
|
reporter.onStepEnd({
|
|
189
211
|
scenarioId: ctx.scenarioId,
|
|
190
212
|
phase,
|
|
@@ -194,6 +216,7 @@ class TestingEngine {
|
|
|
194
216
|
durationMs,
|
|
195
217
|
stepPath,
|
|
196
218
|
...(slowestCallMs >= SLOW_CALL_REPORT_MS ? { slowestCallMs } : {}),
|
|
219
|
+
...(data.length ? { data } : {}),
|
|
197
220
|
...(setup ? { setup } : {}),
|
|
198
221
|
});
|
|
199
222
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-engine.js","sourceRoot":"","sources":["../../../src/testing/core/testing-engine.ts"],"names":[],"mappings":";;;AAYA,kCASC;AAnBD,mDAAkD;AAClD,uDAAmD;AAEnD,mDAA0D;AAC1D,uCAAwC;AAMxC,SAAgB,WAAW,CAAC,KAAgB,EAAE,UAAkB,EAAE,SAAiB;IACjF,MAAM,IAAI,GAAG,SAAS,UAAU,GAAG,CAAC;IACpC,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,GAAG,IAAI,QAAQ,CAAC;IAC7C,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,GAAG,IAAI,OAAO,CAAC;IAC3C,IAAI,KAAK,IAAI,KAAK;QAAE,OAAO,GAAG,IAAI,MAAM,CAAC;IACzC,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC;IACnF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAsBD,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAa,aAAa;IAIxB,YACE,QAAsB,EACtB,QAAmD;QAEnD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,WAAW,CACf,QAAsB,EACtB,OAAoE,EACpE,QAAyB,EAAE;QAE3B,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,CAAC;QAChE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAA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E,GAAG,SAAS,CAAC;YAE1C,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;YAC3D,QAAQ,CAAC,SAAS,CAAC;gBACjB,UAAU,EAAE,GAAG,CAAC,UAAU;gBAC1B,KAAK;gBACL,IAAI,EAAE,YAAY,IAAI,IAAI;gBAC1B,EAAE,EAAE,CAAC,SAAS;gBACd,KAAK,EAAE,SAAS;gBAChB,UAAU;gBACV,QAAQ;gBACR,GAAG,CAAC,aAAa,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAhOD,sCAgOC","sourcesContent":["import type { TestContext, StepPhase } from \"../contracts/runtime-context.types\";\nimport type { OpStep, ScenarioSpec, StepBlock } from \"../contracts/testing-metadata.types\";\nimport { interpolateDeep } from \"./interpolation\";\nimport { normalizeBlock } from \"./normalize-steps\";\nimport { StepRegistry } from \"./step-registry\";\nimport { scenarioNeedsMobile } from \"../runner/lifecycle\";\nimport { withTimeout } from \"./timeout\";\n\n/**\n * Path of a step inside `scenario.steps`, matching the file layout so a consumer can\n * patch the exact step: `steps[2]`, `steps[3].when`, `steps[5].then[1]`.\n */\nexport function stepPathFor(block: StepBlock, blockIndex: number, stepIndex: number): string {\n const base = `steps[${blockIndex}]`;\n if (\"given\" in block) return `${base}.given`;\n if (\"when\" in block) return `${base}.when`;\n if (\"and\" in block) return `${base}.and`;\n if (\"then\" in block) {\n return Array.isArray(block.then) ? `${base}.then[${stepIndex}]` : `${base}.then`;\n }\n return base;\n}\n\n/**\n * Steps that run before a scenario's own, as part of that scenario's report: bringing a phone back to its start screen,\n * or logging in again, so the scenario does not depend on what ran before it. They keep the scenario they come from\n * (`scenario.id`, and `steps[n]` paths inside it), so a heal found in them can be applied to that scenario's file.\n */\nexport interface ScenarioSetup {\n /** What the steps are for, reported with each one: \"reset\", \"login\". */\n kind: string;\n scenario: ScenarioSpec;\n /** Resolved secret values for the steps' `${secret:...}` tokens. */\n secrets?: Record<string, any>;\n /**\n * After the steps have run, look for this element on the device. When it shows within `timeoutMs` the setup is over; when it\n * does not, `orElse` runs in its place. It is how a restore avoids replaying a login the app is still in.\n */\n probe?: { locator: unknown; timeoutMs: number };\n orElse?: ScenarioSetup[];\n}\n\n/** A device lookup slower than this is reported with its step. */\nconst SLOW_CALL_REPORT_MS = 2000;\n\nexport class TestingEngine {\n private readonly registry: StepRegistry;\n private readonly defaults?: { timeoutMs?: number; retries?: number };\n\n constructor(\n registry: StepRegistry,\n defaults?: { timeoutMs?: number; retries?: number },\n ) {\n this.registry = registry;\n this.defaults = defaults;\n }\n\n async runScenario(\n scenario: ScenarioSpec,\n ctxBase: Omit<TestContext, \"scenarioId\" | \"scenarioType\" | \"params\">,\n setup: ScenarioSetup[] = [],\n ): Promise<void> {\n const retries = scenario.retries ?? this.defaults?.retries ?? 0;\n const maxAttempts = Math.max(0, retries) + 1;\n const scenarioTimeoutMs =\n scenario.timeoutMs ?? this.defaults?.timeoutMs;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {\n const ctx: TestContext = {\n ...ctxBase,\n scenarioId: scenario.id,\n scenarioType: scenario.type,\n params: scenario.params ?? {},\n };\n\n const reporter = ctx.reporter;\n const scenarioStart = Date.now();\n let scenarioError: unknown;\n\n reporter.onScenarioStart(scenario);\n // Start a clean capture window for this scenario (UI adapter buffers console/network\n // events; they're only flushed to the reporter if the scenario fails below).\n ctx.ui?.resetCapture();\n const usesMobile = scenarioNeedsMobile(scenario) && !!ctx.mobile?.isStarted();\n if (usesMobile) await ctx.mobile?.resetCapture();\n\n try {\n const execute = async () => {\n for (const part of setup) {\n await this.runSetup(part, ctx);\n // A probe is a question, not a step: a missing element is an answer, and is not reported as a failure.\n if (part.probe) {\n // Showing is what counts, as for an expectVisible. Any failure to find it, or to get an answer in time, is a \"no\".\n const there = await ctx.mobile?.findDisplayed(part.probe.locator, part.probe.timeoutMs).then(() => true, () => false);\n if (!there) for (const fallback of part.orElse ?? []) await this.runSetup(fallback, ctx);\n }\n }\n for (const [blockIndex, block] of scenario.steps.entries()) {\n const normalized = normalizeBlock(block);\n for (const [stepIndex, step] of normalized.steps.entries()) {\n await this.runStep(normalized.phase, step, ctx, stepPathFor(block, blockIndex, stepIndex));\n }\n }\n };\n\n if (scenarioTimeoutMs !== undefined) {\n await withTimeout(\n execute(),\n scenarioTimeoutMs,\n `Scenario timeout after ${scenarioTimeoutMs}ms: \"${scenario.id}\"`,\n );\n } else {\n await execute();\n }\n } catch (err: any) {\n scenarioError = err;\n } finally {\n // On failure, flush the UI adapter's captured artifacts (console + network) BEFORE\n // onScenarioEnd — the lifecycle reporter snapshots the attached artifacts inside\n // onScenarioEnd. No page (e.g. API scenarios) → nothing captured.\n if (scenarioError && ctx.ui?.page && reporter.attach) {\n try {\n const artifacts = await ctx.ui.collectFailureArtifacts();\n for (const a of artifacts) {\n reporter.attach({\n scenarioId: ctx.scenarioId,\n name: a.name,\n contentType: a.contentType,\n data: a.data,\n });\n }\n } catch {\n // Artifact capture is best-effort; never let it mask the scenario error.\n }\n }\n\n // Same for a mobile scenario: device log and a screenshot of the failing screen.\n if (scenarioError && usesMobile && reporter.attach) {\n try {\n const artifacts = (await ctx.mobile?.collectFailureArtifacts()) ?? [];\n for (const a of artifacts) {\n reporter.attach({\n scenarioId: ctx.scenarioId,\n name: a.name,\n contentType: a.contentType,\n data: a.data,\n });\n }\n } catch {\n // Best-effort, like the UI artifacts above.\n }\n }\n\n const durationMs = Date.now() - scenarioStart;\n const heals = [...(ctx.ui?.getHeals() ?? []), ...(ctx.mobile?.getHeals() ?? [])];\n reporter.onScenarioEnd(scenario, {\n ok: !scenarioError,\n error: scenarioError,\n durationMs,\n ...(heals.length ? { heals } : {}),\n });\n }\n\n if (!scenarioError) {\n return;\n }\n\n if (attempt >= maxAttempts) {\n throw scenarioError;\n }\n }\n }\n\n /** Runs one setup part's steps in the part's own scenario context, and names the part when one of them fails. */\n private async runSetup(part: ScenarioSetup, ctx: TestContext): Promise<void> {\n const partCtx: TestContext = {\n ...ctx,\n scenarioId: part.scenario.id,\n scenarioType: part.scenario.type,\n params: part.scenario.params ?? {},\n secrets: part.secrets,\n };\n for (const [blockIndex, block] of part.scenario.steps.entries()) {\n const normalized = normalizeBlock(block);\n for (const [stepIndex, step] of normalized.steps.entries()) {\n const stepPath = stepPathFor(block, blockIndex, stepIndex);\n try {\n await this.runStep(normalized.phase, step, partCtx, stepPath, part.kind);\n } catch (err: any) {\n const failure = new Error(`Setup \"${part.kind}\" (scenario \"${part.scenario.id}\") failed at ${stepPath}: ${err?.message ?? err}`);\n (failure as Error & { cause?: unknown }).cause = err;\n throw failure;\n }\n }\n }\n }\n\n // Interpolates the step, except the `with` fields its op takes as written (StepOptions.rawWith).\n private resolveStep(step: OpStep, ctx: TestContext): OpStep {\n const raw = this.registry\n .rawWithFields(step.op)\n .filter((field) => step.with && typeof step.with === \"object\" && field in step.with);\n if (!raw.length) {\n return interpolateDeep(step, ctx);\n }\n const rest = { ...step.with };\n for (const field of raw) delete rest[field];\n const resolved = interpolateDeep({ ...step, with: rest }, ctx);\n const kept = Object.fromEntries(raw.map((field) => [field, step.with![field]]));\n return { ...resolved, with: { ...resolved.with, ...kept } };\n }\n\n /**\n * Run one step exactly as a scenario would: interpolate, dispatch, honor `timeoutMs`,\n * store `saveAs`, and report start/end. Throws the step's error.\n */\n async runStep(\n phase: StepPhase,\n step: OpStep,\n ctx: TestContext,\n stepPath?: string,\n setup?: string,\n ): Promise<unknown> {\n const reporter = ctx.reporter;\n const stepStart = Date.now();\n let stepError: unknown;\n let resolvedStep: OpStep | undefined;\n let result: unknown;\n\n ctx.stepPath = stepPath;\n reporter.onStepStart({ scenarioId: ctx.scenarioId, phase, step, stepPath, ...(setup ? { setup } : {}) });\n\n try {\n resolvedStep = this.resolveStep(step, ctx);\n const handler = this.registry.get(resolvedStep.op);\n const run = handler(ctx, resolvedStep);\n result =\n resolvedStep.timeoutMs !== undefined\n ? await withTimeout(\n run,\n resolvedStep.timeoutMs,\n `Step timeout after ${resolvedStep.timeoutMs}ms: \"${resolvedStep.op}\"`,\n )\n : await run;\n\n if (resolvedStep.saveAs) {\n ctx.resources.set(resolvedStep.saveAs, result);\n }\n return result;\n } catch (err: any) {\n stepError = err;\n throw err;\n } finally {\n const durationMs = Date.now() - stepStart;\n // Taken for every mobile step so the figure never carries over; only a slow one is worth reporting.\n const slowestCallMs = ctx.mobile?.takeSlowestCallMs() ?? 0;\n reporter.onStepEnd({\n scenarioId: ctx.scenarioId,\n phase,\n step: resolvedStep ?? step,\n ok: !stepError,\n error: stepError,\n durationMs,\n stepPath,\n ...(slowestCallMs >= SLOW_CALL_REPORT_MS ? { slowestCallMs } : {}),\n ...(setup ? { setup } : {}),\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testing-engine.js","sourceRoot":"","sources":["../../../src/testing/core/testing-engine.ts"],"names":[],"mappings":";;;AAYA,kCASC;AAnBD,mDAAkD;AAClD,uDAAmD;AAEnD,mDAA0D;AAC1D,uCAAwC;AAMxC,SAAgB,WAAW,CAAC,KAAgB,EAAE,UAAkB,EAAE,SAAiB;IACjF,MAAM,IAAI,GAAG,SAAS,UAAU,GAAG,CAAC;IACpC,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,GAAG,IAAI,QAAQ,CAAC;IAC7C,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,GAAG,IAAI,OAAO,CAAC;IAC3C,IAAI,KAAK,IAAI,KAAK;QAAE,OAAO,GAAG,IAAI,MAAM,CAAC;IACzC,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC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runtime-context.types\";\nimport type { OpStep, ScenarioSpec, StepBlock } from \"../contracts/testing-metadata.types\";\nimport { interpolateDeep } from \"./interpolation\";\nimport { normalizeBlock } from \"./normalize-steps\";\nimport { StepRegistry } from \"./step-registry\";\nimport { scenarioNeedsMobile } from \"../runner/lifecycle\";\nimport { withTimeout } from \"./timeout\";\n\n/**\n * Path of a step inside `scenario.steps`, matching the file layout so a consumer can\n * patch the exact step: `steps[2]`, `steps[3].when`, `steps[5].then[1]`.\n */\nexport function stepPathFor(block: StepBlock, blockIndex: number, stepIndex: number): string {\n const base = `steps[${blockIndex}]`;\n if (\"given\" in block) return `${base}.given`;\n if (\"when\" in block) return `${base}.when`;\n if (\"and\" in block) return `${base}.and`;\n if (\"then\" in block) {\n return Array.isArray(block.then) ? `${base}.then[${stepIndex}]` : `${base}.then`;\n }\n return base;\n}\n\n/**\n * Steps that run before a scenario's own, as part of that scenario's report: bringing a phone back to its start screen,\n * or logging in again, so the scenario does not depend on what ran before it. They keep the scenario they come from\n * (`scenario.id`, and `steps[n]` paths inside it), so a heal found in them can be applied to that scenario's file.\n */\nexport interface ScenarioSetup {\n /** What the steps are for, reported with each one: \"reset\", \"login\". */\n kind: string;\n scenario: ScenarioSpec;\n /** Resolved secret values for the steps' `${secret:...}` tokens. */\n secrets?: Record<string, any>;\n /**\n * After the steps have run, look for this element on the device. When it shows within `timeoutMs` the setup is over; when it\n * does not, `orElse` runs in its place. It is how a restore avoids replaying a login the app is still in.\n */\n probe?: { locator: unknown; timeoutMs: number };\n orElse?: ScenarioSetup[];\n}\n\n/**\n * `step` with the scenario's step timeout, unless it sets its own. Browser and device steps take it as their wait\n * (`with.timeoutMs`, which their Playwright and Appium calls use); any other step is cut off after it.\n */\nfunction withStepTimeout(step: OpStep, stepTimeoutMs?: number): OpStep {\n if (typeof stepTimeoutMs !== \"number\" || !Number.isFinite(stepTimeoutMs) || stepTimeoutMs <= 0) return step;\n if (step.timeoutMs !== undefined || step.with?.timeoutMs !== undefined) return step;\n if (step.op.startsWith(\"ui.\") || step.op.startsWith(\"mobile.\")) {\n return { ...step, with: { ...(step.with ?? {}), timeoutMs: stepTimeoutMs } };\n }\n return { ...step, timeoutMs: stepTimeoutMs };\n}\n\n/** A device lookup slower than this is reported with its step. */\nconst SLOW_CALL_REPORT_MS = 2000;\n\nexport class TestingEngine {\n private readonly registry: StepRegistry;\n private readonly defaults?: { timeoutMs?: number; retries?: number };\n\n constructor(\n registry: StepRegistry,\n defaults?: { timeoutMs?: number; retries?: number },\n ) {\n this.registry = registry;\n this.defaults = defaults;\n }\n\n async runScenario(\n scenario: ScenarioSpec,\n ctxBase: Omit<TestContext, \"scenarioId\" | \"scenarioType\" | \"params\">,\n setup: ScenarioSetup[] = [],\n ): Promise<void> {\n const retries = scenario.retries ?? this.defaults?.retries ?? 0;\n const maxAttempts = Math.max(0, retries) + 1;\n const scenarioTimeoutMs =\n scenario.timeoutMs ?? this.defaults?.timeoutMs;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {\n const ctx: TestContext = {\n ...ctxBase,\n scenarioId: scenario.id,\n scenarioType: scenario.type,\n params: scenario.params ?? {},\n };\n\n const reporter = ctx.reporter;\n const scenarioStart = Date.now();\n let scenarioError: unknown;\n\n reporter.onScenarioStart(scenario);\n // Start a clean capture window for this scenario (UI adapter buffers console/network\n // events; they're only flushed to the reporter if the scenario fails below).\n ctx.ui?.resetCapture();\n const usesMobile = scenarioNeedsMobile(scenario) && !!ctx.mobile?.isStarted();\n if (usesMobile) await ctx.mobile?.resetCapture();\n\n try {\n const execute = async () => {\n for (const part of setup) {\n await this.runSetup(part, ctx);\n // A probe is a question, not a step: a missing element is an answer, and is not reported as a failure.\n if (part.probe) {\n // Showing is what counts, as for an expectVisible. Any failure to find it, or to get an answer in time, is a \"no\".\n const there = await ctx.mobile?.findDisplayed(part.probe.locator, part.probe.timeoutMs).then(() => true, () => false);\n if (!there) for (const fallback of part.orElse ?? []) await this.runSetup(fallback, ctx);\n }\n }\n for (const [blockIndex, block] of scenario.steps.entries()) {\n const normalized = normalizeBlock(block);\n for (const [stepIndex, step] of normalized.steps.entries()) {\n await this.runStep(normalized.phase, step, ctx, stepPathFor(block, blockIndex, stepIndex), undefined, scenario.stepTimeoutMs);\n }\n }\n };\n\n if (scenarioTimeoutMs !== undefined) {\n await withTimeout(\n execute(),\n scenarioTimeoutMs,\n `Scenario timeout after ${scenarioTimeoutMs}ms: \"${scenario.id}\"`,\n );\n } else {\n await execute();\n }\n } catch (err: any) {\n scenarioError = err;\n } finally {\n // On failure, flush the UI adapter's captured artifacts (console + network) BEFORE\n // onScenarioEnd — the lifecycle reporter snapshots the attached artifacts inside\n // onScenarioEnd. No page (e.g. API scenarios) → nothing captured.\n if (scenarioError && ctx.ui?.page && reporter.attach) {\n try {\n const artifacts = await ctx.ui.collectFailureArtifacts();\n for (const a of artifacts) {\n reporter.attach({\n scenarioId: ctx.scenarioId,\n name: a.name,\n contentType: a.contentType,\n data: a.data,\n });\n }\n } catch {\n // Artifact capture is best-effort; never let it mask the scenario error.\n }\n }\n\n // Same for a mobile scenario: device log and a screenshot of the failing screen.\n if (scenarioError && usesMobile && reporter.attach) {\n try {\n const artifacts = (await ctx.mobile?.collectFailureArtifacts()) ?? [];\n for (const a of artifacts) {\n reporter.attach({\n scenarioId: ctx.scenarioId,\n name: a.name,\n contentType: a.contentType,\n data: a.data,\n });\n }\n } catch {\n // Best-effort, like the UI artifacts above.\n }\n }\n\n const durationMs = Date.now() - scenarioStart;\n // Only browser scenarios are in the run video: an API scenario shows nothing in it, so it gets no place there.\n if (scenario.type === \"ui\") ctx.ui?.recordScenario({\n scenarioId: scenario.id,\n name: scenario.name,\n attempt,\n ok: !scenarioError,\n startedAt: scenarioStart,\n endedAt: scenarioStart + durationMs,\n });\n const heals = [...(ctx.ui?.getHeals() ?? []), ...(ctx.mobile?.getHeals() ?? [])];\n reporter.onScenarioEnd(scenario, {\n ok: !scenarioError,\n error: scenarioError,\n durationMs,\n ...(heals.length ? { heals } : {}),\n });\n }\n\n if (!scenarioError) {\n return;\n }\n\n if (attempt >= maxAttempts) {\n throw scenarioError;\n }\n }\n }\n\n /** Runs one setup part's steps in the part's own scenario context, and names the part when one of them fails. */\n private async runSetup(part: ScenarioSetup, ctx: TestContext): Promise<void> {\n const partCtx: TestContext = {\n ...ctx,\n scenarioId: part.scenario.id,\n scenarioType: part.scenario.type,\n params: part.scenario.params ?? {},\n secrets: part.secrets,\n };\n for (const [blockIndex, block] of part.scenario.steps.entries()) {\n const normalized = normalizeBlock(block);\n for (const [stepIndex, step] of normalized.steps.entries()) {\n const stepPath = stepPathFor(block, blockIndex, stepIndex);\n try {\n await this.runStep(normalized.phase, step, partCtx, stepPath, part.kind, part.scenario.stepTimeoutMs);\n } catch (err: any) {\n const failure = new Error(`Setup \"${part.kind}\" (scenario \"${part.scenario.id}\") failed at ${stepPath}: ${err?.message ?? err}`);\n (failure as Error & { cause?: unknown }).cause = err;\n throw failure;\n }\n }\n }\n }\n\n // Interpolates the step, except the `with` fields its op takes as written (StepOptions.rawWith).\n private resolveStep(step: OpStep, ctx: TestContext): OpStep {\n const raw = this.registry\n .rawWithFields(step.op)\n .filter((field) => step.with && typeof step.with === \"object\" && field in step.with);\n if (!raw.length) {\n return interpolateDeep(step, ctx);\n }\n const rest = { ...step.with };\n for (const field of raw) delete rest[field];\n const resolved = interpolateDeep({ ...step, with: rest }, ctx);\n const kept = Object.fromEntries(raw.map((field) => [field, step.with![field]]));\n return { ...resolved, with: { ...resolved.with, ...kept } };\n }\n\n /**\n * Run one step exactly as a scenario would: interpolate, dispatch, honor `timeoutMs`\n * (the step's own, else the scenario's `stepTimeoutMs`), store `saveAs`, and report\n * start/end. Throws the step's error.\n */\n async runStep(\n phase: StepPhase,\n step: OpStep,\n ctx: TestContext,\n stepPath?: string,\n setup?: string,\n stepTimeoutMs?: number,\n ): Promise<unknown> {\n const reporter = ctx.reporter;\n const stepStart = Date.now();\n let stepError: unknown;\n let resolvedStep: OpStep | undefined;\n let result: unknown;\n\n ctx.stepPath = stepPath;\n ctx.stepData = [];\n reporter.onStepStart({ scenarioId: ctx.scenarioId, phase, step, stepPath, ...(setup ? { setup } : {}) });\n\n try {\n resolvedStep = withStepTimeout(this.resolveStep(step, ctx), stepTimeoutMs);\n const handler = this.registry.get(resolvedStep.op);\n const run = handler(ctx, resolvedStep);\n result =\n resolvedStep.timeoutMs !== undefined\n ? await withTimeout(\n run,\n resolvedStep.timeoutMs,\n `Step timeout after ${resolvedStep.timeoutMs}ms: \"${resolvedStep.op}\"`,\n )\n : await run;\n\n if (resolvedStep.saveAs) {\n ctx.resources.set(resolvedStep.saveAs, result);\n }\n return result;\n } catch (err: any) {\n stepError = err;\n throw err;\n } finally {\n const durationMs = Date.now() - stepStart;\n // Taken for every mobile step so the figure never carries over; only a slow one is worth reporting.\n const slowestCallMs = ctx.mobile?.takeSlowestCallMs() ?? 0;\n const data = ctx.stepData ?? [];\n ctx.stepData = undefined;\n reporter.onStepEnd({\n scenarioId: ctx.scenarioId,\n phase,\n step: resolvedStep ?? step,\n ok: !stepError,\n error: stepError,\n durationMs,\n stepPath,\n ...(slowestCallMs >= SLOW_CALL_REPORT_MS ? { slowestCallMs } : {}),\n ...(data.length ? { data } : {}),\n ...(setup ? { setup } : {}),\n });\n }\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { HealEvent } from "../contracts/runtime-context.types";
|
|
1
|
+
import type { HealEvent, StepDataUsed } from "../contracts/runtime-context.types";
|
|
2
2
|
import type { ScenarioType } from "../contracts/testing-metadata.types";
|
|
3
3
|
export type LifecycleEventType = "run.start" | "scenario.start" | "scenario.end" | "run.end";
|
|
4
4
|
export interface ArtifactRef {
|
|
5
|
-
kind: "console" | "network" | "screenshot" | "video" | "har" | "api-log";
|
|
5
|
+
kind: "console" | "network" | "screenshot" | "video" | "har" | "api-log" | "timeline";
|
|
6
6
|
name: string;
|
|
7
7
|
contentType: string;
|
|
8
8
|
transport: "inline" | "storage";
|
|
@@ -17,6 +17,7 @@ export interface StepResultData {
|
|
|
17
17
|
name?: string;
|
|
18
18
|
stepPath?: string;
|
|
19
19
|
slowestCallMs?: number;
|
|
20
|
+
data?: StepDataUsed[];
|
|
20
21
|
setup?: string;
|
|
21
22
|
ok: boolean;
|
|
22
23
|
durationMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-events.types.d.ts","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-events.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle-events.types.d.ts","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-events.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAOxE,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,gBAAgB,GAChB,cAAc,GACd,SAAS,CAAC;AAOd,MAAM,WAAW,WAAW;IAE1B,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,QAAQ,GAAG,SAAS,CAAC;IAEhC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,QAAQ,CAAC,EAAE,MAAM,CAAC;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,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;CAC3B;AAOD,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,KAAK,EAAE,kBAAkB,CAAC;IAE1B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAEhB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-events.types.js","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-events.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { HealEvent } from \"../contracts/runtime-context.types\";\nimport type { ScenarioType } from \"../contracts/testing-metadata.types\";\n\n/**\n * Incremental lifecycle events emitted by {@link LifecycleWebhookReporter} so an\n * external consumer (e.g. testingHub) can persist run progress live, instead of\n * only receiving a single final payload (as the legacy WebhookReporter does).\n */\nexport type LifecycleEventType =\n | \"run.start\"\n | \"scenario.start\"\n | \"scenario.end\"\n | \"run.end\";\n\n/**\n * Reference to a captured artifact (console/network/api log, screenshot, video, HAR).\n * Text artifacts travel inline; binary artifacts are uploaded to shared storage and\n * referenced by `storageKey`/`url` to keep webhook payloads small.\n */\nexport interface ArtifactRef {\n kind: \"console\" | \"network\" | \"screenshot\" | \"video\" | \"har\" | \"api-log\";\n name: string;\n contentType: string;\n transport: \"inline\" | \"storage\";\n /** base64 (binary) or raw text/JSON (text); present when transport === 'inline'. */\n inlineData?: string;\n /** file-service key; present when transport === 'storage'. */\n storageKey?: string;\n /** resolved getUrl(); present when transport === 'storage'. */\n url?: string;\n sizeBytes?: number;\n}\n\nexport interface StepResultData {\n phase: string;\n operation: string;\n name?: string;\n /** Position in the scenario file, e.g. `steps[3].when`. */\n stepPath?: string;\n /** Mobile only: the longest single device lookup in the step, reported when it was slow (a stalled device). */\n slowestCallMs?: number;\n /** Set for a step that ran as setup for the scenario (\"reset\", \"login\"), not as one of its own. */\n setup?: string;\n ok: boolean;\n durationMs: number;\n error?: string;\n}\n\n/** Minimal descriptor of a scenario in the run, so consumers can snapshot the full suite at run time. */\nexport interface ScenarioDescriptor {\n id: string;\n name?: string;\n type: ScenarioType;\n}\n\nexport interface RunStartData {\n total: number;\n scenarioIds: string[];\n scenarios: ScenarioDescriptor[];\n startedAt: string;\n}\n\nexport interface ScenarioStartData {\n scenarioId: string;\n name?: string;\n type: ScenarioType;\n index: number;\n total: number;\n}\n\nexport interface ScenarioEndData {\n scenarioId: string;\n name?: string;\n ok: boolean;\n /**\n * Absent from older runners, where `ok` alone decides passed/failed. A skipped\n * scenario has `ok: false` so a consumer that ignores `status` never counts it as passed.\n */\n status?: \"passed\" | \"failed\" | \"skipped\";\n /** Set when `status` is `skipped`. */\n skip?: { reason: \"dependency_failed\"; dependency: string };\n durationMs: number;\n error?: string;\n steps: StepResultData[];\n /** console/network/api-log/screenshot/video for THIS scenario. */\n artifacts: ArtifactRef[];\n /** Selectors replaced by a fallback or fingerprint while the scenario ran. */\n heals?: HealEvent[];\n}\n\nexport interface RunEndData {\n ok: boolean;\n total: number;\n passed: number;\n failed: number;\n skipped?: number;\n durationMs: number;\n exitCode?: number;\n error?: string;\n /** run-level artifacts (e.g. the whole-run video). */\n artifacts?: ArtifactRef[];\n}\n\n/**\n * Envelope wrapping every lifecycle event. `externalRunId` correlates the event to\n * the caller's own record (e.g. a testingHub TestRun id); `seq` lets an out-of-order\n * receiver reorder/deduplicate.\n */\nexport interface LifecycleEnvelope<T = unknown> {\n event: LifecycleEventType;\n /** correlation id supplied by the caller (e.g. testingHub TestRun id). */\n externalRunId?: string;\n /** runner-generated uuid for this process run. */\n runId: string;\n runName: string;\n /** 0-based, increments per emitted event. */\n seq: number;\n emittedAt: string;\n data: T;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lifecycle-events.types.js","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-events.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { HealEvent, StepDataUsed } from \"../contracts/runtime-context.types\";\nimport type { ScenarioType } from \"../contracts/testing-metadata.types\";\n\n/**\n * Incremental lifecycle events emitted by {@link LifecycleWebhookReporter} so an\n * external consumer (e.g. testingHub) can persist run progress live, instead of\n * only receiving a single final payload (as the legacy WebhookReporter does).\n */\nexport type LifecycleEventType =\n | \"run.start\"\n | \"scenario.start\"\n | \"scenario.end\"\n | \"run.end\";\n\n/**\n * Reference to a captured artifact (console/network/api log, screenshot, video, HAR).\n * Text artifacts travel inline; binary artifacts are uploaded to shared storage and\n * referenced by `storageKey`/`url` to keep webhook payloads small.\n */\nexport interface ArtifactRef {\n /** `timeline`: where each scenario is in the run video (run-timeline.json). */\n kind: \"console\" | \"network\" | \"screenshot\" | \"video\" | \"har\" | \"api-log\" | \"timeline\";\n name: string;\n contentType: string;\n transport: \"inline\" | \"storage\";\n /** base64 (binary) or raw text/JSON (text); present when transport === 'inline'. */\n inlineData?: string;\n /** file-service key; present when transport === 'storage'. */\n storageKey?: string;\n /** resolved getUrl(); present when transport === 'storage'. */\n url?: string;\n sizeBytes?: number;\n}\n\nexport interface StepResultData {\n phase: string;\n operation: string;\n name?: string;\n /** Position in the scenario file, e.g. `steps[3].when`. */\n stepPath?: string;\n /** Mobile only: the longest single device lookup in the step, reported when it was slow (a stalled device). */\n slowestCallMs?: number;\n /** Random values the step generated and text its `match` regexes extracted, so the results show the data used. */\n data?: StepDataUsed[];\n /** Set for a step that ran as setup for the scenario (\"reset\", \"login\"), not as one of its own. */\n setup?: string;\n ok: boolean;\n durationMs: number;\n error?: string;\n}\n\n/** Minimal descriptor of a scenario in the run, so consumers can snapshot the full suite at run time. */\nexport interface ScenarioDescriptor {\n id: string;\n name?: string;\n type: ScenarioType;\n}\n\nexport interface RunStartData {\n total: number;\n scenarioIds: string[];\n scenarios: ScenarioDescriptor[];\n startedAt: string;\n}\n\nexport interface ScenarioStartData {\n scenarioId: string;\n name?: string;\n type: ScenarioType;\n index: number;\n total: number;\n}\n\nexport interface ScenarioEndData {\n scenarioId: string;\n name?: string;\n ok: boolean;\n /**\n * Absent from older runners, where `ok` alone decides passed/failed. A skipped\n * scenario has `ok: false` so a consumer that ignores `status` never counts it as passed.\n */\n status?: \"passed\" | \"failed\" | \"skipped\";\n /** Set when `status` is `skipped`. */\n skip?: { reason: \"dependency_failed\"; dependency: string };\n durationMs: number;\n error?: string;\n steps: StepResultData[];\n /** console/network/api-log/screenshot/video for THIS scenario. */\n artifacts: ArtifactRef[];\n /** Selectors replaced by a fallback or fingerprint while the scenario ran. */\n heals?: HealEvent[];\n}\n\nexport interface RunEndData {\n ok: boolean;\n total: number;\n passed: number;\n failed: number;\n skipped?: number;\n durationMs: number;\n exitCode?: number;\n error?: string;\n /** run-level artifacts (e.g. the whole-run video). */\n artifacts?: ArtifactRef[];\n}\n\n/**\n * Envelope wrapping every lifecycle event. `externalRunId` correlates the event to\n * the caller's own record (e.g. a testingHub TestRun id); `seq` lets an out-of-order\n * receiver reorder/deduplicate.\n */\nexport interface LifecycleEnvelope<T = unknown> {\n event: LifecycleEventType;\n /** correlation id supplied by the caller (e.g. testingHub TestRun id). */\n externalRunId?: string;\n /** runner-generated uuid for this process run. */\n runId: string;\n runName: string;\n /** 0-based, increments per emitted event. */\n seq: number;\n emittedAt: string;\n data: T;\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { ConsoleReporter } from "./console-reporter";
|
|
|
2
2
|
import type { IArtifactSink } from "./artifact-sink";
|
|
3
3
|
import type { ScenarioDescriptor } from "./lifecycle-events.types";
|
|
4
4
|
import type { OpStep, ScenarioSpec } from "../contracts/testing-metadata.types";
|
|
5
|
-
import type { StepPhase } from "../contracts/runtime-context.types";
|
|
5
|
+
import type { StepDataUsed, StepPhase } from "../contracts/runtime-context.types";
|
|
6
6
|
import type { ScenarioResult, ScenarioSkipInfo } from "./reporter.types";
|
|
7
7
|
export type WebhookPostFn = (url: string, body: unknown, opts: {
|
|
8
8
|
headers?: Record<string, string>;
|
|
@@ -57,6 +57,7 @@ export declare class LifecycleWebhookReporter extends ConsoleReporter {
|
|
|
57
57
|
durationMs: number;
|
|
58
58
|
stepPath?: string;
|
|
59
59
|
slowestCallMs?: number;
|
|
60
|
+
data?: StepDataUsed[];
|
|
60
61
|
setup?: string;
|
|
61
62
|
}): void;
|
|
62
63
|
attach(args: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-webhook-reporter.d.ts","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-webhook-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAIV,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAgB,MAAM,qCAAqC,CAAC;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle-webhook-reporter.d.ts","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-webhook-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAIV,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAgB,MAAM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,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAuBhF,iBAAiB,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAiErF,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpE,OAAO,CAAC,IAAI;YAaE,OAAO;CAiBtB"}
|
|
@@ -23,6 +23,8 @@ const defaultPost = async (url, body, opts) => {
|
|
|
23
23
|
};
|
|
24
24
|
function classifyAttachment(name, contentType) {
|
|
25
25
|
const hint = `${name} ${contentType}`.toLowerCase();
|
|
26
|
+
if (name.toLowerCase().endsWith("timeline.json"))
|
|
27
|
+
return "timeline";
|
|
26
28
|
if (contentType.startsWith("video/") || hint.includes("video"))
|
|
27
29
|
return "video";
|
|
28
30
|
if (hint.includes("screenshot") || contentType.startsWith("image/"))
|
|
@@ -95,6 +97,7 @@ class LifecycleWebhookReporter extends console_reporter_1.ConsoleReporter {
|
|
|
95
97
|
name: args.step.name,
|
|
96
98
|
...(args.stepPath ? { stepPath: args.stepPath } : {}),
|
|
97
99
|
...(args.slowestCallMs ? { slowestCallMs: args.slowestCallMs } : {}),
|
|
100
|
+
...(args.data?.length ? { data: args.data } : {}),
|
|
98
101
|
...(args.setup ? { setup: args.setup } : {}),
|
|
99
102
|
ok: args.ok,
|
|
100
103
|
durationMs: args.durationMs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-webhook-reporter.js","sourceRoot":"","sources":["../../../src/testing/reporter/lifecycle-webhook-reporter.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,yDAAqD;AAsCrD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC,SAAS,WAAW,CAAC,GA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J,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CACV,gDAAgD,QAAQ,CAAC,KAAK,KAAK,GAAG,EAAE,CACzE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA1UD,4DA0UC","sourcesContent":["import { randomUUID } from \"crypto\";\n\nimport { ConsoleReporter } from \"./console-reporter\";\nimport type { IArtifactSink } from \"./artifact-sink\";\nimport type {\n ArtifactRef,\n LifecycleEnvelope,\n LifecycleEventType,\n ScenarioDescriptor,\n ScenarioEndData,\n StepResultData,\n} from \"./lifecycle-events.types\";\nimport type { OpStep, ScenarioSpec, ScenarioType } from \"../contracts/testing-metadata.types\";\nimport type { StepPhase } from \"../contracts/runtime-context.types\";\nimport type { ScenarioResult, ScenarioSkipInfo } from \"./reporter.types\";\n\n/**\n * Pluggable POST function so the reporter stays DI-agnostic. The default uses the\n * global `fetch`; the Nest worker can inject an axios-backed implementation that\n * shares the existing HttpModule stack.\n */\nexport type WebhookPostFn = (\n url: string,\n body: unknown,\n opts: { headers?: Record<string, string>; timeoutMs?: number },\n) => Promise<{ ok: boolean; status: number }>;\n\nexport interface LifecycleWebhookReporterOptions {\n webhookUrl: string;\n runName: string;\n /** correlation id supplied by the caller (e.g. testingHub TestRun id). */\n externalRunId?: string;\n /** runner-generated uuid for this process run; auto-generated when omitted. */\n runId?: string;\n /** Phase 2: sink for binary artifacts (screenshots/video/HAR). */\n artifactSink?: IArtifactSink;\n headers?: Record<string, string>;\n post?: WebhookPostFn;\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n/** Cap inline text artifacts so a webhook body never blows past receiver limits. */\nconst INLINE_TEXT_CAP = 1_000_000;\n\nfunction formatError(err: unknown): string {\n if (!err) return \"\";\n if (err instanceof Error) return err.stack || err.message;\n return String(err);\n}\n\nconst defaultPost: WebhookPostFn = async (url, body, opts) => {\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...(opts.headers ?? {}) },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS),\n });\n return { ok: res.ok, status: res.status };\n};\n\n/** Map an `attach()` payload to an ArtifactRef. Covers API/console/network + video/screenshots. */\nfunction classifyAttachment(name: string, contentType: string): ArtifactRef[\"kind\"] {\n const hint = `${name} ${contentType}`.toLowerCase();\n if (contentType.startsWith(\"video/\") || hint.includes(\"video\")) return \"video\";\n if (hint.includes(\"screenshot\") || contentType.startsWith(\"image/\")) return \"screenshot\";\n if (hint.includes(\"console\")) return \"console\";\n if (hint.includes(\"network\") || hint.includes(\"har\")) return \"network\";\n if (hint.includes(\"api\")) return \"api-log\";\n return \"api-log\";\n}\n\nfunction isBinaryContentType(contentType: string): boolean {\n const ct = contentType.toLowerCase();\n return ct.startsWith(\"image/\") || ct.startsWith(\"video/\") || ct === \"application/octet-stream\";\n}\n\n/**\n * Emits incremental lifecycle webhooks (run.start → scenario.start → scenario.end →\n * run.end) to a single URL, while still printing to the console (extends\n * ConsoleReporter). Deliveries are serialized through an async chain so ordering is\n * preserved without blocking step execution, and a failed POST never throws into the\n * run. Distinct from the legacy {@link WebhookReporter}, which only fires once on flush.\n */\nexport class LifecycleWebhookReporter extends ConsoleReporter {\n private readonly webhookUrl: string;\n private readonly runName: string;\n private readonly externalRunId?: string;\n private readonly runId: string;\n private readonly headers?: Record<string, string>;\n private readonly post: WebhookPostFn;\n /** Phase 2: used to upload binary artifacts in onScenarioEnd. */\n protected readonly artifactSink?: IArtifactSink;\n\n private seq = 0;\n private startedAtMs = Date.now();\n private total = 0;\n private scenarioIndex = 0;\n private passed = 0;\n private failed = 0;\n private skipped = 0;\n private currentSteps: StepResultData[] = [];\n private currentArtifacts: ArtifactRef[] = [];\n /** Run-level artifacts (e.g. the whole-run video); emitted on run.end. */\n private runArtifacts: ArtifactRef[] = [];\n /** Serializes webhook deliveries to preserve order. */\n private chain: Promise<void> = Promise.resolve();\n\n constructor(opts: LifecycleWebhookReporterOptions) {\n super();\n this.webhookUrl = opts.webhookUrl;\n this.runName = opts.runName;\n this.externalRunId = opts.externalRunId;\n this.runId = opts.runId ?? randomUUID();\n this.artifactSink = opts.artifactSink;\n this.headers = opts.headers;\n this.post = opts.post ?? defaultPost;\n }\n\n getRunId(): string {\n return this.runId;\n }\n\n onRunStart(args: {\n total: number;\n startedAt: string;\n scenarioIds: string[];\n scenarios?: ScenarioDescriptor[];\n }): void {\n this.total = args.total;\n this.startedAtMs = Date.now();\n this.emit(\"run.start\", {\n total: args.total,\n scenarioIds: args.scenarioIds,\n scenarios: args.scenarios ?? args.scenarioIds.map((id) => ({ id, type: \"api\" as ScenarioType })),\n startedAt: args.startedAt,\n });\n }\n\n override onScenarioStart(scenario: ScenarioSpec): void {\n super.onScenarioStart(scenario);\n this.currentSteps = [];\n this.currentArtifacts = [];\n const index = this.scenarioIndex++;\n this.emit(\"scenario.start\", {\n scenarioId: scenario.id,\n name: scenario.name,\n type: scenario.type,\n index,\n total: this.total,\n });\n }\n\n override onStepEnd(args: {\n scenarioId: string;\n phase: StepPhase;\n step: OpStep;\n ok: boolean;\n error?: unknown;\n durationMs: number;\n stepPath?: string;\n slowestCallMs?: number;\n setup?: string;\n }): void {\n super.onStepEnd(args);\n this.currentSteps.push({\n phase: String(args.phase),\n operation: args.step.op,\n name: args.step.name,\n ...(args.stepPath ? { stepPath: args.stepPath } : {}),\n ...(args.slowestCallMs ? { slowestCallMs: args.slowestCallMs } : {}),\n ...(args.setup ? { setup: args.setup } : {}),\n ok: args.ok,\n durationMs: args.durationMs,\n error: args.error ? formatError(args.error) : undefined,\n });\n }\n\n override attach(args: {\n scenarioId: string;\n name: string;\n contentType: string;\n data: Buffer | string;\n }): void {\n super.attach(args);\n const kind = classifyAttachment(args.name, args.contentType);\n const binary = Buffer.isBuffer(args.data) && isBinaryContentType(args.contentType);\n\n // Binary artifacts (screenshots, video): when a storage sink is configured, upload the bytes\n // to shared storage and reference them by storageKey/url — never ship blobs inline (the\n // inline cap would silently drop anything large, e.g. a video). The ref is mutated in place\n // by an upload queued onto the delivery chain, so it resolves before scenario.end is posted.\n if (binary && this.artifactSink) {\n const buf = args.data as Buffer;\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"storage\",\n sizeBytes: buf.byteLength,\n };\n this.currentArtifacts.push(artifact);\n const runId = this.externalRunId ?? this.runId;\n const scenarioId = args.scenarioId;\n this.chain = this.chain\n .then(async () => {\n const ref = await this.artifactSink!.put({\n runId,\n scenarioId,\n name: args.name,\n contentType: args.contentType,\n data: buf,\n });\n artifact.storageKey = ref.storageKey;\n artifact.url = ref.url;\n })\n .catch(() => {\n /* upload failed — leave the ref without a key; the ingest side skips empty refs */\n });\n return;\n }\n\n if (binary) {\n // Binary (e.g. a screenshot JPEG): base64-encode — a utf8 decode would corrupt the\n // bytes. Truncating base64 also corrupts it, so if it somehow exceeds the inline cap\n // we drop the payload rather than ship a broken image (viewport JPEGs stay well under).\n const bytes = args.data as Buffer;\n const base64 = bytes.toString(\"base64\");\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n sizeBytes: bytes.byteLength,\n };\n if (base64.length <= INLINE_TEXT_CAP) {\n artifact.inlineData = base64;\n }\n this.currentArtifacts.push(artifact);\n return;\n }\n\n const text = Buffer.isBuffer(args.data)\n ? args.data.toString(\"utf8\")\n : String(args.data ?? \"\");\n this.currentArtifacts.push({\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n inlineData: text.length > INLINE_TEXT_CAP ? text.slice(0, INLINE_TEXT_CAP) : text,\n sizeBytes: Buffer.byteLength(text),\n });\n }\n\n override onScenarioEnd(\n scenario: ScenarioSpec,\n result: ScenarioResult,\n ): void {\n super.onScenarioEnd(scenario, result);\n if (result.ok) {\n this.passed += 1;\n } else {\n this.failed += 1;\n }\n const data: ScenarioEndData = {\n scenarioId: scenario.id,\n name: scenario.name,\n ok: result.ok,\n status: result.ok ? \"passed\" : \"failed\",\n durationMs: result.durationMs,\n error: result.error ? formatError(result.error) : undefined,\n steps: [...this.currentSteps],\n artifacts: [...this.currentArtifacts],\n ...(result.heals?.length ? { heals: result.heals } : {}),\n };\n this.emit(\"scenario.end\", data);\n }\n\n override onScenarioSkipped(scenario: ScenarioSpec, info: ScenarioSkipInfo): void {\n super.onScenarioSkipped(scenario, info);\n this.skipped += 1;\n this.scenarioIndex += 1;\n const data: ScenarioEndData = {\n scenarioId: scenario.id,\n name: scenario.name,\n ok: false,\n status: \"skipped\",\n skip: { reason: info.reason, dependency: info.dependency },\n durationMs: 0,\n error: `Skipped: dependency \"${info.dependency}\" did not pass`,\n steps: [],\n artifacts: [],\n };\n this.emit(\"scenario.end\", data);\n }\n\n /**\n * Attach a run-level binary artifact (e.g. the whole-run video). Uploaded to shared storage\n * via the sink (never inline for a video) and referenced by storageKey/url on run.end. Must\n * be called before {@link flushPending} so the upload is queued ahead of the run.end delivery.\n */\n attachRunArtifact(args: { name: string; contentType: string; data: Buffer | string }): void {\n const kind = classifyAttachment(args.name, args.contentType);\n const binary = Buffer.isBuffer(args.data) && isBinaryContentType(args.contentType);\n\n if (binary && this.artifactSink) {\n const buf = args.data as Buffer;\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"storage\",\n sizeBytes: buf.byteLength,\n };\n this.runArtifacts.push(artifact);\n const runId = this.externalRunId ?? this.runId;\n this.chain = this.chain\n .then(async () => {\n const ref = await this.artifactSink!.put({\n runId,\n scenarioId: \"run\",\n name: args.name,\n contentType: args.contentType,\n data: buf,\n });\n artifact.storageKey = ref.storageKey;\n artifact.url = ref.url;\n })\n .catch(() => {\n /* upload failed — leave the ref without a key; ingest skips empty refs */\n });\n return;\n }\n\n // No sink: fall back to inline (a large video base64 that exceeds the cap is dropped).\n if (binary) {\n const bytes = args.data as Buffer;\n const base64 = bytes.toString(\"base64\");\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n sizeBytes: bytes.byteLength,\n };\n if (base64.length <= INLINE_TEXT_CAP) artifact.inlineData = base64;\n this.runArtifacts.push(artifact);\n return;\n }\n\n const text = Buffer.isBuffer(args.data) ? args.data.toString(\"utf8\") : String(args.data ?? \"\");\n this.runArtifacts.push({\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n inlineData: text.length > INLINE_TEXT_CAP ? text.slice(0, INLINE_TEXT_CAP) : text,\n sizeBytes: Buffer.byteLength(text),\n });\n }\n\n /**\n * Emit run.end and wait for all queued deliveries to complete. `error` names a\n * run-level failure reason (e.g. an unreadable scenario file) so a run that failed\n * before any scenario ran carries a clear message rather than a bare count.\n */\n async flushPending(exitCode?: number, error?: string): Promise<void> {\n this.emit(\"run.end\", {\n // A non-zero exitCode (e.g. the runner threw before any scenario ran) must\n // mark the run failed even when failed === 0.\n ok: this.failed === 0 && (exitCode === undefined || exitCode === 0),\n total: this.total || this.passed + this.failed + this.skipped,\n passed: this.passed,\n failed: this.failed,\n ...(this.skipped ? { skipped: this.skipped } : {}),\n durationMs: Date.now() - this.startedAtMs,\n exitCode,\n error,\n artifacts: this.runArtifacts.length ? [...this.runArtifacts] : undefined,\n });\n await this.chain;\n }\n\n private emit<T>(event: LifecycleEventType, data: T): void {\n const envelope: LifecycleEnvelope<T> = {\n event,\n externalRunId: this.externalRunId,\n runId: this.runId,\n runName: this.runName,\n seq: this.seq++,\n emittedAt: new Date().toISOString(),\n data,\n };\n this.chain = this.chain.then(() => this.deliver(envelope)).catch(() => {});\n }\n\n private async deliver(envelope: LifecycleEnvelope): Promise<void> {\n try {\n const res = await this.post(this.webhookUrl, envelope, {\n headers: this.headers,\n timeoutMs: DEFAULT_TIMEOUT_MS,\n });\n if (!res.ok) {\n console.warn(\n `[LifecycleWebhookReporter] ${envelope.event} → HTTP ${res.status}`,\n );\n }\n } catch (err) {\n console.warn(\n `[LifecycleWebhookReporter] failed to deliver ${envelope.event}: ${err}`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CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,QAA2B;QAC/C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE;gBACrD,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,SAAS,EAAE,kBAAkB;aAC9B,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,OAAO,CAAC,IAAI,CACV,8BAA8B,QAAQ,CAAC,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,CACpE,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CACV,gDAAgD,QAAQ,CAAC,KAAK,KAAK,GAAG,EAAE,CACzE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA5UD,4DA4UC","sourcesContent":["import { randomUUID } from \"crypto\";\n\nimport { ConsoleReporter } from \"./console-reporter\";\nimport type { IArtifactSink } from \"./artifact-sink\";\nimport type {\n ArtifactRef,\n LifecycleEnvelope,\n LifecycleEventType,\n ScenarioDescriptor,\n ScenarioEndData,\n StepResultData,\n} from \"./lifecycle-events.types\";\nimport type { OpStep, ScenarioSpec, ScenarioType } from \"../contracts/testing-metadata.types\";\nimport type { StepDataUsed, StepPhase } from \"../contracts/runtime-context.types\";\nimport type { ScenarioResult, ScenarioSkipInfo } from \"./reporter.types\";\n\n/**\n * Pluggable POST function so the reporter stays DI-agnostic. The default uses the\n * global `fetch`; the Nest worker can inject an axios-backed implementation that\n * shares the existing HttpModule stack.\n */\nexport type WebhookPostFn = (\n url: string,\n body: unknown,\n opts: { headers?: Record<string, string>; timeoutMs?: number },\n) => Promise<{ ok: boolean; status: number }>;\n\nexport interface LifecycleWebhookReporterOptions {\n webhookUrl: string;\n runName: string;\n /** correlation id supplied by the caller (e.g. testingHub TestRun id). */\n externalRunId?: string;\n /** runner-generated uuid for this process run; auto-generated when omitted. */\n runId?: string;\n /** Phase 2: sink for binary artifacts (screenshots/video/HAR). */\n artifactSink?: IArtifactSink;\n headers?: Record<string, string>;\n post?: WebhookPostFn;\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n/** Cap inline text artifacts so a webhook body never blows past receiver limits. */\nconst INLINE_TEXT_CAP = 1_000_000;\n\nfunction formatError(err: unknown): string {\n if (!err) return \"\";\n if (err instanceof Error) return err.stack || err.message;\n return String(err);\n}\n\nconst defaultPost: WebhookPostFn = async (url, body, opts) => {\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...(opts.headers ?? {}) },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS),\n });\n return { ok: res.ok, status: res.status };\n};\n\n/** Map an `attach()` payload to an ArtifactRef. Covers API/console/network + video/screenshots. */\nfunction classifyAttachment(name: string, contentType: string): ArtifactRef[\"kind\"] {\n const hint = `${name} ${contentType}`.toLowerCase();\n if (name.toLowerCase().endsWith(\"timeline.json\")) return \"timeline\";\n if (contentType.startsWith(\"video/\") || hint.includes(\"video\")) return \"video\";\n if (hint.includes(\"screenshot\") || contentType.startsWith(\"image/\")) return \"screenshot\";\n if (hint.includes(\"console\")) return \"console\";\n if (hint.includes(\"network\") || hint.includes(\"har\")) return \"network\";\n if (hint.includes(\"api\")) return \"api-log\";\n return \"api-log\";\n}\n\nfunction isBinaryContentType(contentType: string): boolean {\n const ct = contentType.toLowerCase();\n return ct.startsWith(\"image/\") || ct.startsWith(\"video/\") || ct === \"application/octet-stream\";\n}\n\n/**\n * Emits incremental lifecycle webhooks (run.start → scenario.start → scenario.end →\n * run.end) to a single URL, while still printing to the console (extends\n * ConsoleReporter). Deliveries are serialized through an async chain so ordering is\n * preserved without blocking step execution, and a failed POST never throws into the\n * run. Distinct from the legacy {@link WebhookReporter}, which only fires once on flush.\n */\nexport class LifecycleWebhookReporter extends ConsoleReporter {\n private readonly webhookUrl: string;\n private readonly runName: string;\n private readonly externalRunId?: string;\n private readonly runId: string;\n private readonly headers?: Record<string, string>;\n private readonly post: WebhookPostFn;\n /** Phase 2: used to upload binary artifacts in onScenarioEnd. */\n protected readonly artifactSink?: IArtifactSink;\n\n private seq = 0;\n private startedAtMs = Date.now();\n private total = 0;\n private scenarioIndex = 0;\n private passed = 0;\n private failed = 0;\n private skipped = 0;\n private currentSteps: StepResultData[] = [];\n private currentArtifacts: ArtifactRef[] = [];\n /** Run-level artifacts (e.g. the whole-run video); emitted on run.end. */\n private runArtifacts: ArtifactRef[] = [];\n /** Serializes webhook deliveries to preserve order. */\n private chain: Promise<void> = Promise.resolve();\n\n constructor(opts: LifecycleWebhookReporterOptions) {\n super();\n this.webhookUrl = opts.webhookUrl;\n this.runName = opts.runName;\n this.externalRunId = opts.externalRunId;\n this.runId = opts.runId ?? randomUUID();\n this.artifactSink = opts.artifactSink;\n this.headers = opts.headers;\n this.post = opts.post ?? defaultPost;\n }\n\n getRunId(): string {\n return this.runId;\n }\n\n onRunStart(args: {\n total: number;\n startedAt: string;\n scenarioIds: string[];\n scenarios?: ScenarioDescriptor[];\n }): void {\n this.total = args.total;\n this.startedAtMs = Date.now();\n this.emit(\"run.start\", {\n total: args.total,\n scenarioIds: args.scenarioIds,\n scenarios: args.scenarios ?? args.scenarioIds.map((id) => ({ id, type: \"api\" as ScenarioType })),\n startedAt: args.startedAt,\n });\n }\n\n override onScenarioStart(scenario: ScenarioSpec): void {\n super.onScenarioStart(scenario);\n this.currentSteps = [];\n this.currentArtifacts = [];\n const index = this.scenarioIndex++;\n this.emit(\"scenario.start\", {\n scenarioId: scenario.id,\n name: scenario.name,\n type: scenario.type,\n index,\n total: this.total,\n });\n }\n\n override onStepEnd(args: {\n scenarioId: string;\n phase: StepPhase;\n step: OpStep;\n ok: boolean;\n error?: unknown;\n durationMs: number;\n stepPath?: string;\n slowestCallMs?: number;\n data?: StepDataUsed[];\n setup?: string;\n }): void {\n super.onStepEnd(args);\n this.currentSteps.push({\n phase: String(args.phase),\n operation: args.step.op,\n name: args.step.name,\n ...(args.stepPath ? { stepPath: args.stepPath } : {}),\n ...(args.slowestCallMs ? { slowestCallMs: args.slowestCallMs } : {}),\n ...(args.data?.length ? { data: args.data } : {}),\n ...(args.setup ? { setup: args.setup } : {}),\n ok: args.ok,\n durationMs: args.durationMs,\n error: args.error ? formatError(args.error) : undefined,\n });\n }\n\n override attach(args: {\n scenarioId: string;\n name: string;\n contentType: string;\n data: Buffer | string;\n }): void {\n super.attach(args);\n const kind = classifyAttachment(args.name, args.contentType);\n const binary = Buffer.isBuffer(args.data) && isBinaryContentType(args.contentType);\n\n // Binary artifacts (screenshots, video): when a storage sink is configured, upload the bytes\n // to shared storage and reference them by storageKey/url — never ship blobs inline (the\n // inline cap would silently drop anything large, e.g. a video). The ref is mutated in place\n // by an upload queued onto the delivery chain, so it resolves before scenario.end is posted.\n if (binary && this.artifactSink) {\n const buf = args.data as Buffer;\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"storage\",\n sizeBytes: buf.byteLength,\n };\n this.currentArtifacts.push(artifact);\n const runId = this.externalRunId ?? this.runId;\n const scenarioId = args.scenarioId;\n this.chain = this.chain\n .then(async () => {\n const ref = await this.artifactSink!.put({\n runId,\n scenarioId,\n name: args.name,\n contentType: args.contentType,\n data: buf,\n });\n artifact.storageKey = ref.storageKey;\n artifact.url = ref.url;\n })\n .catch(() => {\n /* upload failed — leave the ref without a key; the ingest side skips empty refs */\n });\n return;\n }\n\n if (binary) {\n // Binary (e.g. a screenshot JPEG): base64-encode — a utf8 decode would corrupt the\n // bytes. Truncating base64 also corrupts it, so if it somehow exceeds the inline cap\n // we drop the payload rather than ship a broken image (viewport JPEGs stay well under).\n const bytes = args.data as Buffer;\n const base64 = bytes.toString(\"base64\");\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n sizeBytes: bytes.byteLength,\n };\n if (base64.length <= INLINE_TEXT_CAP) {\n artifact.inlineData = base64;\n }\n this.currentArtifacts.push(artifact);\n return;\n }\n\n const text = Buffer.isBuffer(args.data)\n ? args.data.toString(\"utf8\")\n : String(args.data ?? \"\");\n this.currentArtifacts.push({\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n inlineData: text.length > INLINE_TEXT_CAP ? text.slice(0, INLINE_TEXT_CAP) : text,\n sizeBytes: Buffer.byteLength(text),\n });\n }\n\n override onScenarioEnd(\n scenario: ScenarioSpec,\n result: ScenarioResult,\n ): void {\n super.onScenarioEnd(scenario, result);\n if (result.ok) {\n this.passed += 1;\n } else {\n this.failed += 1;\n }\n const data: ScenarioEndData = {\n scenarioId: scenario.id,\n name: scenario.name,\n ok: result.ok,\n status: result.ok ? \"passed\" : \"failed\",\n durationMs: result.durationMs,\n error: result.error ? formatError(result.error) : undefined,\n steps: [...this.currentSteps],\n artifacts: [...this.currentArtifacts],\n ...(result.heals?.length ? { heals: result.heals } : {}),\n };\n this.emit(\"scenario.end\", data);\n }\n\n override onScenarioSkipped(scenario: ScenarioSpec, info: ScenarioSkipInfo): void {\n super.onScenarioSkipped(scenario, info);\n this.skipped += 1;\n this.scenarioIndex += 1;\n const data: ScenarioEndData = {\n scenarioId: scenario.id,\n name: scenario.name,\n ok: false,\n status: \"skipped\",\n skip: { reason: info.reason, dependency: info.dependency },\n durationMs: 0,\n error: `Skipped: dependency \"${info.dependency}\" did not pass`,\n steps: [],\n artifacts: [],\n };\n this.emit(\"scenario.end\", data);\n }\n\n /**\n * Attach a run-level binary artifact (e.g. the whole-run video). Uploaded to shared storage\n * via the sink (never inline for a video) and referenced by storageKey/url on run.end. Must\n * be called before {@link flushPending} so the upload is queued ahead of the run.end delivery.\n */\n attachRunArtifact(args: { name: string; contentType: string; data: Buffer | string }): void {\n const kind = classifyAttachment(args.name, args.contentType);\n const binary = Buffer.isBuffer(args.data) && isBinaryContentType(args.contentType);\n\n if (binary && this.artifactSink) {\n const buf = args.data as Buffer;\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"storage\",\n sizeBytes: buf.byteLength,\n };\n this.runArtifacts.push(artifact);\n const runId = this.externalRunId ?? this.runId;\n this.chain = this.chain\n .then(async () => {\n const ref = await this.artifactSink!.put({\n runId,\n scenarioId: \"run\",\n name: args.name,\n contentType: args.contentType,\n data: buf,\n });\n artifact.storageKey = ref.storageKey;\n artifact.url = ref.url;\n })\n .catch(() => {\n /* upload failed — leave the ref without a key; ingest skips empty refs */\n });\n return;\n }\n\n // No sink: fall back to inline (a large video base64 that exceeds the cap is dropped).\n if (binary) {\n const bytes = args.data as Buffer;\n const base64 = bytes.toString(\"base64\");\n const artifact: ArtifactRef = {\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n sizeBytes: bytes.byteLength,\n };\n if (base64.length <= INLINE_TEXT_CAP) artifact.inlineData = base64;\n this.runArtifacts.push(artifact);\n return;\n }\n\n const text = Buffer.isBuffer(args.data) ? args.data.toString(\"utf8\") : String(args.data ?? \"\");\n this.runArtifacts.push({\n kind,\n name: args.name,\n contentType: args.contentType,\n transport: \"inline\",\n inlineData: text.length > INLINE_TEXT_CAP ? text.slice(0, INLINE_TEXT_CAP) : text,\n sizeBytes: Buffer.byteLength(text),\n });\n }\n\n /**\n * Emit run.end and wait for all queued deliveries to complete. `error` names a\n * run-level failure reason (e.g. an unreadable scenario file) so a run that failed\n * before any scenario ran carries a clear message rather than a bare count.\n */\n async flushPending(exitCode?: number, error?: string): Promise<void> {\n this.emit(\"run.end\", {\n // A non-zero exitCode (e.g. the runner threw before any scenario ran) must\n // mark the run failed even when failed === 0.\n ok: this.failed === 0 && (exitCode === undefined || exitCode === 0),\n total: this.total || this.passed + this.failed + this.skipped,\n passed: this.passed,\n failed: this.failed,\n ...(this.skipped ? { skipped: this.skipped } : {}),\n durationMs: Date.now() - this.startedAtMs,\n exitCode,\n error,\n artifacts: this.runArtifacts.length ? [...this.runArtifacts] : undefined,\n });\n await this.chain;\n }\n\n private emit<T>(event: LifecycleEventType, data: T): void {\n const envelope: LifecycleEnvelope<T> = {\n event,\n externalRunId: this.externalRunId,\n runId: this.runId,\n runName: this.runName,\n seq: this.seq++,\n emittedAt: new Date().toISOString(),\n data,\n };\n this.chain = this.chain.then(() => this.deliver(envelope)).catch(() => {});\n }\n\n private async deliver(envelope: LifecycleEnvelope): Promise<void> {\n try {\n const res = await this.post(this.webhookUrl, envelope, {\n headers: this.headers,\n timeoutMs: DEFAULT_TIMEOUT_MS,\n });\n if (!res.ok) {\n console.warn(\n `[LifecycleWebhookReporter] ${envelope.event} → HTTP ${res.status}`,\n );\n }\n } catch (err) {\n console.warn(\n `[LifecycleWebhookReporter] failed to deliver ${envelope.event}: ${err}`,\n );\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HealEvent, StepPhase } from "../contracts/runtime-context.types";
|
|
1
|
+
import type { HealEvent, StepDataUsed, StepPhase } from "../contracts/runtime-context.types";
|
|
2
2
|
import type { OpStep, ScenarioSpec, ScenarioType } from "../contracts/testing-metadata.types";
|
|
3
3
|
import type { SolidTestSpecResult } from "../contracts/test-spec.types";
|
|
4
4
|
export interface ScenarioResult {
|
|
@@ -41,6 +41,7 @@ export interface Reporter {
|
|
|
41
41
|
durationMs: number;
|
|
42
42
|
stepPath?: string;
|
|
43
43
|
slowestCallMs?: number;
|
|
44
|
+
data?: StepDataUsed[];
|
|
44
45
|
setup?: string;
|
|
45
46
|
}): void;
|
|
46
47
|
onSpecResult?(args: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.types.d.ts","sourceRoot":"","sources":["../../../src/testing/reporter/reporter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS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AM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.types.js","sourceRoot":"","sources":["../../../src/testing/reporter/reporter.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { HealEvent, StepPhase } from \"../contracts/runtime-context.types\";\nimport type { OpStep, ScenarioSpec, ScenarioType } from \"../contracts/testing-metadata.types\";\nimport type { SolidTestSpecResult } from \"../contracts/test-spec.types\";\n\nexport interface ScenarioResult {\n ok: boolean;\n error?: unknown;\n durationMs: number;\n /** Selector heals applied while the scenario ran; absent when none. */\n heals?: HealEvent[];\n}\n\nexport interface ScenarioSkipInfo {\n reason: \"dependency_failed\";\n /** The dependency that failed or was itself skipped. */\n dependency: string;\n}\n\nexport interface Reporter {\n onRunStart?(args: {\n total: number;\n startedAt: string;\n scenarioIds: string[];\n scenarios?: Array<{ id: string; name?: string; type: ScenarioType }>;\n }): void;\n onScenarioStart(scenario: ScenarioSpec): void;\n onScenarioEnd(\n scenario: ScenarioSpec,\n result: ScenarioResult,\n ): void;\n /** A scenario that did not run because a `dependsOn` scenario failed or was skipped. */\n onScenarioSkipped?(scenario: ScenarioSpec, info: ScenarioSkipInfo): void;\n onStepStart(args: {\n scenarioId: string;\n phase: StepPhase;\n step: OpStep;\n /** Position in the scenario file, e.g. `steps[3].when`. */\n stepPath?: string;\n /** Set for a step that runs as setup for the scenario (\"reset\", \"login\"), not as one of its own. */\n setup?: string;\n }): void;\n onStepEnd(args: {\n scenarioId: string;\n phase: StepPhase;\n step: OpStep;\n ok: boolean;\n error?: unknown;\n durationMs: number;\n stepPath?: string;\n /** Mobile only: the longest single device lookup in the step, when it was slow enough to matter (a stalled device). */\n slowestCallMs?: number;\n setup?: string;\n }): void;\n onSpecResult?(args: {\n scenarioId: string;\n specId: string;\n stepName?: string;\n result: SolidTestSpecResult;\n }): void;\n attach?(args: {\n scenarioId: string;\n name: string;\n contentType: string;\n data: Buffer | string;\n }): void;\n /** Attach a run-level artifact (e.g. the whole-run video), emitted on run.end. */\n attachRunArtifact?(args: {\n name: string;\n contentType: string;\n data: Buffer | string;\n }): void;\n onRunEnd?(args: RunEndArgs): void;\n}\n\nexport interface RunEndArgs {\n ok: boolean;\n total: number;\n passed: number;\n failed: number;\n /** Scenarios not run because a dependency failed; only present in dependency-aware runs. */\n skipped?: number;\n durationMs: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reporter.types.js","sourceRoot":"","sources":["../../../src/testing/reporter/reporter.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { HealEvent, StepDataUsed, StepPhase } from \"../contracts/runtime-context.types\";\nimport type { OpStep, ScenarioSpec, ScenarioType } from \"../contracts/testing-metadata.types\";\nimport type { SolidTestSpecResult } from \"../contracts/test-spec.types\";\n\nexport interface ScenarioResult {\n ok: boolean;\n error?: unknown;\n durationMs: number;\n /** Selector heals applied while the scenario ran; absent when none. */\n heals?: HealEvent[];\n}\n\nexport interface ScenarioSkipInfo {\n reason: \"dependency_failed\";\n /** The dependency that failed or was itself skipped. */\n dependency: string;\n}\n\nexport interface Reporter {\n onRunStart?(args: {\n total: number;\n startedAt: string;\n scenarioIds: string[];\n scenarios?: Array<{ id: string; name?: string; type: ScenarioType }>;\n }): void;\n onScenarioStart(scenario: ScenarioSpec): void;\n onScenarioEnd(\n scenario: ScenarioSpec,\n result: ScenarioResult,\n ): void;\n /** A scenario that did not run because a `dependsOn` scenario failed or was skipped. */\n onScenarioSkipped?(scenario: ScenarioSpec, info: ScenarioSkipInfo): void;\n onStepStart(args: {\n scenarioId: string;\n phase: StepPhase;\n step: OpStep;\n /** Position in the scenario file, e.g. `steps[3].when`. */\n stepPath?: string;\n /** Set for a step that runs as setup for the scenario (\"reset\", \"login\"), not as one of its own. */\n setup?: string;\n }): void;\n onStepEnd(args: {\n scenarioId: string;\n phase: StepPhase;\n step: OpStep;\n ok: boolean;\n error?: unknown;\n durationMs: number;\n stepPath?: string;\n /** Mobile only: the longest single device lookup in the step, when it was slow enough to matter (a stalled device). */\n slowestCallMs?: number;\n /** Random values the step generated and text its `match` regexes extracted. */\n data?: StepDataUsed[];\n setup?: string;\n }): void;\n onSpecResult?(args: {\n scenarioId: string;\n specId: string;\n stepName?: string;\n result: SolidTestSpecResult;\n }): void;\n attach?(args: {\n scenarioId: string;\n name: string;\n contentType: string;\n data: Buffer | string;\n }): void;\n /** Attach a run-level artifact (e.g. the whole-run video), emitted on run.end. */\n attachRunArtifact?(args: {\n name: string;\n contentType: string;\n data: Buffer | string;\n }): void;\n onRunEnd?(args: RunEndArgs): void;\n}\n\nexport interface RunEndArgs {\n ok: boolean;\n total: number;\n passed: number;\n failed: number;\n /** Scenarios not run because a dependency failed; only present in dependency-aware runs. */\n skipped?: number;\n durationMs: number;\n}\n"]}
|
|
@@ -6,4 +6,5 @@ export interface ReadScenariosResult {
|
|
|
6
6
|
error?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function readScenariosFile(absPath: string): ReadScenariosResult;
|
|
9
|
+
export declare function readScenarioFiles(absPaths: string[]): ReadScenariosResult;
|
|
9
10
|
//# sourceMappingURL=read-scenarios-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-scenarios-file.d.ts","sourceRoot":"","sources":["../../../src/testing/runner/read-scenarios-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAM3F,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAiBtE"}
|
|
1
|
+
{"version":3,"file":"read-scenarios-file.d.ts","sourceRoot":"","sources":["../../../src/testing/runner/read-scenarios-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAM3F,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAiBtE;AAOD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAiBzE"}
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.readScenariosFile = readScenariosFile;
|
|
37
|
+
exports.readScenarioFiles = readScenarioFiles;
|
|
37
38
|
const fs = __importStar(require("fs"));
|
|
38
39
|
function readScenariosFile(absPath) {
|
|
39
40
|
if (!absPath || !fs.existsSync(absPath)) {
|
|
@@ -53,4 +54,23 @@ function readScenariosFile(absPath) {
|
|
|
53
54
|
return { scenarios: [], ok: false, error: err?.message || "read_error" };
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
function readScenarioFiles(absPaths) {
|
|
58
|
+
const scenarios = [];
|
|
59
|
+
for (const absPath of absPaths) {
|
|
60
|
+
if (!absPath || !fs.existsSync(absPath)) {
|
|
61
|
+
return { scenarios: [], ok: false, error: `file_not_found: ${absPath}` };
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(fs.readFileSync(absPath, "utf-8"));
|
|
65
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
66
|
+
return { scenarios: [], ok: false, error: `not_a_scenario: ${absPath}` };
|
|
67
|
+
}
|
|
68
|
+
scenarios.push(parsed);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
return { scenarios: [], ok: false, error: `${err?.message || "read_error"}: ${absPath}` };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { scenarios, ok: true };
|
|
75
|
+
}
|
|
56
76
|
//# sourceMappingURL=read-scenarios-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-scenarios-file.js","sourceRoot":"","sources":["../../../src/testing/runner/read-scenarios-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,8CAiBC;
|
|
1
|
+
{"version":3,"file":"read-scenarios-file.js","sourceRoot":"","sources":["../../../src/testing/runner/read-scenarios-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,8CAiBC;AAOD,8CAiBC;AAnED,uCAAyB;AA0BzB,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,IAAI,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7D,MAAM,YAAY,GAChB,MAAM,EAAE,OAAO,EAAE,SAAS;YAC1B,MAAM,EAAE,SAAS;YACjB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxC,MAAM,SAAS,GAAmB,K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AAC;YACD,SAAS,CAAC,IAAI,CAAC,MAAsB,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAI,GAAa,EAAE,OAAO,IAAI,YAAY,KAAK,OAAO,EAAE,EAAE,CAAC;QACvG,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import * as fs from \"fs\";\n\nimport type { ScenarioSpec, TestingDataRecord } from \"../contracts/testing-metadata.types\";\n\n/**\n * Result of reading a scenario JSON file. `ok:false` means the file was missing,\n * unreadable, or contained invalid JSON — never a thrown error.\n */\nexport interface ReadScenariosResult {\n scenarios: ScenarioSpec[];\n data?: TestingDataRecord[];\n ok: boolean;\n error?: string;\n}\n\n/**\n * Read + parse an application's scenario file `{ testing: { scenarios, data } }` from an\n * absolute path, on the WORKER tier (which shares the filesystem with the caller in the\n * default single-process deployment). Tolerant by design — mirrors\n * ScenarioFileService.resolvePayload in testingHub — so a concurrent editor half-writing\n * the file, a deleted file (TOCTOU between existsSync and readFileSync), or invalid JSON\n * returns `{ ok:false }` instead of throwing. The worker fails the run loudly on `ok:false`.\n *\n * Lives in core (not testingHub) because the worker is a core component and must not import\n * testingHub code.\n */\nexport function readScenariosFile(absPath: string): ReadScenariosResult {\n if (!absPath || !fs.existsSync(absPath)) {\n return { scenarios: [], ok: false, error: \"file_not_found\" };\n }\n try {\n const parsed = JSON.parse(fs.readFileSync(absPath, \"utf-8\"));\n const rawScenarios =\n parsed?.testing?.scenarios ??\n parsed?.scenarios ??\n (Array.isArray(parsed) ? parsed : []);\n const scenarios: ScenarioSpec[] = Array.isArray(rawScenarios) ? rawScenarios : [];\n const rawData = parsed?.testing?.data ?? parsed?.data;\n const data: TestingDataRecord[] | undefined = Array.isArray(rawData) ? rawData : undefined;\n return { scenarios, data, ok: true };\n } catch (err) {\n return { scenarios: [], ok: false, error: (err as Error)?.message || \"read_error\" };\n }\n}\n\n/**\n * Read one scenario per file, in the order given: Testing Hub keeps each scenario in its own JSON file\n * (`<app>/<scenario key>.json`) and sends their paths. Every file must hold one scenario object; the first missing,\n * unreadable or invalid file fails the whole read (naming the file), so a run never silently drops a scenario.\n */\nexport function readScenarioFiles(absPaths: string[]): ReadScenariosResult {\n const scenarios: ScenarioSpec[] = [];\n for (const absPath of absPaths) {\n if (!absPath || !fs.existsSync(absPath)) {\n return { scenarios: [], ok: false, error: `file_not_found: ${absPath}` };\n }\n try {\n const parsed = JSON.parse(fs.readFileSync(absPath, \"utf-8\"));\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return { scenarios: [], ok: false, error: `not_a_scenario: ${absPath}` };\n }\n scenarios.push(parsed as ScenarioSpec);\n } catch (err) {\n return { scenarios: [], ok: false, error: `${(err as Error)?.message || \"read_error\"}: ${absPath}` };\n }\n }\n return { scenarios, ok: true };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-from-metadata.d.ts","sourceRoot":"","sources":["../../../src/testing/runner/run-from-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAM5E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-from-metadata.d.ts","sourceRoot":"","sources":["../../../src/testing/runner/run-from-metadata.ts"],"names":[],"mappings":"A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