@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
|
@@ -3,6 +3,7 @@ import type { Browser, BrowserContext, Page, ConsoleMessage, Response, Request,
|
|
|
3
3
|
import type { HealEvent } from "../../contracts/runtime-context.types";
|
|
4
4
|
import type { HealingPolicy } from "../../contracts/testing-metadata.types";
|
|
5
5
|
import type { AttachOptions, CaptureOptions, PlaywrightAdapterOptions, ViewportOptions } from "./ui.types";
|
|
6
|
+
import { buildTimeline, clipDurationMs, findFfmpeg, joinClips, type ClipTiming, type RunVideoTimeline, type ScenarioMark } from "./run-video";
|
|
6
7
|
|
|
7
8
|
/** Storage state as returned by `BrowserContext.storageState()`. */
|
|
8
9
|
export type StorageState = Awaited<ReturnType<BrowserContext["storageState"]>>;
|
|
@@ -71,8 +72,11 @@ export class PlaywrightAdapter {
|
|
|
71
72
|
* finalized bytes.
|
|
72
73
|
*/
|
|
73
74
|
private videoDir?: string;
|
|
74
|
-
private videoSegments: Video
|
|
75
|
+
private videoSegments: Array<{ video: Video; startedAt: number; endedAt: number }> = [];
|
|
76
|
+
private segmentStartedAt = 0;
|
|
77
|
+
private scenarioMarks: ScenarioMark[] = [];
|
|
75
78
|
private runVideos: FailureArtifact[] = [];
|
|
79
|
+
private runVideoTimeline?: RunVideoTimeline;
|
|
76
80
|
private readonly requestStartedAt = new Map<Request, number>();
|
|
77
81
|
|
|
78
82
|
constructor(opts?: PlaywrightAdapterOptions) {
|
|
@@ -156,18 +160,23 @@ export class PlaywrightAdapter {
|
|
|
156
160
|
}
|
|
157
161
|
this.context = await this.browser.newContext({
|
|
158
162
|
...contextViewportOptions(this.viewport),
|
|
159
|
-
|
|
163
|
+
// At the viewport's own size: without `size` Playwright scales the recording down to fit 800x800, so a 1920x1080
|
|
164
|
+
// run was recorded at about 800x450 and its text was unreadable.
|
|
165
|
+
...(this.videoDir
|
|
166
|
+
? { recordVideo: { dir: this.videoDir, size: this.viewport ? { width: this.viewport.width, height: this.viewport.height } : { width: 1280, height: 720 } } }
|
|
167
|
+
: {}),
|
|
160
168
|
...(storageState ? { storageState } : {}),
|
|
161
169
|
});
|
|
162
170
|
this.context.setDefaultTimeout(this.defaultTimeoutMs);
|
|
163
171
|
this.context.setDefaultNavigationTimeout(this.navigationTimeoutMs);
|
|
164
172
|
this.page = await this.context.newPage();
|
|
173
|
+
this.segmentStartedAt = Date.now();
|
|
165
174
|
this.attachCaptureListeners(this.page);
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
private async closeContext(): Promise<void> {
|
|
169
178
|
const video = this.videoDir ? this.page?.video() : undefined;
|
|
170
|
-
if (video) this.videoSegments.push(video);
|
|
179
|
+
if (video) this.videoSegments.push({ video, startedAt: this.segmentStartedAt, endedAt: Date.now() });
|
|
171
180
|
try {
|
|
172
181
|
if (this.context) {
|
|
173
182
|
await this.context.close();
|
|
@@ -203,11 +212,21 @@ export class PlaywrightAdapter {
|
|
|
203
212
|
return this.runVideos[0];
|
|
204
213
|
}
|
|
205
214
|
|
|
206
|
-
/** Every whole-run video
|
|
215
|
+
/** Every whole-run video file, after {@link stop}: one, unless clips could not be joined (no ffmpeg). */
|
|
207
216
|
getRunVideos(): FailureArtifact[] {
|
|
208
217
|
return [...this.runVideos];
|
|
209
218
|
}
|
|
210
219
|
|
|
220
|
+
/** Where each scenario is in the run video, after {@link stop} kept it. */
|
|
221
|
+
getRunVideoTimeline(): RunVideoTimeline | undefined {
|
|
222
|
+
return this.runVideoTimeline;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Note when a scenario attempt ran, so the run video can show where it is. Only while recording. */
|
|
226
|
+
recordScenario(mark: ScenarioMark): void {
|
|
227
|
+
if (this.videoDir) this.scenarioMarks.push(mark);
|
|
228
|
+
}
|
|
229
|
+
|
|
211
230
|
/**
|
|
212
231
|
* Wire console/network listeners once per page. Events accumulate in the per-scenario
|
|
213
232
|
* buffers and are only surfaced (via {@link collectFailureArtifacts}) when a scenario
|
|
@@ -349,13 +368,8 @@ export class PlaywrightAdapter {
|
|
|
349
368
|
const fs = await import('fs');
|
|
350
369
|
// Only read the recording into memory when the caller wants to keep it (i.e. the
|
|
351
370
|
// run FAILED). Passing runs discard the webm unread — no wasted IO/memory.
|
|
352
|
-
if (keepVideo) {
|
|
353
|
-
|
|
354
|
-
for (const [i, video] of this.videoSegments.entries()) {
|
|
355
|
-
const data = await fs.promises.readFile(await video.path());
|
|
356
|
-
const name = single ? 'run.webm' : `run-${i + 1}.webm`;
|
|
357
|
-
this.runVideos.push({ name, contentType: 'video/webm', data });
|
|
358
|
-
}
|
|
371
|
+
if (keepVideo && this.videoSegments.length) {
|
|
372
|
+
await this.keepRunVideo(this.videoDir);
|
|
359
373
|
}
|
|
360
374
|
// Clean up the temp recording directory either way.
|
|
361
375
|
await fs.promises.rm(this.videoDir, { recursive: true, force: true }).catch(() => {});
|
|
@@ -364,6 +378,7 @@ export class PlaywrightAdapter {
|
|
|
364
378
|
} finally {
|
|
365
379
|
this.videoDir = undefined;
|
|
366
380
|
this.videoSegments = [];
|
|
381
|
+
this.scenarioMarks = [];
|
|
367
382
|
}
|
|
368
383
|
}
|
|
369
384
|
|
|
@@ -376,6 +391,33 @@ export class PlaywrightAdapter {
|
|
|
376
391
|
}
|
|
377
392
|
}
|
|
378
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Read the run's recording into {@link runVideos} as one `run.webm` (clips joined with ffmpeg when the run opened
|
|
396
|
+
* several contexts) and work out where each scenario is in it. Without ffmpeg several clips stay `run-<n>.webm`.
|
|
397
|
+
*/
|
|
398
|
+
private async keepRunVideo(dir: string): Promise<void> {
|
|
399
|
+
const fs = await import('fs');
|
|
400
|
+
const path = await import('path');
|
|
401
|
+
const files = await Promise.all(this.videoSegments.map((s) => s.video.path()));
|
|
402
|
+
const ffmpeg = await findFfmpeg();
|
|
403
|
+
const clips: ClipTiming[] = [];
|
|
404
|
+
for (const [i, s] of this.videoSegments.entries()) {
|
|
405
|
+
const measured = ffmpeg ? await clipDurationMs(ffmpeg, files[i]) : undefined;
|
|
406
|
+
clips.push({ startedAt: s.startedAt, endedAt: s.endedAt, durationMs: measured ?? s.endedAt - s.startedAt });
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
let joined: string | undefined = files.length === 1 ? files[0] : undefined;
|
|
410
|
+
if (!joined && ffmpeg) {
|
|
411
|
+
const out = path.join(dir, 'run-joined.webm');
|
|
412
|
+
if (await joinClips(ffmpeg, files, path.join(dir, 'clips.txt'), out)) joined = out;
|
|
413
|
+
}
|
|
414
|
+
const names = joined ? ['run.webm'] : files.map((_, i) => `run-${i + 1}.webm`);
|
|
415
|
+
for (const [i, file] of (joined ? [joined] : files).entries()) {
|
|
416
|
+
this.runVideos.push({ name: names[i], contentType: 'video/webm', data: await fs.promises.readFile(file) });
|
|
417
|
+
}
|
|
418
|
+
this.runVideoTimeline = buildTimeline(clips, names, this.scenarioMarks, !!joined);
|
|
419
|
+
}
|
|
420
|
+
|
|
379
421
|
/**
|
|
380
422
|
* Multi-tab support. The onboarding flow needs a second site (the BI OTP portal)
|
|
381
423
|
* open at the same time as the in-progress SPA, without destroying it. Opening a
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { buildTimeline, parseDurationMs, videoPosition, type ClipTiming, type ScenarioMark } from "./run-video";
|
|
2
|
+
|
|
3
|
+
// Two contexts as Playwright records them: each clip is a little shorter than its page was open,
|
|
4
|
+
// because recording starts a moment after the page opens.
|
|
5
|
+
const CLIPS: ClipTiming[] = [
|
|
6
|
+
{ startedAt: 1_000, endedAt: 3_650, durationMs: 2_440 },
|
|
7
|
+
{ startedAt: 3_700, endedAt: 7_870, durationMs: 3_920 },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const mark = (scenarioId: string, startedAt: number, endedAt: number, ok = true, attempt = 1): ScenarioMark => ({
|
|
11
|
+
scenarioId,
|
|
12
|
+
attempt,
|
|
13
|
+
ok,
|
|
14
|
+
startedAt,
|
|
15
|
+
endedAt,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("run video timeline", () => {
|
|
19
|
+
it("measures a time back from the end of its clip", () => {
|
|
20
|
+
expect(videoPosition(CLIPS, 3_650)).toEqual({ clip: 0, ms: 2_440 });
|
|
21
|
+
expect(videoPosition(CLIPS, 2_650)).toEqual({ clip: 0, ms: 1_440 });
|
|
22
|
+
// The moment the page opened is before the recording started: clamp to 0.
|
|
23
|
+
expect(videoPosition(CLIPS, 1_000)).toEqual({ clip: 0, ms: 0 });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("puts a time between two clips at the start of the next", () => {
|
|
27
|
+
expect(videoPosition(CLIPS, 3_680)).toEqual({ clip: 1, ms: 0 });
|
|
28
|
+
expect(videoPosition(CLIPS, 9_000)).toEqual({ clip: 1, ms: 3_920 });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("gives every scenario its place in the joined file", () => {
|
|
32
|
+
const timeline = buildTimeline(CLIPS, ["run.webm"], [
|
|
33
|
+
mark("login", 1_100, 3_600),
|
|
34
|
+
mark("tasks-list", 4_000, 5_000),
|
|
35
|
+
mark("task-create", 5_000, 7_800, false),
|
|
36
|
+
], true);
|
|
37
|
+
|
|
38
|
+
expect(timeline.oneFile).toBe(true);
|
|
39
|
+
expect(timeline.clips).toEqual([{ name: "run.webm", durationMs: 6_360 }]);
|
|
40
|
+
expect(timeline.scenarios).toEqual([
|
|
41
|
+
{ scenarioId: "login", attempt: 1, ok: true, clip: 0, startMs: 0, endMs: 2_390 },
|
|
42
|
+
// Second clip starts at 2440 in the joined file.
|
|
43
|
+
{ scenarioId: "tasks-list", attempt: 1, ok: true, clip: 0, startMs: 2_440 + 50, endMs: 2_440 + 1_050 },
|
|
44
|
+
{ scenarioId: "task-create", attempt: 1, ok: false, clip: 0, startMs: 2_440 + 1_050, endMs: 2_440 + 3_850 },
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("keeps clip-relative times when the clips stay separate", () => {
|
|
49
|
+
const timeline = buildTimeline(CLIPS, ["run-1.webm", "run-2.webm"], [mark("tasks-list", 4_000, 5_000)], false);
|
|
50
|
+
expect(timeline.oneFile).toBe(false);
|
|
51
|
+
expect(timeline.clips).toEqual([
|
|
52
|
+
{ name: "run-1.webm", durationMs: 2_440 },
|
|
53
|
+
{ name: "run-2.webm", durationMs: 3_920 },
|
|
54
|
+
]);
|
|
55
|
+
expect(timeline.scenarios).toEqual([{ scenarioId: "tasks-list", attempt: 1, ok: true, clip: 1, startMs: 50, endMs: 1_050 }]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("leaves out scenarios that ran while nothing was recording, and keeps retries apart", () => {
|
|
59
|
+
const timeline = buildTimeline(CLIPS, ["run.webm"], [
|
|
60
|
+
mark("api-health", 100, 900),
|
|
61
|
+
mark("flaky", 4_000, 4_500, false, 1),
|
|
62
|
+
mark("flaky", 4_500, 5_000, true, 2),
|
|
63
|
+
], true);
|
|
64
|
+
expect(timeline.scenarios.map((s) => `${s.scenarioId}#${s.attempt}:${s.ok}`)).toEqual(["flaky#1:false", "flaky#2:true"]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("reads ffmpeg's duration line", () => {
|
|
68
|
+
expect(parseDurationMs(" Duration: 00:00:06.36, start: 0.000000, bitrate: 19 kb/s")).toBe(6_360);
|
|
69
|
+
expect(parseDurationMs(" Duration: 01:02:03.50, start: 0")).toBe(3_723_500);
|
|
70
|
+
expect(parseDurationMs("Duration: N/A")).toBeUndefined();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The whole-run video and where each scenario is in it.
|
|
5
|
+
*
|
|
6
|
+
* Playwright records one clip per browser context, so a run that opens a new context for `session: restore|fresh`
|
|
7
|
+
* has several. They are joined into one file with ffmpeg (from SOLID_FFMPEG_PATH, else `ffmpeg` on the PATH);
|
|
8
|
+
* without ffmpeg the clips stay separate and the timeline says which clip each scenario is in.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** One recorded clip: when its page was open (wall clock) and how long the clip actually is. */
|
|
12
|
+
export interface ClipTiming {
|
|
13
|
+
startedAt: number;
|
|
14
|
+
endedAt: number;
|
|
15
|
+
durationMs: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** One scenario attempt, by wall clock. */
|
|
19
|
+
export interface ScenarioMark {
|
|
20
|
+
scenarioId: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
attempt: number;
|
|
23
|
+
ok: boolean;
|
|
24
|
+
startedAt: number;
|
|
25
|
+
endedAt: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RunVideoTimeline {
|
|
29
|
+
version: 1;
|
|
30
|
+
/** Every scenario is in one file: the clips were joined, or there was only one. */
|
|
31
|
+
oneFile: boolean;
|
|
32
|
+
clips: Array<{ name: string; durationMs: number }>;
|
|
33
|
+
/** Times are milliseconds into `clips[clip]`. */
|
|
34
|
+
scenarios: Array<{ scenarioId: string; name?: string; attempt: number; ok: boolean; clip: number; startMs: number; endMs: number }>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Where wall-clock time `t` is in the recording: the clip and how far into it. Recording starts a moment after the
|
|
39
|
+
* page opens but runs until the context closes, so the position is measured back from the clip's end. A time
|
|
40
|
+
* between two clips (a context switch) is the start of the next one.
|
|
41
|
+
*/
|
|
42
|
+
export function videoPosition(clips: ClipTiming[], t: number): { clip: number; ms: number } {
|
|
43
|
+
for (const [clip, c] of clips.entries()) {
|
|
44
|
+
if (t > c.endedAt) continue;
|
|
45
|
+
if (t < c.startedAt) return { clip, ms: 0 };
|
|
46
|
+
return { clip, ms: Math.min(c.durationMs, Math.max(0, c.durationMs - (c.endedAt - t))) };
|
|
47
|
+
}
|
|
48
|
+
const last = clips.length - 1;
|
|
49
|
+
return { clip: last, ms: clips[last]?.durationMs ?? 0 };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The timeline of a run's video. `oneFile`: the clips are joined in order into one file, so every time is into
|
|
54
|
+
* that file. Scenarios that ran while nothing was recording (e.g. API scenarios before the browser opened) are left out.
|
|
55
|
+
*/
|
|
56
|
+
export function buildTimeline(clips: ClipTiming[], names: string[], marks: ScenarioMark[], oneFile: boolean): RunVideoTimeline {
|
|
57
|
+
const offsets = clips.map((_, i) => clips.slice(0, i).reduce((sum, c) => sum + c.durationMs, 0));
|
|
58
|
+
const first = clips[0];
|
|
59
|
+
const last = clips[clips.length - 1];
|
|
60
|
+
const scenarios = !first
|
|
61
|
+
? []
|
|
62
|
+
: marks
|
|
63
|
+
.filter((m) => m.endedAt >= first.startedAt && m.startedAt <= last.endedAt)
|
|
64
|
+
.map((m) => {
|
|
65
|
+
const start = videoPosition(clips, m.startedAt);
|
|
66
|
+
const end = videoPosition(clips, m.endedAt);
|
|
67
|
+
// Separate clips: a scenario cannot run past the end of the clip it started in.
|
|
68
|
+
const endMs = end.clip === start.clip ? end.ms : clips[start.clip].durationMs;
|
|
69
|
+
const at = (clip: number, ms: number) => (oneFile ? offsets[clip] + ms : ms);
|
|
70
|
+
return {
|
|
71
|
+
scenarioId: m.scenarioId,
|
|
72
|
+
...(m.name ? { name: m.name } : {}),
|
|
73
|
+
attempt: m.attempt,
|
|
74
|
+
ok: m.ok,
|
|
75
|
+
clip: oneFile ? 0 : start.clip,
|
|
76
|
+
startMs: Math.round(at(start.clip, start.ms)),
|
|
77
|
+
endMs: Math.round(oneFile ? at(end.clip, end.ms) : endMs),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
const total = clips.reduce((sum, c) => sum + c.durationMs, 0);
|
|
81
|
+
return {
|
|
82
|
+
version: 1,
|
|
83
|
+
oneFile,
|
|
84
|
+
clips: oneFile ? [{ name: names[0], durationMs: Math.round(total) }] : clips.map((c, i) => ({ name: names[i], durationMs: Math.round(c.durationMs) })),
|
|
85
|
+
scenarios,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function run(bin: string, args: string[]): Promise<{ ok: boolean; stderr: string }> {
|
|
90
|
+
return new Promise((resolve) => {
|
|
91
|
+
execFile(bin, args, { maxBuffer: 4 * 1024 * 1024, timeout: 120_000 }, (error, _stdout, stderr) => {
|
|
92
|
+
resolve({ ok: !error, stderr: String(stderr ?? "") });
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The ffmpeg to use, or undefined when there is none. */
|
|
98
|
+
export async function findFfmpeg(): Promise<string | undefined> {
|
|
99
|
+
const bin = process.env.SOLID_FFMPEG_PATH?.trim() || "ffmpeg";
|
|
100
|
+
return (await run(bin, ["-hide_banner", "-version"])).ok ? bin : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A clip's length from ffmpeg's "Duration: 00:00:02.44" line, or undefined. */
|
|
104
|
+
export async function clipDurationMs(ffmpeg: string, file: string): Promise<number | undefined> {
|
|
105
|
+
const { stderr } = await run(ffmpeg, ["-hide_banner", "-i", file]);
|
|
106
|
+
return parseDurationMs(stderr);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function parseDurationMs(ffmpegOutput: string): number | undefined {
|
|
110
|
+
const m = /Duration:\s*(\d+):(\d+):(\d+(?:\.\d+)?)/.exec(ffmpegOutput);
|
|
111
|
+
if (!m) return undefined;
|
|
112
|
+
return (Number(m[1]) * 3600 + Number(m[2]) * 60 + Number(m[3])) * 1000;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Join same-size WebM clips into `out` without re-encoding. */
|
|
116
|
+
export async function joinClips(ffmpeg: string, files: string[], listFile: string, out: string): Promise<boolean> {
|
|
117
|
+
const fs = await import("fs");
|
|
118
|
+
const quote = (f: string) => `file '${f.replace(/'/g, "'\\''")}'`;
|
|
119
|
+
await fs.promises.writeFile(listFile, files.map(quote).join("\n") + "\n");
|
|
120
|
+
const { ok } = await run(ffmpeg, ["-hide_banner", "-v", "error", "-y", "-f", "concat", "-safe", "0", "-i", listFile, "-c", "copy", out]);
|
|
121
|
+
return ok && fs.existsSync(out);
|
|
122
|
+
}
|
|
@@ -49,6 +49,22 @@ export interface TestContext {
|
|
|
49
49
|
* (`steps[3].when`, `steps[5].then[1]`). Heal reports use it to address the step.
|
|
50
50
|
*/
|
|
51
51
|
stepPath?: string;
|
|
52
|
+
/** Values the current step generated or extracted, reported with its result. Reset for every step. */
|
|
53
|
+
stepData?: StepDataUsed[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A value a step made up or pulled out while it ran, so a run's results show the data it actually used: a
|
|
58
|
+
* `${random:...}` token or `util.random` value, or the text a `match` regex extracted (`| match:` or
|
|
59
|
+
* `ui.storeText`'s `match`). Values from secrets are never recorded.
|
|
60
|
+
*/
|
|
61
|
+
export interface StepDataUsed {
|
|
62
|
+
kind: "random" | "match";
|
|
63
|
+
/** What produced it, e.g. `${random:emailAddress}`, `random:firstName`, `match:(\d{6})`. */
|
|
64
|
+
source: string;
|
|
65
|
+
value: string;
|
|
66
|
+
/** The resource name the step saved the value under, when it has one. */
|
|
67
|
+
saveAs?: string;
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
/**
|
|
@@ -50,6 +50,11 @@ export interface ScenarioSpec {
|
|
|
50
50
|
params?: Record<string, any>;
|
|
51
51
|
tags?: string[];
|
|
52
52
|
timeoutMs?: number;
|
|
53
|
+
/**
|
|
54
|
+
* How long each step may take, for every step that sets no timeout of its own: the wait for browser and device
|
|
55
|
+
* steps (`with.timeoutMs`), the step-level `timeoutMs` for the rest. `timeoutMs` above bounds the whole scenario.
|
|
56
|
+
*/
|
|
57
|
+
stepTimeoutMs?: number;
|
|
53
58
|
retries?: number;
|
|
54
59
|
/**
|
|
55
60
|
* Scenarios that must pass before this one runs. Selecting this scenario pulls its
|
|
@@ -4,6 +4,7 @@ import { resolveNow } from "./dates";
|
|
|
4
4
|
import { parseCallToken } from "./call-args";
|
|
5
5
|
import { parseRandomToken, randomDataFor } from "./random-data";
|
|
6
6
|
import { findTokens, splitOutsideQuotes } from "./token-scan";
|
|
7
|
+
import { recordStepData } from "./step-data";
|
|
7
8
|
|
|
8
9
|
function getByPath(obj: Record<string, any>, path: string): unknown {
|
|
9
10
|
if (!path) return undefined;
|
|
@@ -175,11 +176,15 @@ function applyTransform(value: unknown, name: string, arg: string | undefined):
|
|
|
175
176
|
function resolveTokenWithTransforms(token: string, ctx: TestContext): TokenResolution {
|
|
176
177
|
// Split outside quotes, so a quoted `|` in an argument is not a transform.
|
|
177
178
|
const [first, ...transforms] = splitOutsideQuotes(token, "|");
|
|
179
|
+
const base = first.trim();
|
|
178
180
|
if (!transforms.length) {
|
|
179
|
-
|
|
181
|
+
const resolved = resolveToken(token, ctx);
|
|
182
|
+
if (base.startsWith(RANDOM_PREFIX)) recordStepData(ctx, { kind: "random", source: `\${${token}}`, value: resolved.value });
|
|
183
|
+
return resolved;
|
|
180
184
|
}
|
|
181
|
-
const resolved = resolveToken(
|
|
185
|
+
const resolved = resolveToken(base, ctx);
|
|
182
186
|
let value = resolved.value;
|
|
187
|
+
let matched = false;
|
|
183
188
|
for (const rawTransform of transforms) {
|
|
184
189
|
const t = rawTransform.trim();
|
|
185
190
|
if (!t) continue;
|
|
@@ -187,7 +192,11 @@ function resolveTokenWithTransforms(token: string, ctx: TestContext): TokenResol
|
|
|
187
192
|
const name = (colon === -1 ? t : t.slice(0, colon)).trim();
|
|
188
193
|
const arg = colon === -1 ? undefined : t.slice(colon + 1).trim();
|
|
189
194
|
value = applyTransform(value, name, arg);
|
|
195
|
+
if (name === "match") matched = true;
|
|
190
196
|
}
|
|
197
|
+
// A value taken from a secret stays out of the report, even after a transform.
|
|
198
|
+
if (base.startsWith(RANDOM_PREFIX)) recordStepData(ctx, { kind: "random", source: `\${${token.trim()}}`, value });
|
|
199
|
+
else if (matched && !base.startsWith(SECRET_PREFIX)) recordStepData(ctx, { kind: "match", source: `\${${token.trim()}}`, value });
|
|
191
200
|
return { value, raw: false };
|
|
192
201
|
}
|
|
193
202
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Purpose: a run's results show the data its steps made up or pulled out — `${random:...}` tokens, `util.random`
|
|
2
|
+
// values and `match` extractions — on the step that used them, and never a secret.
|
|
3
|
+
|
|
4
|
+
import type { TestContext } from "../contracts/runtime-context.types";
|
|
5
|
+
import { RandomDataRegistry } from "./random-data";
|
|
6
|
+
import { SimpleResourceStore } from "./resource-store";
|
|
7
|
+
import { StepRegistry } from "./step-registry";
|
|
8
|
+
import { TestingEngine } from "./testing-engine";
|
|
9
|
+
import { registerUtilSteps } from "../steps/util";
|
|
10
|
+
|
|
11
|
+
function setup() {
|
|
12
|
+
const ended: any[] = [];
|
|
13
|
+
const registry = new StepRegistry();
|
|
14
|
+
registerUtilSteps(registry);
|
|
15
|
+
registry.register("test.echo", async (_ctx, step) => step.with);
|
|
16
|
+
const ctx = {
|
|
17
|
+
scenarioId: "spec",
|
|
18
|
+
scenarioType: "api",
|
|
19
|
+
params: {},
|
|
20
|
+
resources: new SimpleResourceStore(),
|
|
21
|
+
randomData: new RandomDataRegistry(),
|
|
22
|
+
secrets: { "app-otp-line": "Your code is 482913" },
|
|
23
|
+
reporter: { onStepStart: () => undefined, onStepEnd: (args: any) => ended.push(args) } as any,
|
|
24
|
+
} as TestContext;
|
|
25
|
+
return { engine: new TestingEngine(registry), ctx, ended };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("data used by a step", () => {
|
|
29
|
+
it("reports a util.random value with its saveAs name", async () => {
|
|
30
|
+
const { engine, ctx, ended } = setup();
|
|
31
|
+
|
|
32
|
+
const value = await engine.runStep("given" as any, { op: "util.random", with: { generator: "emailAddress" }, saveAs: "email" } as any, ctx);
|
|
33
|
+
|
|
34
|
+
expect(ended[0].data).toEqual([{ kind: "random", source: "random:emailAddress", value, saveAs: "email" }]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("reports inline random tokens and match transforms, on the step that resolved them only", async () => {
|
|
38
|
+
const { engine, ctx, ended } = setup();
|
|
39
|
+
ctx.resources.set("sms", "OTP 7731 is valid for 5 minutes");
|
|
40
|
+
|
|
41
|
+
const out: any = await engine.runStep("when" as any, { op: "test.echo", with: { name: "${random:firstName}", otp: "${res:sms | match:(\\d+)}" } } as any, ctx);
|
|
42
|
+
await engine.runStep("then" as any, { op: "test.echo", with: { plain: "${res:sms}" } } as any, ctx);
|
|
43
|
+
|
|
44
|
+
expect(ended[0].data).toEqual([
|
|
45
|
+
{ kind: "random", source: "${random:firstName}", value: out.name },
|
|
46
|
+
{ kind: "match", source: "${res:sms | match:(\\d+)}", value: "7731" },
|
|
47
|
+
]);
|
|
48
|
+
expect(ended[1].data).toBeUndefined();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("never reports a value taken from a secret", async () => {
|
|
52
|
+
const { engine, ctx, ended } = setup();
|
|
53
|
+
|
|
54
|
+
const out: any = await engine.runStep("when" as any, { op: "test.echo", with: { otp: "${secret:app-otp-line | match:(\\d+)}" } } as any, ctx);
|
|
55
|
+
|
|
56
|
+
expect(out.otp).toBe("482913");
|
|
57
|
+
expect(ended[0].data).toBeUndefined();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StepDataUsed, TestContext } from "../contracts/runtime-context.types";
|
|
2
|
+
|
|
3
|
+
/** Longest value kept in a step's report; generated data is short, so this only guards against a whole page of text. */
|
|
4
|
+
const MAX_VALUE_LENGTH = 500;
|
|
5
|
+
|
|
6
|
+
/** Adds a value the current step generated or extracted to its report (see {@link StepDataUsed}). */
|
|
7
|
+
export function recordStepData(ctx: TestContext, entry: Omit<StepDataUsed, "value"> & { value: unknown }): void {
|
|
8
|
+
if (!ctx.stepData) return;
|
|
9
|
+
const text = typeof entry.value === "string" ? entry.value : JSON.stringify(entry.value) ?? String(entry.value);
|
|
10
|
+
ctx.stepData.push({
|
|
11
|
+
...entry,
|
|
12
|
+
value: text.length > MAX_VALUE_LENGTH ? `${text.slice(0, MAX_VALUE_LENGTH)}…` : text,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -40,6 +40,19 @@ export interface ScenarioSetup {
|
|
|
40
40
|
orElse?: ScenarioSetup[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* `step` with the scenario's step timeout, unless it sets its own. Browser and device steps take it as their wait
|
|
45
|
+
* (`with.timeoutMs`, which their Playwright and Appium calls use); any other step is cut off after it.
|
|
46
|
+
*/
|
|
47
|
+
function withStepTimeout(step: OpStep, stepTimeoutMs?: number): OpStep {
|
|
48
|
+
if (typeof stepTimeoutMs !== "number" || !Number.isFinite(stepTimeoutMs) || stepTimeoutMs <= 0) return step;
|
|
49
|
+
if (step.timeoutMs !== undefined || step.with?.timeoutMs !== undefined) return step;
|
|
50
|
+
if (step.op.startsWith("ui.") || step.op.startsWith("mobile.")) {
|
|
51
|
+
return { ...step, with: { ...(step.with ?? {}), timeoutMs: stepTimeoutMs } };
|
|
52
|
+
}
|
|
53
|
+
return { ...step, timeoutMs: stepTimeoutMs };
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
/** A device lookup slower than this is reported with its step. */
|
|
44
57
|
const SLOW_CALL_REPORT_MS = 2000;
|
|
45
58
|
|
|
@@ -98,7 +111,7 @@ export class TestingEngine {
|
|
|
98
111
|
for (const [blockIndex, block] of scenario.steps.entries()) {
|
|
99
112
|
const normalized = normalizeBlock(block);
|
|
100
113
|
for (const [stepIndex, step] of normalized.steps.entries()) {
|
|
101
|
-
await this.runStep(normalized.phase, step, ctx, stepPathFor(block, blockIndex, stepIndex));
|
|
114
|
+
await this.runStep(normalized.phase, step, ctx, stepPathFor(block, blockIndex, stepIndex), undefined, scenario.stepTimeoutMs);
|
|
102
115
|
}
|
|
103
116
|
}
|
|
104
117
|
};
|
|
@@ -152,6 +165,15 @@ export class TestingEngine {
|
|
|
152
165
|
}
|
|
153
166
|
|
|
154
167
|
const durationMs = Date.now() - scenarioStart;
|
|
168
|
+
// Only browser scenarios are in the run video: an API scenario shows nothing in it, so it gets no place there.
|
|
169
|
+
if (scenario.type === "ui") ctx.ui?.recordScenario({
|
|
170
|
+
scenarioId: scenario.id,
|
|
171
|
+
name: scenario.name,
|
|
172
|
+
attempt,
|
|
173
|
+
ok: !scenarioError,
|
|
174
|
+
startedAt: scenarioStart,
|
|
175
|
+
endedAt: scenarioStart + durationMs,
|
|
176
|
+
});
|
|
155
177
|
const heals = [...(ctx.ui?.getHeals() ?? []), ...(ctx.mobile?.getHeals() ?? [])];
|
|
156
178
|
reporter.onScenarioEnd(scenario, {
|
|
157
179
|
ok: !scenarioError,
|
|
@@ -185,7 +207,7 @@ export class TestingEngine {
|
|
|
185
207
|
for (const [stepIndex, step] of normalized.steps.entries()) {
|
|
186
208
|
const stepPath = stepPathFor(block, blockIndex, stepIndex);
|
|
187
209
|
try {
|
|
188
|
-
await this.runStep(normalized.phase, step, partCtx, stepPath, part.kind);
|
|
210
|
+
await this.runStep(normalized.phase, step, partCtx, stepPath, part.kind, part.scenario.stepTimeoutMs);
|
|
189
211
|
} catch (err: any) {
|
|
190
212
|
const failure = new Error(`Setup "${part.kind}" (scenario "${part.scenario.id}") failed at ${stepPath}: ${err?.message ?? err}`);
|
|
191
213
|
(failure as Error & { cause?: unknown }).cause = err;
|
|
@@ -211,8 +233,9 @@ export class TestingEngine {
|
|
|
211
233
|
}
|
|
212
234
|
|
|
213
235
|
/**
|
|
214
|
-
* Run one step exactly as a scenario would: interpolate, dispatch, honor `timeoutMs
|
|
215
|
-
* store `saveAs`, and report
|
|
236
|
+
* Run one step exactly as a scenario would: interpolate, dispatch, honor `timeoutMs`
|
|
237
|
+
* (the step's own, else the scenario's `stepTimeoutMs`), store `saveAs`, and report
|
|
238
|
+
* start/end. Throws the step's error.
|
|
216
239
|
*/
|
|
217
240
|
async runStep(
|
|
218
241
|
phase: StepPhase,
|
|
@@ -220,6 +243,7 @@ export class TestingEngine {
|
|
|
220
243
|
ctx: TestContext,
|
|
221
244
|
stepPath?: string,
|
|
222
245
|
setup?: string,
|
|
246
|
+
stepTimeoutMs?: number,
|
|
223
247
|
): Promise<unknown> {
|
|
224
248
|
const reporter = ctx.reporter;
|
|
225
249
|
const stepStart = Date.now();
|
|
@@ -228,10 +252,11 @@ export class TestingEngine {
|
|
|
228
252
|
let result: unknown;
|
|
229
253
|
|
|
230
254
|
ctx.stepPath = stepPath;
|
|
255
|
+
ctx.stepData = [];
|
|
231
256
|
reporter.onStepStart({ scenarioId: ctx.scenarioId, phase, step, stepPath, ...(setup ? { setup } : {}) });
|
|
232
257
|
|
|
233
258
|
try {
|
|
234
|
-
resolvedStep = this.resolveStep(step, ctx);
|
|
259
|
+
resolvedStep = withStepTimeout(this.resolveStep(step, ctx), stepTimeoutMs);
|
|
235
260
|
const handler = this.registry.get(resolvedStep.op);
|
|
236
261
|
const run = handler(ctx, resolvedStep);
|
|
237
262
|
result =
|
|
@@ -254,6 +279,8 @@ export class TestingEngine {
|
|
|
254
279
|
const durationMs = Date.now() - stepStart;
|
|
255
280
|
// Taken for every mobile step so the figure never carries over; only a slow one is worth reporting.
|
|
256
281
|
const slowestCallMs = ctx.mobile?.takeSlowestCallMs() ?? 0;
|
|
282
|
+
const data = ctx.stepData ?? [];
|
|
283
|
+
ctx.stepData = undefined;
|
|
257
284
|
reporter.onStepEnd({
|
|
258
285
|
scenarioId: ctx.scenarioId,
|
|
259
286
|
phase,
|
|
@@ -263,6 +290,7 @@ export class TestingEngine {
|
|
|
263
290
|
durationMs,
|
|
264
291
|
stepPath,
|
|
265
292
|
...(slowestCallMs >= SLOW_CALL_REPORT_MS ? { slowestCallMs } : {}),
|
|
293
|
+
...(data.length ? { data } : {}),
|
|
266
294
|
...(setup ? { setup } : {}),
|
|
267
295
|
});
|
|
268
296
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
|
4
4
|
/**
|
|
@@ -18,7 +18,8 @@ export type LifecycleEventType =
|
|
|
18
18
|
* referenced by `storageKey`/`url` to keep webhook payloads small.
|
|
19
19
|
*/
|
|
20
20
|
export interface ArtifactRef {
|
|
21
|
-
|
|
21
|
+
/** `timeline`: where each scenario is in the run video (run-timeline.json). */
|
|
22
|
+
kind: "console" | "network" | "screenshot" | "video" | "har" | "api-log" | "timeline";
|
|
22
23
|
name: string;
|
|
23
24
|
contentType: string;
|
|
24
25
|
transport: "inline" | "storage";
|
|
@@ -39,6 +40,8 @@ export interface StepResultData {
|
|
|
39
40
|
stepPath?: string;
|
|
40
41
|
/** Mobile only: the longest single device lookup in the step, reported when it was slow (a stalled device). */
|
|
41
42
|
slowestCallMs?: number;
|
|
43
|
+
/** Random values the step generated and text its `match` regexes extracted, so the results show the data used. */
|
|
44
|
+
data?: StepDataUsed[];
|
|
42
45
|
/** Set for a step that ran as setup for the scenario ("reset", "login"), not as one of its own. */
|
|
43
46
|
setup?: string;
|
|
44
47
|
ok: boolean;
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
StepResultData,
|
|
12
12
|
} from "./lifecycle-events.types";
|
|
13
13
|
import type { OpStep, ScenarioSpec, ScenarioType } from "../contracts/testing-metadata.types";
|
|
14
|
-
import type { StepPhase } from "../contracts/runtime-context.types";
|
|
14
|
+
import type { StepDataUsed, StepPhase } from "../contracts/runtime-context.types";
|
|
15
15
|
import type { ScenarioResult, ScenarioSkipInfo } from "./reporter.types";
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -61,6 +61,7 @@ const defaultPost: WebhookPostFn = async (url, body, opts) => {
|
|
|
61
61
|
/** Map an `attach()` payload to an ArtifactRef. Covers API/console/network + video/screenshots. */
|
|
62
62
|
function classifyAttachment(name: string, contentType: string): ArtifactRef["kind"] {
|
|
63
63
|
const hint = `${name} ${contentType}`.toLowerCase();
|
|
64
|
+
if (name.toLowerCase().endsWith("timeline.json")) return "timeline";
|
|
64
65
|
if (contentType.startsWith("video/") || hint.includes("video")) return "video";
|
|
65
66
|
if (hint.includes("screenshot") || contentType.startsWith("image/")) return "screenshot";
|
|
66
67
|
if (hint.includes("console")) return "console";
|
|
@@ -159,6 +160,7 @@ export class LifecycleWebhookReporter extends ConsoleReporter {
|
|
|
159
160
|
durationMs: number;
|
|
160
161
|
stepPath?: string;
|
|
161
162
|
slowestCallMs?: number;
|
|
163
|
+
data?: StepDataUsed[];
|
|
162
164
|
setup?: string;
|
|
163
165
|
}): void {
|
|
164
166
|
super.onStepEnd(args);
|
|
@@ -168,6 +170,7 @@ export class LifecycleWebhookReporter extends ConsoleReporter {
|
|
|
168
170
|
name: args.step.name,
|
|
169
171
|
...(args.stepPath ? { stepPath: args.stepPath } : {}),
|
|
170
172
|
...(args.slowestCallMs ? { slowestCallMs: args.slowestCallMs } : {}),
|
|
173
|
+
...(args.data?.length ? { data: args.data } : {}),
|
|
171
174
|
...(args.setup ? { setup: args.setup } : {}),
|
|
172
175
|
ok: args.ok,
|
|
173
176
|
durationMs: args.durationMs,
|
|
@@ -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
|
|
|
@@ -49,6 +49,8 @@ export interface Reporter {
|
|
|
49
49
|
stepPath?: string;
|
|
50
50
|
/** Mobile only: the longest single device lookup in the step, when it was slow enough to matter (a stalled device). */
|
|
51
51
|
slowestCallMs?: number;
|
|
52
|
+
/** Random values the step generated and text its `match` regexes extracted. */
|
|
53
|
+
data?: StepDataUsed[];
|
|
52
54
|
setup?: string;
|
|
53
55
|
}): void;
|
|
54
56
|
onSpecResult?(args: {
|