@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.
Files changed (275) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/constants/error-messages.d.ts +1 -1
  3. package/dist/constants/error-messages.d.ts.map +1 -1
  4. package/dist/constants/error-messages.js +1 -1
  5. package/dist/constants/error-messages.js.map +1 -1
  6. package/dist/controllers/admin-embed.controller.d.ts +5 -0
  7. package/dist/controllers/admin-embed.controller.d.ts.map +1 -0
  8. package/dist/controllers/admin-embed.controller.js +58 -0
  9. package/dist/controllers/admin-embed.controller.js.map +1 -0
  10. package/dist/controllers/agent-registry.controller.d.ts +2 -0
  11. package/dist/controllers/agent-registry.controller.d.ts.map +1 -1
  12. package/dist/controllers/agent-registry.controller.js +14 -0
  13. package/dist/controllers/agent-registry.controller.js.map +1 -1
  14. package/dist/controllers/agent-session.controller.d.ts +8 -1
  15. package/dist/controllers/agent-session.controller.d.ts.map +1 -1
  16. package/dist/controllers/agent-session.controller.js +88 -2
  17. package/dist/controllers/agent-session.controller.js.map +1 -1
  18. package/dist/controllers/authentication.controller.d.ts +12 -1
  19. package/dist/controllers/authentication.controller.d.ts.map +1 -1
  20. package/dist/controllers/authentication.controller.js +26 -2
  21. package/dist/controllers/authentication.controller.js.map +1 -1
  22. package/dist/controllers/test-data.controller.d.ts +12 -0
  23. package/dist/controllers/test-data.controller.d.ts.map +1 -0
  24. package/dist/controllers/test-data.controller.js +66 -0
  25. package/dist/controllers/test-data.controller.js.map +1 -0
  26. package/dist/controllers/test-data.controller.spec.d.ts +2 -0
  27. package/dist/controllers/test-data.controller.spec.d.ts.map +1 -0
  28. package/dist/controllers/test-data.controller.spec.js +78 -0
  29. package/dist/controllers/test-data.controller.spec.js.map +1 -0
  30. package/dist/dtos/create-agent-job.dto.d.ts +1 -0
  31. package/dist/dtos/create-agent-job.dto.d.ts.map +1 -1
  32. package/dist/dtos/create-agent-job.dto.js +8 -1
  33. package/dist/dtos/create-agent-job.dto.js.map +1 -1
  34. package/dist/dtos/create-agent-process.dto.d.ts +5 -0
  35. package/dist/dtos/create-agent-process.dto.d.ts.map +1 -1
  36. package/dist/dtos/create-agent-process.dto.js +37 -1
  37. package/dist/dtos/create-agent-process.dto.js.map +1 -1
  38. package/dist/dtos/create-agent-registry.dto.d.ts +5 -0
  39. package/dist/dtos/create-agent-registry.dto.d.ts.map +1 -1
  40. package/dist/dtos/create-agent-registry.dto.js +39 -1
  41. package/dist/dtos/create-agent-registry.dto.js.map +1 -1
  42. package/dist/dtos/create-agent-session.dto.js +1 -1
  43. package/dist/dtos/create-agent-session.dto.js.map +1 -1
  44. package/dist/dtos/test-run-request.dto.d.ts +1 -0
  45. package/dist/dtos/test-run-request.dto.d.ts.map +1 -1
  46. package/dist/dtos/test-run-request.dto.js +7 -1
  47. package/dist/dtos/test-run-request.dto.js.map +1 -1
  48. package/dist/dtos/update-agent-deployment.dto.d.ts +8 -0
  49. package/dist/dtos/update-agent-deployment.dto.d.ts.map +1 -0
  50. package/dist/dtos/update-agent-deployment.dto.js +60 -0
  51. package/dist/dtos/update-agent-deployment.dto.js.map +1 -0
  52. package/dist/dtos/update-agent-job.dto.d.ts +1 -0
  53. package/dist/dtos/update-agent-job.dto.d.ts.map +1 -1
  54. package/dist/dtos/update-agent-job.dto.js +8 -1
  55. package/dist/dtos/update-agent-job.dto.js.map +1 -1
  56. package/dist/dtos/update-agent-process.dto.d.ts +5 -0
  57. package/dist/dtos/update-agent-process.dto.d.ts.map +1 -1
  58. package/dist/dtos/update-agent-process.dto.js +37 -1
  59. package/dist/dtos/update-agent-process.dto.js.map +1 -1
  60. package/dist/dtos/update-agent-registry.dto.d.ts +5 -0
  61. package/dist/dtos/update-agent-registry.dto.d.ts.map +1 -1
  62. package/dist/dtos/update-agent-registry.dto.js +39 -1
  63. package/dist/dtos/update-agent-registry.dto.js.map +1 -1
  64. package/dist/dtos/update-agent-session.dto.js +1 -1
  65. package/dist/dtos/update-agent-session.dto.js.map +1 -1
  66. package/dist/entities/agent-job.entity.d.ts +1 -0
  67. package/dist/entities/agent-job.entity.d.ts.map +1 -1
  68. package/dist/entities/agent-job.entity.js +7 -2
  69. package/dist/entities/agent-job.entity.js.map +1 -1
  70. package/dist/entities/agent-process.entity.d.ts +8 -0
  71. package/dist/entities/agent-process.entity.d.ts.map +1 -1
  72. package/dist/entities/agent-process.entity.js +38 -1
  73. package/dist/entities/agent-process.entity.js.map +1 -1
  74. package/dist/entities/agent-registry.entity.d.ts +5 -0
  75. package/dist/entities/agent-registry.entity.d.ts.map +1 -1
  76. package/dist/entities/agent-registry.entity.js +22 -1
  77. package/dist/entities/agent-registry.entity.js.map +1 -1
  78. package/dist/entities/agent-session.entity.d.ts.map +1 -1
  79. package/dist/entities/agent-session.entity.js +3 -1
  80. package/dist/entities/agent-session.entity.js.map +1 -1
  81. package/dist/guards/access-token.guard.d.ts +3 -1
  82. package/dist/guards/access-token.guard.d.ts.map +1 -1
  83. package/dist/guards/access-token.guard.js +11 -2
  84. package/dist/guards/access-token.guard.js.map +1 -1
  85. package/dist/helpers/agent-config-version-name.d.ts +2 -0
  86. package/dist/helpers/agent-config-version-name.d.ts.map +1 -0
  87. package/dist/helpers/agent-config-version-name.js +17 -0
  88. package/dist/helpers/agent-config-version-name.js.map +1 -0
  89. package/dist/helpers/agent-config-version-name.spec.d.ts +2 -0
  90. package/dist/helpers/agent-config-version-name.spec.d.ts.map +1 -0
  91. package/dist/helpers/agent-config-version-name.spec.js +31 -0
  92. package/dist/helpers/agent-config-version-name.spec.js.map +1 -0
  93. package/dist/index.d.ts +3 -0
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +2 -0
  96. package/dist/index.js.map +1 -1
  97. package/dist/interfaces/active-user-data.interface.d.ts +1 -0
  98. package/dist/interfaces/active-user-data.interface.d.ts.map +1 -1
  99. package/dist/interfaces/active-user-data.interface.js.map +1 -1
  100. package/dist/jobs/database/test-run-queue-subscriber-database.service.d.ts.map +1 -1
  101. package/dist/jobs/database/test-run-queue-subscriber-database.service.js +8 -4
  102. package/dist/jobs/database/test-run-queue-subscriber-database.service.js.map +1 -1
  103. package/dist/resources/admin-embed/solid-admin-embed.js +133 -0
  104. package/dist/resources/agent-embed/solid-agent-embed.js +243 -4
  105. package/dist/seeders/module-test-data.service.d.ts +19 -0
  106. package/dist/seeders/module-test-data.service.d.ts.map +1 -1
  107. package/dist/seeders/module-test-data.service.js +95 -15
  108. package/dist/seeders/module-test-data.service.js.map +1 -1
  109. package/dist/seeders/module-test-data.service.spec.d.ts +2 -0
  110. package/dist/seeders/module-test-data.service.spec.d.ts.map +1 -0
  111. package/dist/seeders/module-test-data.service.spec.js +158 -0
  112. package/dist/seeders/module-test-data.service.spec.js.map +1 -0
  113. package/dist/seeders/seed-data/solid-core-metadata.json +375 -11
  114. package/dist/services/agent-hub-process-manager.service.d.ts +16 -0
  115. package/dist/services/agent-hub-process-manager.service.d.ts.map +1 -1
  116. package/dist/services/agent-hub-process-manager.service.js +27 -3
  117. package/dist/services/agent-hub-process-manager.service.js.map +1 -1
  118. package/dist/services/agent-registry.service.d.ts +2 -0
  119. package/dist/services/agent-registry.service.d.ts.map +1 -1
  120. package/dist/services/agent-registry.service.js +36 -1
  121. package/dist/services/agent-registry.service.js.map +1 -1
  122. package/dist/services/api-key-portal-session.spec.d.ts +2 -0
  123. package/dist/services/api-key-portal-session.spec.d.ts.map +1 -0
  124. package/dist/services/api-key-portal-session.spec.js +71 -0
  125. package/dist/services/api-key-portal-session.spec.js.map +1 -0
  126. package/dist/services/api-key.service.d.ts +12 -0
  127. package/dist/services/api-key.service.d.ts.map +1 -1
  128. package/dist/services/api-key.service.js +58 -0
  129. package/dist/services/api-key.service.js.map +1 -1
  130. package/dist/services/authentication.service.d.ts +1 -0
  131. package/dist/services/authentication.service.d.ts.map +1 -1
  132. package/dist/services/authentication.service.js +14 -1
  133. package/dist/services/authentication.service.js.map +1 -1
  134. package/dist/services/crud.service.d.ts +1 -0
  135. package/dist/services/crud.service.d.ts.map +1 -1
  136. package/dist/services/crud.service.js +26 -2
  137. package/dist/services/crud.service.js.map +1 -1
  138. package/dist/services/settings/default-settings-provider.service.d.ts +16 -6
  139. package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
  140. package/dist/services/settings/default-settings-provider.service.js +9 -3
  141. package/dist/services/settings/default-settings-provider.service.js.map +1 -1
  142. package/dist/solid-core.module.d.ts.map +1 -1
  143. package/dist/solid-core.module.js +5 -0
  144. package/dist/solid-core.module.js.map +1 -1
  145. package/dist/testing/adapters/ui/browser-provisioner.d.ts +11 -0
  146. package/dist/testing/adapters/ui/browser-provisioner.d.ts.map +1 -1
  147. package/dist/testing/adapters/ui/browser-provisioner.js +51 -1
  148. package/dist/testing/adapters/ui/browser-provisioner.js.map +1 -1
  149. package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts +2 -0
  150. package/dist/testing/adapters/ui/browser-provisioner.spec.d.ts.map +1 -0
  151. package/dist/testing/adapters/ui/browser-provisioner.spec.js +137 -0
  152. package/dist/testing/adapters/ui/browser-provisioner.spec.js.map +1 -0
  153. package/dist/testing/adapters/ui/playwright-adapter.d.ts +7 -0
  154. package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -1
  155. package/dist/testing/adapters/ui/playwright-adapter.js +40 -9
  156. package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -1
  157. package/dist/testing/adapters/ui/run-video.d.ts +40 -0
  158. package/dist/testing/adapters/ui/run-video.d.ts.map +1 -0
  159. package/dist/testing/adapters/ui/run-video.js +113 -0
  160. package/dist/testing/adapters/ui/run-video.js.map +1 -0
  161. package/dist/testing/adapters/ui/run-video.spec.d.ts +2 -0
  162. package/dist/testing/adapters/ui/run-video.spec.d.ts.map +1 -0
  163. package/dist/testing/adapters/ui/run-video.spec.js +62 -0
  164. package/dist/testing/adapters/ui/run-video.spec.js.map +1 -0
  165. package/dist/testing/contracts/runtime-context.types.d.ts +7 -0
  166. package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -1
  167. package/dist/testing/contracts/runtime-context.types.js.map +1 -1
  168. package/dist/testing/contracts/testing-metadata.types.d.ts +1 -0
  169. package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -1
  170. package/dist/testing/contracts/testing-metadata.types.js.map +1 -1
  171. package/dist/testing/core/interpolation.d.ts.map +1 -1
  172. package/dist/testing/core/interpolation.js +14 -2
  173. package/dist/testing/core/interpolation.js.map +1 -1
  174. package/dist/testing/core/step-data.d.ts +5 -0
  175. package/dist/testing/core/step-data.d.ts.map +1 -0
  176. package/dist/testing/core/step-data.js +14 -0
  177. package/dist/testing/core/step-data.js.map +1 -0
  178. package/dist/testing/core/step-data.spec.d.ts +2 -0
  179. package/dist/testing/core/step-data.spec.d.ts.map +1 -0
  180. package/dist/testing/core/step-data.spec.js +48 -0
  181. package/dist/testing/core/step-data.spec.js.map +1 -0
  182. package/dist/testing/core/testing-engine.d.ts +1 -1
  183. package/dist/testing/core/testing-engine.d.ts.map +1 -1
  184. package/dist/testing/core/testing-engine.js +27 -4
  185. package/dist/testing/core/testing-engine.js.map +1 -1
  186. package/dist/testing/reporter/lifecycle-events.types.d.ts +3 -2
  187. package/dist/testing/reporter/lifecycle-events.types.d.ts.map +1 -1
  188. package/dist/testing/reporter/lifecycle-events.types.js.map +1 -1
  189. package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts +2 -1
  190. package/dist/testing/reporter/lifecycle-webhook-reporter.d.ts.map +1 -1
  191. package/dist/testing/reporter/lifecycle-webhook-reporter.js +3 -0
  192. package/dist/testing/reporter/lifecycle-webhook-reporter.js.map +1 -1
  193. package/dist/testing/reporter/reporter.types.d.ts +2 -1
  194. package/dist/testing/reporter/reporter.types.d.ts.map +1 -1
  195. package/dist/testing/reporter/reporter.types.js.map +1 -1
  196. package/dist/testing/runner/read-scenarios-file.d.ts +1 -0
  197. package/dist/testing/runner/read-scenarios-file.d.ts.map +1 -1
  198. package/dist/testing/runner/read-scenarios-file.js +20 -0
  199. package/dist/testing/runner/read-scenarios-file.js.map +1 -1
  200. package/dist/testing/runner/run-from-metadata.d.ts.map +1 -1
  201. package/dist/testing/runner/run-from-metadata.js +48 -10
  202. package/dist/testing/runner/run-from-metadata.js.map +1 -1
  203. package/dist/testing/runner/run-from-metadata.spec.js +41 -1
  204. package/dist/testing/runner/run-from-metadata.spec.js.map +1 -1
  205. package/dist/testing/runner/scenario-graph.d.ts +9 -0
  206. package/dist/testing/runner/scenario-graph.d.ts.map +1 -1
  207. package/dist/testing/runner/scenario-graph.js +47 -13
  208. package/dist/testing/runner/scenario-graph.js.map +1 -1
  209. package/dist/testing/steps/ui/navigation.step.d.ts.map +1 -1
  210. package/dist/testing/steps/ui/navigation.step.js +4 -1
  211. package/dist/testing/steps/ui/navigation.step.js.map +1 -1
  212. package/dist/testing/steps/util/random.step.d.ts.map +1 -1
  213. package/dist/testing/steps/util/random.step.js +4 -1
  214. package/dist/testing/steps/util/random.step.js.map +1 -1
  215. package/package.json +1 -1
  216. package/resources/admin-embed/solid-admin-embed.js +133 -0
  217. package/resources/agent-embed/solid-agent-embed.js +243 -4
  218. package/src/constants/error-messages.ts +2 -1
  219. package/src/controllers/admin-embed.controller.ts +34 -0
  220. package/src/controllers/agent-registry.controller.ts +8 -1
  221. package/src/controllers/agent-session.controller.ts +53 -2
  222. package/src/controllers/authentication.controller.ts +20 -1
  223. package/src/controllers/test-data.controller.spec.ts +94 -0
  224. package/src/controllers/test-data.controller.ts +58 -0
  225. package/src/dtos/create-agent-job.dto.ts +6 -0
  226. package/src/dtos/create-agent-process.dto.ts +32 -1
  227. package/src/dtos/create-agent-registry.dto.ts +34 -1
  228. package/src/dtos/create-agent-session.dto.ts +1 -1
  229. package/src/dtos/test-run-request.dto.ts +6 -0
  230. package/src/dtos/update-agent-deployment.dto.ts +37 -0
  231. package/src/dtos/update-agent-job.dto.ts +6 -0
  232. package/src/dtos/update-agent-process.dto.ts +32 -1
  233. package/src/dtos/update-agent-registry.dto.ts +34 -1
  234. package/src/dtos/update-agent-session.dto.ts +1 -1
  235. package/src/entities/agent-job.entity.ts +5 -1
  236. package/src/entities/agent-process.entity.ts +28 -0
  237. package/src/entities/agent-registry.entity.ts +15 -0
  238. package/src/entities/agent-session.entity.ts +3 -0
  239. package/src/guards/access-token.guard.ts +11 -1
  240. package/src/helpers/agent-config-version-name.spec.ts +35 -0
  241. package/src/helpers/agent-config-version-name.ts +16 -0
  242. package/src/index.ts +5 -0
  243. package/src/interfaces/active-user-data.interface.ts +3 -0
  244. package/src/jobs/database/test-run-queue-subscriber-database.service.ts +10 -6
  245. package/src/seeders/module-test-data.service.spec.ts +184 -0
  246. package/src/seeders/module-test-data.service.ts +136 -20
  247. package/src/seeders/seed-data/solid-core-metadata.json +376 -12
  248. package/src/services/agent-hub-process-manager.service.ts +35 -4
  249. package/src/services/agent-registry.service.ts +38 -2
  250. package/src/services/api-key-portal-session.spec.ts +75 -0
  251. package/src/services/api-key.service.ts +61 -0
  252. package/src/services/authentication.service.ts +16 -2
  253. package/src/services/crud.service.ts +30 -2
  254. package/src/services/settings/default-settings-provider.service.ts +13 -3
  255. package/src/solid-core.module.ts +5 -0
  256. package/src/testing/adapters/ui/browser-provisioner.spec.ts +131 -0
  257. package/src/testing/adapters/ui/browser-provisioner.ts +85 -2
  258. package/src/testing/adapters/ui/playwright-adapter.ts +53 -11
  259. package/src/testing/adapters/ui/run-video.spec.ts +72 -0
  260. package/src/testing/adapters/ui/run-video.ts +122 -0
  261. package/src/testing/contracts/runtime-context.types.ts +16 -0
  262. package/src/testing/contracts/testing-metadata.types.ts +5 -0
  263. package/src/testing/core/interpolation.ts +11 -2
  264. package/src/testing/core/step-data.spec.ts +59 -0
  265. package/src/testing/core/step-data.ts +14 -0
  266. package/src/testing/core/testing-engine.ts +33 -5
  267. package/src/testing/reporter/lifecycle-events.types.ts +5 -2
  268. package/src/testing/reporter/lifecycle-webhook-reporter.ts +4 -1
  269. package/src/testing/reporter/reporter.types.ts +3 -1
  270. package/src/testing/runner/read-scenarios-file.ts +24 -0
  271. package/src/testing/runner/run-from-metadata.spec.ts +48 -1
  272. package/src/testing/runner/run-from-metadata.ts +66 -21
  273. package/src/testing/runner/scenario-graph.ts +55 -12
  274. package/src/testing/steps/ui/navigation.step.ts +4 -1
  275. 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
- ...(this.videoDir ? { recordVideo: { dir: this.videoDir } } : {}),
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 segment (one per browser context), after {@link stop}. */
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
- const single = this.videoSegments.length === 1;
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
- return resolveToken(token, ctx);
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(first.trim(), ctx);
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 start/end. Throws the step's error.
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
- kind: "console" | "network" | "screenshot" | "video" | "har" | "api-log";
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: {