@testsprite/testsprite-cli 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +52 -147
  2. package/dist/commands/agent.d.ts +12 -4
  3. package/dist/commands/agent.js +48 -63
  4. package/dist/commands/auth.d.ts +6 -10
  5. package/dist/commands/auth.js +40 -56
  6. package/dist/commands/ci.d.ts +23 -100
  7. package/dist/commands/ci.js +293 -487
  8. package/dist/commands/conversation.d.ts +27 -0
  9. package/dist/commands/conversation.js +741 -0
  10. package/dist/commands/doctor.d.ts +5 -1
  11. package/dist/commands/doctor.js +129 -34
  12. package/dist/commands/init.d.ts +4 -45
  13. package/dist/commands/init.js +108 -66
  14. package/dist/commands/project-env.d.ts +62 -2
  15. package/dist/commands/project-env.js +434 -43
  16. package/dist/commands/project-sign-in.d.ts +0 -48
  17. package/dist/commands/project-sign-in.js +1 -229
  18. package/dist/commands/project.d.ts +19 -186
  19. package/dist/commands/project.js +108 -926
  20. package/dist/commands/result.d.ts +10 -0
  21. package/dist/commands/result.js +216 -0
  22. package/dist/commands/schedule.d.ts +0 -29
  23. package/dist/commands/schedule.js +28 -87
  24. package/dist/commands/test.d.ts +301 -1838
  25. package/dist/commands/test.js +1880 -13917
  26. package/dist/commands/testlist.d.ts +130 -5
  27. package/dist/commands/testlist.js +300 -342
  28. package/dist/commands/tunnel.d.ts +3 -3
  29. package/dist/commands/tunnel.js +23 -20
  30. package/dist/commands/usage.d.ts +12 -45
  31. package/dist/commands/usage.js +50 -131
  32. package/dist/index.js +191 -110
  33. package/dist/lib/agent-detect.js +9 -5
  34. package/dist/lib/agent-targets.d.ts +21 -2
  35. package/dist/lib/agent-targets.js +88 -11
  36. package/dist/lib/args.d.ts +13 -0
  37. package/dist/lib/args.js +49 -0
  38. package/dist/lib/basic-auth.d.ts +3 -0
  39. package/dist/lib/basic-auth.js +15 -0
  40. package/dist/lib/billing-refusal.js +4 -3
  41. package/dist/lib/ci-linkage.d.ts +4 -82
  42. package/dist/lib/ci-linkage.js +4 -157
  43. package/dist/lib/ci-run.js +1 -1
  44. package/dist/lib/client-factory.d.ts +12 -4
  45. package/dist/lib/client-factory.js +41 -30
  46. package/dist/lib/commit-signal.d.ts +65 -0
  47. package/dist/lib/commit-signal.js +305 -0
  48. package/dist/lib/concurrency-limiter.d.ts +6 -0
  49. package/dist/lib/concurrency-limiter.js +29 -0
  50. package/dist/lib/config.js +10 -5
  51. package/dist/lib/conflict-reason.d.ts +9 -3
  52. package/dist/lib/conflict-reason.js +6 -3
  53. package/dist/lib/conversation/answers.d.ts +9 -0
  54. package/dist/lib/conversation/answers.js +49 -0
  55. package/dist/lib/conversation/api.d.ts +75 -0
  56. package/dist/lib/conversation/api.js +151 -0
  57. package/dist/lib/conversation/change.d.ts +31 -0
  58. package/dist/lib/conversation/change.js +124 -0
  59. package/dist/lib/conversation/context.d.ts +29 -0
  60. package/dist/lib/conversation/context.js +82 -0
  61. package/dist/lib/conversation/environment.d.ts +16 -0
  62. package/dist/lib/conversation/environment.js +21 -0
  63. package/dist/lib/conversation/follow.d.ts +24 -0
  64. package/dist/lib/conversation/follow.js +42 -0
  65. package/dist/lib/conversation/render.d.ts +33 -0
  66. package/dist/lib/conversation/render.js +318 -0
  67. package/dist/lib/conversation/title.d.ts +2 -0
  68. package/dist/lib/conversation/title.js +18 -0
  69. package/dist/lib/conversation/types.d.ts +158 -0
  70. package/dist/lib/conversation/types.js +6 -0
  71. package/dist/lib/credentials.js +67 -11
  72. package/dist/lib/cron.d.ts +1 -1
  73. package/dist/lib/cron.js +2 -2
  74. package/dist/lib/dispatch-stop.d.ts +20 -0
  75. package/dist/lib/dispatch-stop.js +30 -0
  76. package/dist/lib/download.d.ts +100 -0
  77. package/dist/lib/download.js +408 -0
  78. package/dist/lib/dry-run/fetch.d.ts +10 -0
  79. package/dist/lib/dry-run/fetch.js +20 -0
  80. package/dist/lib/dry-run/samples.d.ts +6 -34
  81. package/dist/lib/dry-run/samples.js +375 -747
  82. package/dist/lib/environment-tunnel.d.ts +19 -30
  83. package/dist/lib/environment-tunnel.js +168 -202
  84. package/dist/lib/errors.d.ts +20 -4
  85. package/dist/lib/errors.js +36 -16
  86. package/dist/lib/facade.d.ts +7 -29
  87. package/dist/lib/facade.js +7 -36
  88. package/dist/lib/failing-fe-resolver.d.ts +13 -58
  89. package/dist/lib/failing-fe-resolver.js +47 -132
  90. package/dist/lib/first-suite-hint.d.ts +20 -30
  91. package/dist/lib/first-suite-hint.js +57 -72
  92. package/dist/lib/gh-output.d.ts +76 -21
  93. package/dist/lib/gh-output.js +171 -90
  94. package/dist/lib/git-utils.d.ts +56 -0
  95. package/dist/lib/git-utils.js +212 -0
  96. package/dist/lib/github-context.d.ts +2 -0
  97. package/dist/lib/github-context.js +40 -8
  98. package/dist/lib/history-retention.d.ts +6 -2
  99. package/dist/lib/history-retention.js +10 -7
  100. package/dist/lib/http.d.ts +58 -134
  101. package/dist/lib/http.js +354 -291
  102. package/dist/lib/interrupt.d.ts +14 -8
  103. package/dist/lib/interrupt.js +28 -10
  104. package/dist/lib/junit-report.d.ts +57 -4
  105. package/dist/lib/junit-report.js +202 -32
  106. package/dist/lib/local-target.d.ts +8 -7
  107. package/dist/lib/local-target.js +14 -13
  108. package/dist/lib/output.d.ts +2 -41
  109. package/dist/lib/output.js +13 -51
  110. package/dist/lib/pagination.d.ts +2 -5
  111. package/dist/lib/pagination.js +2 -5
  112. package/dist/lib/presigned-url.d.ts +22 -0
  113. package/dist/lib/presigned-url.js +90 -0
  114. package/dist/lib/prompt.js +36 -2
  115. package/dist/lib/proxy.js +2 -1
  116. package/dist/lib/redact.d.ts +2 -2
  117. package/dist/lib/redact.js +3 -4
  118. package/dist/lib/removed-commands.d.ts +18 -0
  119. package/dist/lib/removed-commands.js +170 -0
  120. package/dist/lib/render-error.d.ts +31 -6
  121. package/dist/lib/render-error.js +88 -25
  122. package/dist/lib/response-schemas.d.ts +38 -30
  123. package/dist/lib/response-schemas.js +207 -207
  124. package/dist/lib/result/api.d.ts +24 -0
  125. package/dist/lib/result/api.js +28 -0
  126. package/dist/lib/result/evidence.d.ts +73 -0
  127. package/dist/lib/result/evidence.js +422 -0
  128. package/dist/lib/result/render.d.ts +20 -0
  129. package/dist/lib/result/render.js +194 -0
  130. package/dist/lib/result/types.d.ts +122 -0
  131. package/dist/lib/result/types.js +19 -0
  132. package/dist/lib/run-output.d.ts +275 -0
  133. package/dist/lib/run-output.js +227 -0
  134. package/dist/lib/run-render.d.ts +101 -0
  135. package/dist/lib/run-render.js +183 -0
  136. package/dist/lib/run-wait.d.ts +192 -0
  137. package/dist/lib/run-wait.js +452 -0
  138. package/dist/lib/runs.types.d.ts +118 -367
  139. package/dist/lib/runs.types.js +0 -14
  140. package/dist/lib/secret-file.d.ts +1 -1
  141. package/dist/lib/secret-file.js +11 -2
  142. package/dist/lib/skill-nudge.d.ts +7 -27
  143. package/dist/lib/skill-nudge.js +9 -37
  144. package/dist/lib/target-path.d.ts +15 -0
  145. package/dist/lib/target-path.js +35 -0
  146. package/dist/lib/target-url-advisory.d.ts +19 -0
  147. package/dist/lib/target-url-advisory.js +31 -0
  148. package/dist/lib/target-url-preflight.d.ts +9 -0
  149. package/dist/lib/target-url-preflight.js +214 -106
  150. package/dist/lib/target-url.d.ts +8 -8
  151. package/dist/lib/target-url.js +14 -24
  152. package/dist/lib/telemetry.d.ts +35 -15
  153. package/dist/lib/telemetry.js +38 -9
  154. package/dist/lib/terminal-text.d.ts +41 -0
  155. package/dist/lib/terminal-text.js +127 -0
  156. package/dist/lib/testlist.types.d.ts +16 -8
  157. package/dist/lib/testlist.types.js +1 -1
  158. package/dist/lib/text-equality.d.ts +2 -0
  159. package/dist/lib/text-equality.js +5 -0
  160. package/dist/lib/text-file.d.ts +16 -0
  161. package/dist/lib/text-file.js +41 -0
  162. package/dist/lib/text-table.d.ts +46 -0
  163. package/dist/lib/text-table.js +72 -4
  164. package/dist/lib/ticker.d.ts +9 -2
  165. package/dist/lib/ticker.js +16 -3
  166. package/dist/lib/transport-failure.d.ts +22 -0
  167. package/dist/lib/transport-failure.js +126 -0
  168. package/dist/lib/tunnel-session.d.ts +8 -2
  169. package/dist/lib/tunnel-session.js +24 -11
  170. package/dist/lib/update-check.js +3 -2
  171. package/dist/lib/url-template.d.ts +43 -0
  172. package/dist/lib/url-template.js +151 -0
  173. package/dist/lib/validate.d.ts +0 -64
  174. package/dist/lib/validate.js +2 -131
  175. package/dist/lib/version-notice.js +4 -3
  176. package/dist/lib/wait-exit.d.ts +37 -2
  177. package/dist/lib/wait-exit.js +88 -30
  178. package/dist/lib/workspace-status.js +10 -2
  179. package/dist/version.d.ts +1 -1
  180. package/dist/version.js +1 -1
  181. package/package.json +2 -3
  182. package/skills/testsprite-ci.skill.md +52 -23
  183. package/skills/testsprite-onboard.skill.md +70 -153
  184. package/skills/testsprite-verify.codex.md +54 -58
  185. package/skills/testsprite-verify.skill.md +189 -358
  186. package/dist/lib/browser.d.ts +0 -6
  187. package/dist/lib/browser.js +0 -54
  188. package/dist/lib/bundle.d.ts +0 -234
  189. package/dist/lib/bundle.js +0 -781
  190. package/dist/lib/deprecate.d.ts +0 -32
  191. package/dist/lib/deprecate.js +0 -39
  192. package/dist/lib/flaky.d.ts +0 -91
  193. package/dist/lib/flaky.js +0 -71
  194. package/dist/lib/plan-poll.d.ts +0 -171
  195. package/dist/lib/plan-poll.js +0 -441
  196. package/dist/lib/plans.types.d.ts +0 -130
  197. package/dist/lib/plans.types.js +0 -31
  198. package/dist/lib/poll.d.ts +0 -100
  199. package/dist/lib/poll.js +0 -290
  200. package/dist/lib/rate-throttle.d.ts +0 -49
  201. package/dist/lib/rate-throttle.js +0 -75
  202. package/dist/lib/run-progress.d.ts +0 -41
  203. package/dist/lib/run-progress.js +0 -56
  204. package/dist/lib/v3-advisory.d.ts +0 -55
  205. package/dist/lib/v3-advisory.js +0 -74
  206. package/schemas/plan.schema.json +0 -61
@@ -1,37 +1,37 @@
1
- import { ApiError } from '../errors.js';
2
1
  import { buildJUnitReport } from '../junit-report.js';
3
2
  const SAMPLE_USER_ID = '11111111-1111-4111-8111-111111111111';
4
3
  const SAMPLE_KEY_ID = 'key_dryrun_2026';
5
4
  const SAMPLE_PROJECT_ID = 'project_b3c91efa';
5
+ const SAMPLE_CONVERSATION_ID = 'conv_dryrun_2026';
6
+ const SAMPLE_CONVERSATION_URL = `https://portal.dry-run.invalid/dashboard-v3/projects/${SAMPLE_PROJECT_ID}/agent/${SAMPLE_CONVERSATION_ID}`;
6
7
  const SAMPLE_PROJECT_ID_BACKEND = 'project_a47b2c11';
7
8
  const SAMPLE_TEST_ID_FAILED = 'test_8f2a4d10';
8
9
  const SAMPLE_TEST_ID_PASSED = 'test_3a91bb02';
9
10
  const SAMPLE_TEST_ID_BLOCKED = 'test_blocked_4f7a';
10
- export const SAMPLE_RUN_ID = 'run_abc';
11
+ const SAMPLE_TEST_ID_RUNNING = 'test_running_6c1e';
12
+ /**
13
+ * The sample run (one launch) and its results, one per test. Result ids start
14
+ * `res_` and run ids `run_`, so a dry run never shows one under the other's
15
+ * name.
16
+ */
17
+ const SAMPLE_RUN_ID = 'run_dryrun0001';
18
+ const SAMPLE_RESULT_ID = 'res_dryrun0001';
19
+ const SAMPLE_RESULT_ID_PASSED = 'res_dryrun0002';
20
+ const SAMPLE_RESULT_ID_BLOCKED = 'res_dryrun0003';
21
+ const SAMPLE_RESULT_ID_RUNNING = 'res_dryrun0004';
11
22
  const SAMPLE_SCHEDULE_ID = 'sch_7d21ac48';
12
- const SAMPLE_SCHEDULE_RUN_ID = 'exec_5c08f1b2';
23
+ const SAMPLE_SCHEDULE_RUN_ID = 'run_dryrun0002';
13
24
  const SAMPLE_TUNNEL_ID_1 = '00000000-0000-4000-8000-000000000001';
14
25
  const SAMPLE_TUNNEL_ID_2 = '00000000-0000-4000-8000-000000000002';
15
- // Documented sentinel for `test steps --run-id run_failed_sample --dry-run`:
16
- // keeps wait flows on the default passed sample while still demonstrating a
17
- // run-scoped failed step offline.
18
- const SAMPLE_FAILED_RUN_ID = 'run_failed_sample';
19
- // M3.4 rerun dry-run sample IDs
20
- const SAMPLE_RERUN_ID_BE_NAMED = 'run_rerun_be_named';
21
- const SAMPLE_RERUN_ID_BE_PRODUCER = 'run_rerun_be_producer';
22
- const SAMPLE_TEST_ID_BE_CONSUMER = 'test_be_consumer_01';
23
- const SAMPLE_TEST_ID_BE_PRODUCER = 'test_be_producer_01';
24
- const SAMPLE_RERUN_BATCH_ID_1 = 'run_batch_rerun_001';
25
- const SAMPLE_RERUN_BATCH_ID_2 = 'run_batch_rerun_002';
26
- const SAMPLE_TEST_ID_BATCH_1 = 'test_batch_01';
27
- const SAMPLE_TEST_ID_BATCH_2 = 'test_batch_02';
28
- const SAMPLE_TEST_ID_DEFERRED = 'test_deferred_01';
29
- // M4 piece-2 — batch fresh run sample IDs
30
- const SAMPLE_BATCH_FRESH_RUN_ID_1 = 'run_fresh_batch_001';
31
- const SAMPLE_BATCH_FRESH_RUN_ID_2 = 'run_fresh_batch_002';
26
+ // A result id `GET /runs/{id}` answers with the failed sample: keeps wait
27
+ // flows on the default passed sample while still demonstrating a failed
28
+ // result offline.
29
+ const SAMPLE_FAILED_RESULT_ID = 'res_failed_sample';
30
+ // The results a fresh batch run starts, in the sample run.
31
+ const SAMPLE_BATCH_FRESH_RESULT_ID_1 = 'res_dryrun0005';
32
+ const SAMPLE_BATCH_FRESH_RESULT_ID_2 = 'res_dryrun0006';
32
33
  const SAMPLE_TEST_ID_FRESH_1 = 'test_fresh_wave_01';
33
34
  const SAMPLE_TEST_ID_FRESH_2 = 'test_fresh_wave_02';
34
- const SAMPLE_SNAPSHOT_ID = 'snap_2026_05_05_b2f9a1c8';
35
35
  const SAMPLE_TARGET_URL = 'https://staging.example.com/checkout';
36
36
  const SAMPLE_REQUEST_ID = 'req_dry-run';
37
37
  export const SAMPLE_DRY_RUN_REQUEST_ID = SAMPLE_REQUEST_ID;
@@ -46,12 +46,14 @@ export function sampleJUnitReportXml(projectId = SAMPLE_PROJECT_ID, reportSuiteN
46
46
  results: [
47
47
  {
48
48
  testId: SAMPLE_TEST_ID_FRESH_1,
49
- runId: SAMPLE_BATCH_FRESH_RUN_ID_1,
49
+ resultId: SAMPLE_BATCH_FRESH_RESULT_ID_1,
50
+ runId: SAMPLE_RUN_ID,
50
51
  status: 'passed',
51
52
  },
52
53
  {
53
54
  testId: SAMPLE_TEST_ID_FRESH_2,
54
- runId: SAMPLE_BATCH_FRESH_RUN_ID_2,
55
+ resultId: SAMPLE_BATCH_FRESH_RESULT_ID_2,
56
+ runId: SAMPLE_RUN_ID,
55
57
  status: 'failed',
56
58
  error: {
57
59
  code: 'ASSERTION',
@@ -67,7 +69,6 @@ const me = {
67
69
  keyId: SAMPLE_KEY_ID,
68
70
  scopes: ['read:projects', 'read:tests', 'write:tests', 'run:tests'],
69
71
  env: 'development',
70
- v3Enabled: true,
71
72
  activeOrg: {
72
73
  id: '22222222-2222-4222-8222-222222222222',
73
74
  name: 'Dry Run Workspace',
@@ -103,6 +104,8 @@ const schedule = {
103
104
  enabled: true,
104
105
  targetType: 'project',
105
106
  targetId: SAMPLE_PROJECT_ID,
107
+ environment: null,
108
+ environmentMode: 'inherit',
106
109
  cron: '0 3 * * *',
107
110
  timezone: 'UTC',
108
111
  startAt: '2026-05-01T00:00:00.000Z',
@@ -113,263 +116,245 @@ const schedule = {
113
116
  createdAt: '2026-05-01T00:00:00.000Z',
114
117
  updatedAt: '2026-05-02T00:00:00.000Z',
115
118
  };
116
- // A finished run with one failure — more instructive for a dry-run learner than
117
- // an all-green one, since it shows how the per-status counts relate to `status`.
118
- const scheduleRun = {
119
- runId: SAMPLE_SCHEDULE_RUN_ID,
120
- scheduleId: SAMPLE_SCHEDULE_ID,
121
- status: 'failed',
122
- projectId: SAMPLE_PROJECT_ID,
123
- testListId: null,
124
- stats: { total: 4, passed: 3, failed: 1, blocked: 0, running: 0, cancelled: 0 },
125
- createdAt: '2026-05-02T03:00:00.000Z',
126
- updatedAt: '2026-05-02T03:06:41.000Z',
127
- };
128
119
  const tests = [
129
120
  {
130
121
  id: SAMPLE_TEST_ID_FAILED,
131
122
  projectId: SAMPLE_PROJECT_ID,
132
- name: 'Checkout happy path',
123
+ projectName: 'Checkout',
124
+ slug: 'CHECKOUT-001',
125
+ title: 'Checkout happy path',
126
+ description: 'Pays for a cart with a saved card and lands on the confirmation page.',
133
127
  type: 'frontend',
134
- createdFrom: 'portal',
135
- status: 'failed',
136
- // G1a — priority label shown on one row so dry-run learners see the field.
128
+ isIntegration: false,
129
+ category: 'Checkout',
137
130
  priority: 'Medium',
131
+ version: { hash: 'a3f9c2e1d4b7', label: 'v1.2' },
132
+ stepCount: 8,
138
133
  createdAt: '2026-04-20T11:00:00.000Z',
139
134
  updatedAt: '2026-05-05T12:34:56.000Z',
140
- details: {
141
- processingStatus: 'Idle',
142
- testStatus: 'Failed',
143
- rawStatus: 'ps=Idle; ts=Failed',
144
- },
145
135
  },
146
136
  {
147
137
  id: SAMPLE_TEST_ID_PASSED,
148
138
  projectId: SAMPLE_PROJECT_ID,
149
- name: 'Checkout — declined card',
139
+ projectName: 'Checkout',
140
+ slug: 'CHECKOUT-002',
141
+ title: 'Checkout — declined card',
142
+ description: null,
150
143
  type: 'frontend',
151
- createdFrom: 'portal',
152
- status: 'passed',
144
+ isIntegration: false,
145
+ category: 'Checkout',
153
146
  priority: null,
147
+ version: { hash: '7c1e0b9a5d22', label: 'v1.0' },
148
+ stepCount: 5,
154
149
  createdAt: '2026-04-20T11:00:00.000Z',
155
150
  updatedAt: '2026-05-05T08:00:00.000Z',
156
- details: {
157
- processingStatus: 'Idle',
158
- testStatus: 'Passed',
159
- rawStatus: 'ps=Idle; ts=Passed',
160
- },
161
151
  },
162
152
  {
163
- // M2.1 piece 1: distinct `blocked` status surfaces here so a
164
- // dry-run learner sees how blocked rows render. Pre-M2.1 this
165
- // would have shown up as `failed` and would have been
166
- // indistinguishable from the row above.
167
153
  id: SAMPLE_TEST_ID_BLOCKED,
168
154
  projectId: SAMPLE_PROJECT_ID,
169
- name: 'Checkout — coupon redemption',
155
+ projectName: 'Checkout',
156
+ slug: 'CHECKOUT-003',
157
+ title: 'Checkout — coupon redemption',
158
+ description: null,
170
159
  type: 'frontend',
171
- createdFrom: 'portal',
172
- status: 'blocked',
160
+ isIntegration: false,
161
+ category: 'Checkout',
173
162
  priority: null,
163
+ version: { hash: 'e5d4c3b2a101', label: 'v1.0' },
164
+ stepCount: 6,
174
165
  createdAt: '2026-04-21T09:00:00.000Z',
175
166
  updatedAt: '2026-05-05T13:01:12.000Z',
176
- details: {
177
- processingStatus: 'Idle',
178
- testStatus: 'Blocked',
179
- rawStatus: 'ps=Idle; ts=Blocked',
180
- },
181
- },
182
- ];
183
- const testCode = {
184
- testId: SAMPLE_TEST_ID_FAILED,
185
- language: 'python',
186
- framework: 'playwright',
187
- // TestSprite test code is Python: frontend tests are Playwright
188
- // (`playwright.async_api`); backend tests use `requests` + assertions.
189
- code: [
190
- 'import asyncio',
191
- 'from playwright.async_api import async_playwright, expect',
192
- '',
193
- '',
194
- 'async def run_test():',
195
- ' async with async_playwright() as pw:',
196
- ' browser = await pw.chromium.launch(headless=True)',
197
- ' context = await browser.new_context()',
198
- ' page = await context.new_page()',
199
- ' try:',
200
- ' await page.goto("https://example.com") # target URL injected by the runner',
201
- ' await page.click(\'[data-testid="cart"]\')',
202
- ' await page.click(\'[data-testid="submit"]\')',
203
- ' await expect(page.get_by_role("heading", name="Order placed")).to_be_visible()',
204
- ' finally:',
205
- ' await context.close()',
206
- ' await browser.close()',
207
- '',
208
- '',
209
- 'asyncio.run(run_test())',
210
- '',
211
- ].join('\n'),
212
- codeVersion: 'v3',
213
- etag: 'sha256:c7c4a4f6c1b8c2e5',
214
- };
215
- // Sample step list. Includes both `outcomeContributesToFailure` per-step
216
- // flags (M2.1 piece 4) and the synthetic terminal "assertion" row
217
- // (piece-4 follow-up — also surfaced on `/steps`, not just `/failure`).
218
- // Step 5 is a real per-step failure → flag `true` only on that row;
219
- // step 7 is the synthesizer's fallback for assertion-level failures
220
- // where no per-step row caught the verdict, so dry-run learners see
221
- // both shapes in one fixture rather than only the per-step case.
222
- const testSteps = [
223
- {
224
- testId: SAMPLE_TEST_ID_FAILED,
225
- stepIndex: 4,
226
- action: 'click',
227
- description: 'Click the cart icon',
228
- status: 'passed',
229
- screenshotUrl: 'https://s3-presigned.example.com/snap/04.png?X-Amz-dryrun',
230
- htmlSnapshotUrl: 'https://s3-presigned.example.com/snap/04.html?X-Amz-dryrun',
231
- runIdIfAvailable: SAMPLE_RUN_ID,
232
- codeVersion: 'v3',
233
- capturedAt: '2026-05-05T12:34:55.000Z',
234
- updatedAt: '2026-05-05T12:34:56.000Z',
235
- outcomeContributesToFailure: false,
236
- },
237
- {
238
- testId: SAMPLE_TEST_ID_FAILED,
239
- stepIndex: 5,
240
- action: 'click',
241
- description: 'Click the submit button',
242
- status: 'failed',
243
- screenshotUrl: 'https://s3-presigned.example.com/snap/05.png?X-Amz-dryrun',
244
- htmlSnapshotUrl: 'https://s3-presigned.example.com/snap/05.html?X-Amz-dryrun',
245
- runIdIfAvailable: SAMPLE_RUN_ID,
246
- codeVersion: 'v3',
247
- capturedAt: '2026-05-05T12:34:56.000Z',
248
- updatedAt: '2026-05-05T12:34:56.000Z',
249
- outcomeContributesToFailure: true,
250
167
  },
251
168
  {
252
- testId: SAMPLE_TEST_ID_FAILED,
253
- stepIndex: 6,
254
- action: 'expect',
255
- description: 'Expect order confirmation heading',
256
- status: null,
257
- screenshotUrl: null,
258
- htmlSnapshotUrl: null,
259
- runIdIfAvailable: SAMPLE_RUN_ID,
260
- codeVersion: 'v3',
261
- capturedAt: null,
262
- updatedAt: '2026-05-05T12:34:58.000Z',
263
- outcomeContributesToFailure: false,
169
+ // Still running in the sample run, so a dry run of `run wait` / `test
170
+ // cancel` on that run shows the poll and the cancel request it would send.
171
+ id: SAMPLE_TEST_ID_RUNNING,
172
+ projectId: SAMPLE_PROJECT_ID,
173
+ projectName: 'Checkout',
174
+ slug: 'CHECKOUT-004',
175
+ title: 'Checkout — saved address',
176
+ description: null,
177
+ type: 'frontend',
178
+ isIntegration: false,
179
+ category: 'Checkout',
180
+ priority: null,
181
+ version: { hash: '9b8a7f6e5d4c', label: 'v1.0' },
182
+ stepCount: 4,
183
+ createdAt: '2026-04-22T10:00:00.000Z',
184
+ updatedAt: '2026-05-05T12:34:03.000Z',
264
185
  },
265
186
  ];
266
- const latestResult = {
267
- testId: SAMPLE_TEST_ID_FAILED,
268
- status: 'failed',
269
- startedAt: '2026-05-05T12:34:00.000Z',
270
- finishedAt: '2026-05-05T12:34:58.000Z',
271
- videoUrl: 'https://s3-presigned.example.com/video/run_abc.mp4?X-Amz-dryrun',
272
- failureAnalysisUrl: 'https://s3-presigned.example.com/analysis/run_abc.json?X-Amz-dryrun',
273
- snapshotId: SAMPLE_SNAPSHOT_ID,
274
- runIdIfAvailable: SAMPLE_RUN_ID,
275
- codeVersion: 'v3',
276
- targetUrl: SAMPLE_TARGET_URL,
277
- targetUrlSource: 'run',
278
- failedStepIndex: 5,
279
- failureKind: 'assertion',
280
- verdict: 'failed',
281
- executionStatus: 'completed',
282
- summary: 'Failed (assertion) on step 5: expected cart badge to show 1 item, but it was empty.',
283
- };
284
- const failureContext = {
285
- snapshotId: SAMPLE_SNAPSHOT_ID,
286
- testId: SAMPLE_TEST_ID_FAILED,
287
- projectId: SAMPLE_PROJECT_ID,
288
- result: latestResult,
289
- steps: testSteps,
290
- code: testCode,
291
- failure: {
292
- rootCauseHypothesis: 'Submit button has `opacity: 0.4` and is rendered as disabled. The checkout ' +
293
- "form's `isFormValid` predicate evaluates to false because the credit-card " +
294
- 'field is empty.',
295
- recommendedFixTarget: {
296
- kind: 'code',
297
- reference: 'src/components/CheckoutForm.tsx:412',
298
- rationale: 'The disabled state originates from `isFormValid()` in CheckoutForm.tsx; the ' +
299
- 'submit button only enables when `card.number.length === 16`. The test fixture ' +
300
- 'leaves the card field empty.',
301
- },
302
- evidence: [
303
- {
304
- kind: 'screenshot',
305
- stepIndex: 5,
306
- url: 'https://s3-presigned.example.com/evidence/run_abc/05.png?X-Amz-dryrun',
307
- summary: 'Submit button has `opacity: 0.4` and is rendered as disabled. Credit-card ' +
308
- 'field is empty. No visible error message.',
309
- },
310
- {
311
- kind: 'snapshot',
312
- stepIndex: 5,
313
- url: 'https://s3-presigned.example.com/evidence/run_abc/05.html?X-Amz-dryrun',
314
- summary: '`<button data-testid="submit" disabled aria-disabled="true" ' +
315
- 'style="pointer-events:none;opacity:0.4">`. DOM diff vs. step 4 shows the ' +
316
- "`disabled` attribute being added by the form's onChange handler.",
317
- },
318
- ],
319
- },
320
- };
187
+ // The failed result of the sample run: the checkout happy path, failing
188
+ // because the card field is empty.
189
+ const SAMPLE_RESULT_ERROR = 'AssertionError: expected the order confirmation heading to be visible';
190
+ const SAMPLE_RESULT_CAUSE = "The submit button stays disabled: the checkout form's `isFormValid` is false because the card field is empty.";
191
+ const SAMPLE_RESULT_FIX = 'Fill the card number before submitting the checkout form.';
321
192
  /**
322
- * §5.2 / M2.1 piece 3 — sample for `GET /tests/{testId}/failure/summary`.
323
- * Mirrors the analysis fields in `failureContext.failure` so a learner
324
- * comparing dry-run outputs sees the same hypothesis on both surfaces.
193
+ * The results of the sample run, newest first: one still running, the failed
194
+ * and the passed test of the report below, and the blocked test, which never
195
+ * got past sign-in.
196
+ * Each line names its test by the id and title `test list` prints for it, as
197
+ * a line from the backend does. The two history-window fields are sent for a
198
+ * test's history only, so a run's listing leaves them out.
325
199
  */
326
- const failureSummary = {
327
- testId: SAMPLE_TEST_ID_FAILED,
200
+ const resultListSample = {
201
+ results: [
202
+ {
203
+ resultId: SAMPLE_RESULT_ID_RUNNING,
204
+ runId: SAMPLE_RUN_ID,
205
+ caseKey: SAMPLE_TEST_ID_RUNNING,
206
+ title: 'Checkout — saved address',
207
+ testStatus: 'RUNNING',
208
+ processStatus: 'Executing',
209
+ error: null,
210
+ blockedReason: null,
211
+ environmentName: 'staging',
212
+ created: '2026-05-05T12:34:03.000Z',
213
+ },
214
+ {
215
+ resultId: SAMPLE_RESULT_ID_BLOCKED,
216
+ runId: SAMPLE_RUN_ID,
217
+ caseKey: SAMPLE_TEST_ID_BLOCKED,
218
+ title: 'Checkout — coupon redemption',
219
+ testStatus: 'BLOCKED',
220
+ processStatus: 'Idle',
221
+ error: null,
222
+ blockedReason: 'Sign-in failed, so the test never started.',
223
+ environmentName: 'staging',
224
+ created: '2026-05-05T12:34:02.000Z',
225
+ },
226
+ {
227
+ resultId: SAMPLE_RESULT_ID_PASSED,
228
+ runId: SAMPLE_RUN_ID,
229
+ caseKey: SAMPLE_TEST_ID_PASSED,
230
+ title: 'Checkout — declined card',
231
+ testStatus: 'PASSED',
232
+ processStatus: 'Idle',
233
+ error: null,
234
+ blockedReason: null,
235
+ environmentName: 'staging',
236
+ created: '2026-05-05T12:34:01.000Z',
237
+ },
238
+ {
239
+ resultId: SAMPLE_RESULT_ID,
240
+ runId: SAMPLE_RUN_ID,
241
+ caseKey: SAMPLE_TEST_ID_FAILED,
242
+ title: 'Checkout happy path',
243
+ testStatus: 'FAILED',
244
+ processStatus: 'Idle',
245
+ error: SAMPLE_RESULT_ERROR,
246
+ blockedReason: null,
247
+ environmentName: 'staging',
248
+ created: '2026-05-05T12:34:00.000Z',
249
+ },
250
+ ],
251
+ hiddenRunCount: 4,
252
+ retentionDays: 30,
253
+ };
254
+ const resultFailedStepSample = {
255
+ stepIndex: '3',
256
+ type: 'assertion',
257
+ action: 'visible',
258
+ description: 'Expect the order confirmation heading',
328
259
  status: 'failed',
329
- failureKind: 'assertion',
330
- snapshotId: SAMPLE_SNAPSHOT_ID,
331
- rootCauseHypothesis: failureContext.failure.rootCauseHypothesis,
332
- recommendedFixTarget: failureContext.failure.recommendedFixTarget,
260
+ selector: '[data-testid="order-confirmation"]',
261
+ url: SAMPLE_TARGET_URL,
262
+ healed: false,
263
+ screenshotSignedUrl: 'https://s3-presigned.example.com/snap/03.png?X-Amz-dryrun',
264
+ htmlSignedUrl: 'https://s3-presigned.example.com/snap/03.html?X-Amz-dryrun',
265
+ };
266
+ /** The failed result of the sample run, with its steps. */
267
+ const resultDetailSample = {
268
+ resultId: SAMPLE_RESULT_ID,
269
+ runId: SAMPLE_RUN_ID,
270
+ caseKey: SAMPLE_TEST_ID_FAILED,
271
+ caseHash: 'case_dryrun0001',
272
+ title: 'Checkout happy path',
273
+ type: 'FRONTEND',
274
+ testStatus: 'FAILED',
275
+ processStatus: 'Idle',
276
+ processErrorMessage: null,
277
+ error: SAMPLE_RESULT_ERROR,
278
+ cause: SAMPLE_RESULT_CAUSE,
279
+ fix: SAMPLE_RESULT_FIX,
280
+ blockedReason: null,
281
+ // A frontend test has no traceback or captured output.
282
+ trace: null,
283
+ apiOutput: null,
284
+ videoUrl: 'https://s3-presigned.example.com/video/res_dryrun0001.mp4?X-Amz-dryrun',
285
+ envId: 'env_dryrun0001',
286
+ created: '2026-05-05T12:34:00.000Z',
287
+ modified: '2026-05-05T12:34:58.000Z',
288
+ failedStep: resultFailedStepSample,
289
+ steps: [
290
+ {
291
+ stepIndex: '1',
292
+ type: 'action',
293
+ action: 'click',
294
+ description: 'Click the cart icon',
295
+ status: 'passed',
296
+ selector: '[data-testid="cart"]',
297
+ url: SAMPLE_TARGET_URL,
298
+ healed: false,
299
+ screenshotSignedUrl: 'https://s3-presigned.example.com/snap/01.png?X-Amz-dryrun',
300
+ htmlSignedUrl: 'https://s3-presigned.example.com/snap/01.html?X-Amz-dryrun',
301
+ },
302
+ {
303
+ stepIndex: '2',
304
+ type: 'action',
305
+ action: 'fill',
306
+ description: 'Fill the shipping address',
307
+ status: 'passed',
308
+ selector: '#address',
309
+ url: SAMPLE_TARGET_URL,
310
+ healed: true,
311
+ screenshotSignedUrl: 'https://s3-presigned.example.com/snap/02.png?X-Amz-dryrun',
312
+ htmlSignedUrl: 'https://s3-presigned.example.com/snap/02.html?X-Amz-dryrun',
313
+ },
314
+ resultFailedStepSample,
315
+ ],
316
+ signIn: null,
333
317
  };
334
- const SAMPLE_EXECUTION_ID = 'exec_dryrun0001';
335
318
  /** A ready execution report: one failed and one passed row, the App's Markdown shape in miniature. */
336
319
  const executionReportSample = {
337
320
  ready: true,
338
321
  report: {
339
322
  projectId: SAMPLE_PROJECT_ID,
340
- executionId: SAMPLE_EXECUTION_ID,
323
+ runId: SAMPLE_RUN_ID,
341
324
  projectName: 'Sample project',
342
325
  orgId: null,
343
326
  stats: { passed: 1, failed: 1, blocked: 0, total: 2 },
344
327
  allPassed: false,
345
- narrative: 'Dry-run sample: one regression in checkout, login passed.',
328
+ narrative: 'Dry-run sample: the checkout happy path regressed; the declined-card test passed.',
346
329
  whatCouldBeBetter: 'Add coverage for password reset.',
347
- recommendedNextStep: 'Fix the checkout selector and rerun.',
330
+ recommendedNextStep: 'Fill the card number in the checkout test and rerun.',
348
331
  tests: [
349
332
  {
350
- id: SAMPLE_RUN_ID,
351
- title: 'Checkout applies a coupon',
352
- slug: 'CHK-002',
333
+ id: SAMPLE_RESULT_ID,
334
+ title: 'Checkout happy path',
335
+ slug: 'CHK-001',
353
336
  status: 'FAILED',
354
337
  screenshotUrl: null,
355
- error: 'AssertionError: expected the order total to drop',
356
- fix: 'Apply the coupon before computing the total.',
338
+ error: SAMPLE_RESULT_ERROR,
339
+ fix: SAMPLE_RESULT_FIX,
357
340
  },
358
341
  {
359
- id: `${SAMPLE_RUN_ID}-2`,
360
- title: 'Login with a valid account',
361
- slug: 'AUTH-001',
342
+ id: SAMPLE_RESULT_ID_PASSED,
343
+ title: 'Checkout — declined card',
344
+ slug: 'CHK-002',
362
345
  status: 'PASSED',
363
346
  screenshotUrl: null,
364
347
  error: null,
365
348
  fix: null,
366
349
  },
367
350
  ],
368
- resultUrl: `https://www.testsprite.com/dashboard-v3/projects/${SAMPLE_PROJECT_ID}/execution/${SAMPLE_EXECUTION_ID}`,
351
+ resultUrl: `https://www.testsprite.com/dashboard-v3/projects/${SAMPLE_PROJECT_ID}/execution/${SAMPLE_RUN_ID}`,
369
352
  },
370
- markdown: '> [!WARNING]\n> ### Ran into trouble — 1 failed\n>\n> Dry-run sample: one regression in checkout, login passed.\n',
353
+ markdown: '> [!WARNING]\n> ### Ran into trouble — 1 failed\n>\n> Dry-run sample: the checkout happy path regressed; the declined-card test passed.\n',
371
354
  };
355
+ // Modern wire samples use native runId (execution) and resultId (result).
372
356
  const passedRunSample = {
357
+ resultId: SAMPLE_RESULT_ID,
373
358
  runId: SAMPLE_RUN_ID,
374
359
  testId: SAMPLE_TEST_ID_PASSED,
375
360
  projectId: SAMPLE_PROJECT_ID,
@@ -392,36 +377,10 @@ const passedRunSample = {
392
377
  passedCount: 2,
393
378
  failedCount: 0,
394
379
  },
395
- // Representative per-run steps so `test steps --run-id <id> --dry-run`
396
- // demonstrates real output instead of an empty list (the generic
397
- // `/runs/{runId}` sample is also used by `test wait`, which ignores steps).
398
- steps: [
399
- {
400
- stepIndex: '0001',
401
- type: 'action',
402
- action: 'navigate',
403
- status: 'passed',
404
- description: 'Open the target URL',
405
- error: null,
406
- screenshotUrl: null,
407
- htmlSnapshotUrl: null,
408
- createdAt: '2026-05-15T19:32:10.000Z',
409
- },
410
- {
411
- stepIndex: '0002',
412
- type: 'assertion',
413
- action: 'assert_visible',
414
- status: 'passed',
415
- description: 'Dashboard heading is visible',
416
- error: null,
417
- screenshotUrl: null,
418
- htmlSnapshotUrl: null,
419
- createdAt: '2026-05-15T19:32:20.000Z',
420
- },
421
- ],
422
380
  };
423
381
  const failedRunSample = {
424
- runId: SAMPLE_FAILED_RUN_ID,
382
+ resultId: SAMPLE_FAILED_RESULT_ID,
383
+ runId: SAMPLE_RUN_ID,
425
384
  testId: SAMPLE_TEST_ID_FAILED,
426
385
  projectId: SAMPLE_PROJECT_ID,
427
386
  userId: SAMPLE_USER_ID,
@@ -443,41 +402,6 @@ const failedRunSample = {
443
402
  passedCount: 2,
444
403
  failedCount: 1,
445
404
  },
446
- steps: [
447
- {
448
- stepIndex: '0001',
449
- type: 'action',
450
- action: 'navigate',
451
- status: 'passed',
452
- description: 'Open the target URL',
453
- error: null,
454
- screenshotUrl: null,
455
- htmlSnapshotUrl: null,
456
- createdAt: '2026-05-15T19:32:10.000Z',
457
- },
458
- {
459
- stepIndex: '0002',
460
- type: 'assertion',
461
- action: 'assert_visible',
462
- status: 'passed',
463
- description: 'Dashboard heading is visible',
464
- error: null,
465
- screenshotUrl: null,
466
- htmlSnapshotUrl: null,
467
- createdAt: '2026-05-15T19:32:20.000Z',
468
- },
469
- {
470
- stepIndex: '0003',
471
- type: 'assertion',
472
- action: 'assert_visible',
473
- status: 'failed',
474
- description: 'Billing status badge is visible',
475
- error: 'Expected billing status badge to be visible, but it was not found.',
476
- screenshotUrl: null,
477
- htmlSnapshotUrl: null,
478
- createdAt: '2026-05-15T19:32:30.000Z',
479
- },
480
- ],
481
405
  };
482
406
  const PATH_PREFIX = '/api/cli/v1';
483
407
  // Regex metacharacters that must be escaped when a literal string is spliced
@@ -488,7 +412,7 @@ function escapeRegExpLiteral(literal) {
488
412
  }
489
413
  /**
490
414
  * Build the matcher RegExp for a route template, e.g.
491
- * `/tests/{testId}/code` → /^\/tests\/[^/]+\/code$/. Splits on the
415
+ * `/results/{resultId}` → /^\/results\/[^/]+$/. Splits on the
492
416
  * `{param}` placeholders first, then regex-escapes every literal segment in
493
417
  * between (including any literal backslash) so a route literal containing a
494
418
  * regex metacharacter is matched literally instead of being reinterpreted as
@@ -504,155 +428,127 @@ function buildPathPattern(pathTemplate) {
504
428
  const ENTRIES = [
505
429
  entry('whoami', 'GET', '/me', me),
506
430
  entry('listProjects', 'GET', '/projects', pageOf(projects)),
507
- entry('getProjectSignIn', 'GET', '/projects/{projectId}/sign-in', {
508
- projectId: SAMPLE_PROJECT_ID,
509
- environment: {
510
- id: 'env_dryrun',
511
- name: 'default',
512
- url: 'https://app.example.com',
513
- isDefault: true,
514
- authMode: 'public',
515
- hasCredentials: false,
516
- username: null,
517
- enableOtp: false,
518
- updatedAt: '2026-09-25T00:00:00.000Z',
519
- },
520
- signIn: { mode: 'public', account: null, otp: null, manual: null },
521
- nextAction: null,
431
+ entry('startConversation', 'POST', '/projects/{projectId}/conversations', {
432
+ id: SAMPLE_CONVERSATION_ID,
433
+ url: SAMPLE_CONVERSATION_URL,
434
+ model: 'claude-opus-5-5',
522
435
  }),
523
- entry('setProjectSignIn', 'PUT', '/projects/{projectId}/sign-in', (request) => {
524
- const body = request;
525
- const mode = body?.mode ?? 'manual';
526
- return {
527
- projectId: SAMPLE_PROJECT_ID,
528
- environment: {
529
- id: 'env_dryrun',
530
- name: 'default',
531
- url: 'https://app.example.com',
532
- isDefault: true,
533
- authMode: mode,
534
- hasCredentials: mode === 'account',
535
- username: mode === 'account' ? 'qa@example.com' : null,
536
- enableOtp: mode === 'otp',
537
- updatedAt: '2026-09-25T00:00:00.000Z',
538
- },
539
- signIn: {
540
- mode,
541
- account: mode === 'account' ? { username: 'qa@example.com', passwordSet: true } : null,
542
- otp: mode === 'otp'
543
- ? { channels: ['email'], email: 'dryrun@inbox.example', phone: null }
544
- : null,
545
- manual: mode === 'manual'
546
- ? {
547
- sessionReuseTtlSeconds: 3600,
548
- hasValidSession: false,
549
- needsReauth: true,
550
- reason: 'never',
551
- capturedAt: null,
552
- expiresAt: null,
553
- }
554
- : null,
436
+ entry('listConversations', 'GET', '/projects/{projectId}/conversations', {
437
+ conversations: [
438
+ {
439
+ id: SAMPLE_CONVERSATION_ID,
440
+ title: 'Cover the new coupon rules',
441
+ state: 'proposed',
442
+ lastMessageAt: '2026-01-01T00:12:00.000Z',
443
+ url: SAMPLE_CONVERSATION_URL,
555
444
  },
556
- changed: mode !== 'otp',
557
- nextAction: mode === 'manual' ? 'Log in once in the Portal.' : null,
558
- };
445
+ ],
559
446
  }),
560
- // Plan-generation surface. All three MUST be registered
561
- // BEFORE `getProject`: findSample is first-match-wins and the projects/*
562
- // family shares the `/projects/…` prefix, so the more specific plans
563
- // paths are listed first (same defensive convention as `/tests/{id}/runs`
564
- // before the `/tests/{id}` catch-all; `samples.test.ts` proves the
565
- // ordering with shadowing tests).
566
- //
567
- // The trigger sample reports the PROPOSALS rung starting
568
- // (`stagesRemaining: []`) and the plans sample shows the settled result
569
- // (idle + two staged proposals), so a dry-run learner sees a coherent
570
- // story: trigger → stage runs → staged batch with stable proposalIds.
571
- entry('generatePlans', 'POST', '/projects/{projectId}/plans/generate', {
572
- status: 'accepted',
447
+ entry('getConversation', 'GET', '/projects/{projectId}/conversations/{conversationId}', {
448
+ id: SAMPLE_CONVERSATION_ID,
573
449
  projectId: SAMPLE_PROJECT_ID,
574
- stage: 'proposals',
575
- stagesRemaining: [],
576
- enqueuedAt: '2026-07-28T09:00:00.000Z',
577
- }),
578
- // One frontend proposal (with action/assertion steps) and one backend
579
- // proposal (with endpointPath/captures/consumes) so both wire shapes are
580
- // learnable offline. `credits` shows the charged-actions breakdown the
581
- // real facade fills best-effort.
582
- entry('getPlans', 'GET', '/projects/{projectId}/plans', {
583
- generation: { status: 'idle', errorCode: null, errorMessage: null },
584
- proposals: [
450
+ title: 'Cover the new coupon rules',
451
+ url: SAMPLE_CONVERSATION_URL,
452
+ state: 'proposed',
453
+ model: 'claude-opus-5-5',
454
+ lastSeq: 42,
455
+ events: [
585
456
  {
586
- proposalId: 'prop_1',
587
- title: 'Login happy path',
588
- description: 'Sign in with valid credentials and land on the dashboard.',
589
- priority: 'p1',
590
- category: 'auth',
591
- feature: 'login',
592
- type: 'frontend',
593
- steps: [
594
- { type: 'action', description: 'Enter valid credentials and submit the login form' },
595
- { type: 'assertion', description: 'Dashboard heading is visible' },
596
- ],
457
+ seq: 40,
458
+ at: '2026-01-01T00:11:00.000Z',
459
+ kind: 'activity',
460
+ text: 'Opening staging.example.com/cart',
461
+ },
462
+ {
463
+ seq: 41,
464
+ at: '2026-01-01T00:11:30.000Z',
465
+ kind: 'activity',
466
+ text: 'Saving test cases to TestSprite',
597
467
  },
598
468
  {
599
- proposalId: 'prop_2',
600
- title: 'Create order — success',
601
- description: 'POST a valid order and capture its id for downstream tests.',
602
- priority: 'p2',
603
- category: 'orders',
604
- feature: 'create-order',
605
- type: 'backend',
606
- endpointPath: '/v1/orders',
607
- captures: ['orderId'],
608
- consumes: ['authToken'],
469
+ seq: 42,
470
+ at: '2026-01-01T00:12:00.000Z',
471
+ kind: 'message',
472
+ from: 'agent',
473
+ text: 'Two new tests for the coupon rules and one fix. The second-coupon limit comes from the PRD; whether coupons apply to sale items is only what the app does today.',
609
474
  },
610
475
  ],
611
- credits: {
612
- charged: [
613
- { action: 'strategy', amount: 1 },
614
- { action: 'proposals', amount: 2 },
615
- ],
616
- balance: 147,
476
+ proposal: {
477
+ id: '00000000-0000-4000-8000-0000000000c1',
478
+ kind: 'plan',
479
+ summary: '2 new tests, 1 changed',
480
+ plan: {
481
+ added: [
482
+ {
483
+ ref: '1',
484
+ useCase: 'Checkout',
485
+ title: 'A second percent-off coupon replaces the first',
486
+ priority: 'High',
487
+ description: 'Expected from the PRD (docs/coupons-prd.md): one percent-off coupon per order.',
488
+ steps: [
489
+ { type: 'action', description: 'Add the Desk Lamp to the cart and open the cart' },
490
+ { type: 'action', description: 'Apply SAVE10, then WELCOME15' },
491
+ {
492
+ type: 'assertion',
493
+ description: 'Only WELCOME15 is listed and the total is $35.70',
494
+ },
495
+ ],
496
+ },
497
+ {
498
+ ref: '2',
499
+ useCase: 'Checkout',
500
+ title: 'An expired coupon is refused',
501
+ priority: 'Medium',
502
+ description: 'Expected from what the app does today; not confirmed.',
503
+ steps: [
504
+ { type: 'action', description: 'Apply OLD20 in the cart' },
505
+ {
506
+ type: 'assertion',
507
+ description: 'The message "This code has expired" shows and the total is unchanged',
508
+ },
509
+ ],
510
+ },
511
+ ],
512
+ changed: [{ ref: 'CHK-002', title: 'Pay by card', priority: 'High' }],
513
+ removed: [],
514
+ },
617
515
  },
516
+ reply: 'Two new tests for the coupon rules and one fix. The second-coupon limit comes from the PRD; whether coupons apply to sale items is only what the app does today.',
618
517
  }),
619
- // Input-derived: echoes the explicit id list the CLI always sends (never
620
- // the omitted or empty forms — §3.3 safety rules), so `accept --only
621
- // prop_2 --dry-run` shows acceptedCount: 1 rather than a canned 2.
622
- entry('acceptPlans', 'POST', '/projects/{projectId}/plans/accept', (req) => {
623
- const body = req != null && typeof req === 'object' ? req : {};
624
- const only = Array.isArray(body.only)
625
- ? body.only.filter((id) => typeof id === 'string')
626
- : null;
627
- const ids = only !== null && only.length > 0 ? only : ['prop_1', 'prop_2'];
628
- return {
629
- acceptedCount: ids.length,
630
- caseKeys: ids.map(id => `case_dryrun_${id}`),
631
- };
518
+ entry('conversationFileUrl', 'POST', '/projects/{projectId}/conversations/{conversationId}/files', {
519
+ uploadUrl: 'https://s3.dry-run.invalid/testsprite-usercontent/u_dryrun/chat/change.patch?X-Amz-Signature=dryrun',
520
+ name: 'change.patch',
632
521
  }),
633
- // `project docs upload` two-step facade routes.
634
- // Registered BEFORE the broader project patterns (design doc §7 ordering
635
- // rule; findSample is first-match-wins) and with `/docs/upload-url` before
636
- // `/docs`. NOT consumed by the command's dry-run path: `project docs
637
- // upload --dry-run` is an inline early-exit (zero network, stat only —
638
- // the presigned S3 PUT leg cannot be expressed as a canned fetch sample).
639
- // These are documentation/shape-guards, same family as `deleteBatch`.
640
- entry('docsUploadUrl', 'POST', '/projects/{projectId}/docs/upload-url', {
641
- uploadUrl: 'https://s3.dry-run.invalid/testsprite-usercontent/u_dryrun/p_dryrun_2026/openapi.yaml?X-Amz-Signature=dryrun',
642
- s3Key: 'u_dryrun/p_dryrun_2026/openapi.yaml',
643
- expiresInSeconds: 3600,
522
+ entry('sendConversationMessage', 'POST', '/projects/{projectId}/conversations/{conversationId}/messages', {
523
+ seq: 1,
644
524
  }),
645
- entry('docsRegister', 'POST', '/projects/{projectId}/docs', {
646
- resourceId: 'res_dryrun_2026',
647
- displayName: 'openapi.yaml',
648
- docRole: 'API_DOC',
649
- processStatus: 'Pending',
525
+ entry('applyConversationProposal', 'POST', '/projects/{projectId}/conversations/{conversationId}/apply', {
526
+ applied: '2 new tests, 1 changed',
527
+ ok: true,
528
+ saved: [
529
+ { path: '/test-cases/coupon-replace.md', detail: 'created CHK-011' },
530
+ { path: '/test-cases/coupon-expired.md', detail: 'created CHK-012' },
531
+ { path: '/test-cases/CHK-002.md', detail: 'updated CHK-002' },
532
+ ],
533
+ failed: [],
534
+ tests: ['tc_dryrun_011', 'tc_dryrun_012', 'tc_dryrun_002'],
535
+ }),
536
+ entry('rejectConversationProposal', 'POST', '/projects/{projectId}/conversations/{conversationId}/reject', {
537
+ rejected: '2 new tests, 1 changed',
538
+ }),
539
+ entry('stopConversation', 'POST', '/projects/{projectId}/conversations/{conversationId}/stop', {
540
+ ok: true,
541
+ }),
542
+ entry('discardConversation', 'POST', '/projects/{projectId}/conversations/{conversationId}/discard', {
543
+ discarded: '00000000-0000-4000-8000-0000000000a1',
544
+ released: ['/test-cases/CHK-002.md'],
650
545
  }),
651
546
  // The single-project read carries the project-level test-id attribute list
652
547
  // (present-and-null contract, see `CliProject.testIdAttributes`); the list
653
- // row above deliberately omits it, like `targetUrl`.
548
+ // row above deliberately omits it.
654
549
  entry('getProject', 'GET', '/projects/{projectId}', {
655
550
  ...checkoutProject,
551
+ instruction: 'Use the staging account for checkout tests.',
656
552
  testIdAttributes: ['data-element', 'data-testid'],
657
553
  }),
658
554
  // P6 — POST /projects (create project). The id uses a stable dry-run
@@ -682,216 +578,18 @@ const ENTRIES = [
682
578
  deletedAt: '2026-05-16T00:00:00.000Z',
683
579
  }),
684
580
  entry('listTests', 'GET', '/tests', pageOf(tests)),
685
- entry('getTestCode', 'GET', '/tests/{testId}/code', testCode),
686
- entry('listTestSteps', 'GET', '/tests/{testId}/steps', pageOf(testSteps)),
687
- entry('getTestResult', 'GET', '/tests/{testId}/result', latestResult),
688
581
  // Execution report — static `executions/` prefix, four segments, so no
689
582
  // `/tests/{testId}/…` pattern can shadow it; kept beside the other reads.
690
- entry('getExecutionReport', 'GET', '/tests/executions/{executionId}/report', executionReportSample),
691
- // `/failure/summary` MUST come before `/failure` so the regex matcher
692
- // doesn't shadow it with the bundle endpoint.
693
- entry('getTestFailureSummary', 'GET', '/tests/{testId}/failure/summary', failureSummary),
694
- entry('getTestFailure', 'GET', '/tests/{testId}/failure', failureContext),
695
- // M3.4 piece-5 — GET /tests/{testId}/runs (run-history list).
696
- // **MUST appear BEFORE the `/tests/{testId}` catch-all** so the more
697
- // specific `/runs` suffix wins the regex match. Shows two rows
698
- // (fresh + rerun) so dry-run learners see both `isRerun: false` and
699
- // `isRerun: true` shapes in one fixture.
700
- entry('listTestRuns', 'GET', '/tests/{testId}/runs', {
701
- runs: [
702
- {
703
- // G1b — fresh run with a real targetUrl stamped at trigger time.
704
- runId: SAMPLE_RUN_ID,
705
- status: 'passed',
706
- source: 'cli',
707
- isRerun: false,
708
- createdFrom: null,
709
- createdAt: '2026-06-03T10:00:00.000Z',
710
- startedAt: '2026-06-03T10:00:05.000Z',
711
- finishedAt: '2026-06-03T10:02:00.000Z',
712
- codeVersion: 'v1',
713
- failureKind: null,
714
- targetUrl: SAMPLE_TARGET_URL,
715
- targetUrlSource: 'run',
716
- },
717
- {
718
- // G1b — rerun row where the URL could not be resolved (shows null shape).
719
- runId: 'run_rerun_history_01',
720
- status: 'failed',
721
- source: 'cli',
722
- isRerun: true,
723
- createdFrom: `rerun:${SAMPLE_RUN_ID}`,
724
- createdAt: '2026-06-02T14:30:00.000Z',
725
- startedAt: '2026-06-02T14:30:10.000Z',
726
- finishedAt: '2026-06-02T14:32:45.000Z',
727
- codeVersion: 'v1',
728
- failureKind: 'assertion',
729
- targetUrl: null,
730
- targetUrlSource: 'unresolved',
731
- },
732
- ],
733
- nextCursor: null,
734
- meta: { testKind: 'frontend' },
735
- }),
583
+ entry('getExecutionReport', 'GET', '/tests/executions/{runId}/report', executionReportSample),
736
584
  // `getTest` is the catch-all for `/tests/{id}` — must appear AFTER the
737
585
  // `/tests/{id}/{...}` siblings so the more specific patterns win.
738
586
  entry('getTest', 'GET', '/tests/{testId}', tests[0]),
739
- // M3.3 piece-4 — GET /runs/{runId}/failure (run-scoped artifact bundle).
740
- // Must appear BEFORE the /runs/{runId} catch-all so the more specific
741
- // /failure path wins the regex match.
742
- entry('getRunFailure', 'GET', '/runs/{runId}/failure', failureContext),
743
- // M3.2 piece-5 — POST /tests/batch (FE-only plan-steps batch create).
744
- // **MUST appear before `/tests`** so the more-specific path wins the
745
- // regex match. Input-derived response: one result per supplied spec so
746
- // the caller can verify their JSONL file was parsed as the right count.
747
- // FE specs are echoed as `created`; backend specs (which the live route
748
- // rejects per `runCreateBatch`'s stderr advisory) are echoed as
749
- // `validation_error` so a mixed-batch dry-run doesn't teach a
750
- // false-positive contract (codex-review P2, 2026-05-28).
751
- entry('createTestBatch', 'POST', '/tests/batch', (req) => {
752
- const body = req != null && typeof req === 'object' ? req : {};
753
- const tests = Array.isArray(body.tests) ? body.tests : [];
754
- const count = tests.length;
755
- if (count === 0) {
756
- // No input detected — fall back to the illustrative 3-entry sample
757
- // (2 created + 1 validation_error) so dry-run learners still see
758
- // the mixed-status shape when run without body context.
759
- return {
760
- results: [
761
- { specIndex: 0, testId: 'test_dryrun_batch_0', status: 'created' },
762
- { specIndex: 1, testId: 'test_dryrun_batch_1', status: 'created' },
763
- {
764
- specIndex: 2,
765
- status: 'validation_error',
766
- error: {
767
- code: 'VALIDATION_ERROR',
768
- message: 'planSteps[0].type must be one of: "action", "assertion"',
769
- field: 'planSteps[0].type',
770
- },
771
- },
772
- ],
773
- summary: { total: 3, created: 2, failed: 1 },
774
- };
775
- }
776
- // Mirror runCreateBatch's real behavior — backend specs are rejected
777
- // with `validation_error`, FE specs are created. A mixed-batch dry-run
778
- // that marks BE specs as `created` would teach agents a false-positive
779
- // contract (codex-review P2, 2026-05-28).
780
- const results = tests.map((spec, i) => {
781
- if (spec && typeof spec === 'object' && spec.type === 'backend') {
782
- return {
783
- specIndex: i,
784
- testId: null,
785
- status: 'validation_error',
786
- error: {
787
- code: 'VALIDATION_ERROR',
788
- message: `spec[${i}]: backend specs are not supported on POST /tests/batch — use 'test create --type backend --code-file' instead.`,
789
- field: 'type',
790
- },
791
- };
792
- }
793
- return {
794
- specIndex: i,
795
- testId: `test_dryrun_batch_${i}`,
796
- status: 'created',
797
- };
798
- });
799
- const created = results.filter(r => r.status === 'created').length;
800
- const failed = results.filter(r => r.status === 'validation_error').length;
801
- return {
802
- results,
803
- summary: { total: count, created, failed },
804
- };
805
- }),
806
- // M3.2 piece-2 — POST /tests (code-based create). Input-derived response
807
- // so the `type` field reflects what the caller actually passed (P3-12 fix:
808
- // previously hardcoded to `"frontend"`, hiding BE test dry-run behaviour).
809
- // The `planSteps` echo a real plan-from response would carry is omitted —
810
- // agents see testId/codeVersion/createdAt which is enough to confirm shape.
811
- entry('createTestFromCode', 'POST', '/tests', (req) => {
812
- const body = req != null && typeof req === 'object' ? req : {};
813
- const type = body.type === 'backend' ? 'backend' : 'frontend';
814
- return {
815
- testId: 'test_dryrun_create_2026',
816
- type,
817
- codeVersion: 'v1',
818
- createdAt: '2026-05-13T00:00:00.000Z',
819
- };
820
- }),
821
- // M3.2 piece-6 — PUT /tests/{id}/plan-steps (FE plan replace).
822
- // Input-derived response: `stepCount` reflects the actual number of
823
- // steps the caller supplied so they can verify their file was parsed
824
- // correctly. `planStepsHash` stays canned (sha256 is not worth
825
- // recomputing in dry-run).
826
- entry('putPlanSteps', 'PUT', '/tests/{testId}/plan-steps', (req) => {
827
- const body = req != null && typeof req === 'object' ? req : {};
828
- const planSteps = Array.isArray(body.planSteps) ? body.planSteps : [];
829
- return {
830
- testId: 'test_dryrun_plan_put_2026',
831
- planStepsHash: 'sha256:dryrun-plan-steps-hash',
832
- stepCount: planSteps.length > 0 ? planSteps.length : 3,
833
- updatedAt: '2026-05-14T00:00:00.000Z',
834
- };
835
- }),
836
- // M3.2 piece-4 — PUT /tests/{id}/code (etag-guarded replace). Canned
837
- // response shape per the code-put design spec. The
838
- // `codeVersion` here is the bumped value (v3 → v4) so an agent
839
- // dry-running the chain sees a coherent progression: the sample
840
- // testCode.codeVersion is `v3`, so `put` advances to `v4`.
841
- entry('putTestCode', 'PUT', '/tests/{testId}/code', {
842
- testId: 'test_dryrun_code_put_2026',
843
- codeVersion: 'v4',
844
- updatedAt: '2026-05-13T00:00:00.000Z',
845
- }),
846
- // PUT /tests/{id} (metadata update). Input-derived response: `updatedFields`
847
- // echoes the keys the caller actually passed so an agent can confirm their
848
- // flags landed in the right fields. OpenAPI spec does not define either PATCH
849
- // or PUT for this path; the wire truth is whatever the backend implements
850
- // (currently PUT).
851
- entry('updateTest', 'PUT', '/tests/{testId}', (req) => {
852
- const body = req != null && typeof req === 'object' ? req : {};
853
- const updatedFields = Object.keys(body).filter(k => body[k] !== undefined);
854
- return {
855
- testId: 'test_dryrun_update_2026',
856
- updatedFields: updatedFields.length > 0 ? updatedFields : ['name', 'description'],
857
- updatedAt: '2026-05-13T00:00:00.000Z',
858
- };
859
- }),
860
- // delete-batch (DELETE /tests/<id> × N). The batch sub-command dispatches
861
- // one DELETE /tests/{testId} per test (no batch endpoint) and aggregates
862
- // results into CliBulkDeleteSummary. Under --dry-run the function has an
863
- // inline early-exit (no network calls), so this sample is not consumed by
864
- // the dry-run runner itself. It is registered here as documentation of the
865
- // wire shape for agents learning the surface via `--dry-run --output json`,
866
- // and it participates in the samples.test.ts shape-guard so drift against
867
- // CliBulkDeleteSummary fails the build.
868
- //
869
- // **MUST appear before deleteTest** — `/tests/batch` is a literal path that
870
- // would otherwise match the `/tests/{testId}` wildcard (first-match-wins).
871
- entry('deleteBatch', 'DELETE', '/tests/batch', {
872
- results: [
873
- {
874
- testId: 'test_dryrun_delete_2026',
875
- status: 'deleted',
876
- deletedAt: '2026-05-13T00:00:00.000Z',
877
- },
878
- { testId: 'test_dryrun_skip_2026', status: 'skipped', error: 'not found (already deleted?)' },
879
- ],
880
- summary: { total: 2, deleted: 1, skipped: 1, failed: 0 },
881
- }),
882
- // M3.2 piece-3 — DELETE /tests/{id} (permanent hard-delete). Canned
883
- // response shape per the update/delete design spec.
884
- // `deletedAt` is the delete-time ack (no restore window). Stable
885
- // strings here so a `--dry-run` capture stays diff-able across runs.
886
- entry('deleteTest', 'DELETE', '/tests/{testId}', {
887
- testId: 'test_dryrun_delete_2026',
888
- deletedAt: '2026-05-13T00:00:00.000Z',
889
- }),
890
587
  // M3.3 piece-3 — POST /tests/{testId}/runs (trigger run).
891
588
  // **MUST appear before `/tests` and `/tests/{testId}` generic matchers**
892
589
  // so the more-specific runs path wins. Canned response shape per the
893
590
  // runs-trigger design spec.
894
591
  entry('triggerRun', 'POST', '/tests/{testId}/runs', (req) => ({
592
+ resultId: SAMPLE_RESULT_ID,
895
593
  runId: SAMPLE_RUN_ID,
896
594
  status: 'queued',
897
595
  enqueuedAt: '2026-05-15T19:32:00.000Z',
@@ -899,46 +597,21 @@ const ENTRIES = [
899
597
  targetUrl: SAMPLE_TARGET_URL,
900
598
  ...echoSkipDependencies(req),
901
599
  })),
902
- // M3.4 piece-3 — POST /tests/{testId}/runs/rerun (single rerun).
903
- // **MUST appear before `/tests/{testId}/runs` and `/tests/{testId}`** so the
904
- // more-specific `/runs/rerun` path wins over the generic runs trigger.
905
- // Two shapes are possible (FE / BE). The sample shows a BE shape (with
906
- // closure) so dry-run learners see the richer response; FE callers get the
907
- // same response minus `closure`.
908
- entry('triggerRerun', 'POST', '/tests/{testId}/runs/rerun', {
909
- runId: SAMPLE_RERUN_ID_BE_NAMED,
910
- status: 'queued',
911
- enqueuedAt: '2026-06-03T10:00:00.000Z',
912
- codeVersion: 'v1',
913
- autoHeal: true,
914
- closure: {
915
- members: [
916
- { testId: SAMPLE_TEST_ID_BE_CONSUMER, runId: SAMPLE_RERUN_ID_BE_NAMED, role: 'selected' },
917
- {
918
- testId: SAMPLE_TEST_ID_BE_PRODUCER,
919
- runId: SAMPLE_RERUN_ID_BE_PRODUCER,
920
- role: 'producer',
921
- },
922
- ],
923
- addedProducers: [SAMPLE_TEST_ID_BE_PRODUCER],
924
- addedTeardowns: [],
925
- clearedCaptured: 0,
926
- },
927
- }),
928
600
  // M4 piece-2 — POST /tests/batch/run (fresh wave-ordered batch run).
929
- // **MUST appear before `/tests/batch/rerun` and `/tests/batch` (create)**
930
- // so the more-specific `/batch/run` path wins. Shows `accepted[]` with
931
- // per-test runIds + `skippedFrontend[]` so dry-run learners see both shapes.
601
+ // Shows `accepted[]` with per-test runIds + `skippedFrontend[]` so dry-run
602
+ // learners see both shapes.
932
603
  entry('triggerBatchRunFresh', 'POST', '/tests/batch/run', (req) => ({
933
604
  accepted: [
934
605
  {
606
+ runId: SAMPLE_RUN_ID,
935
607
  testId: SAMPLE_TEST_ID_FRESH_1,
936
- runId: SAMPLE_BATCH_FRESH_RUN_ID_1,
608
+ resultId: SAMPLE_BATCH_FRESH_RESULT_ID_1,
937
609
  enqueuedAt: '2026-06-09T10:00:00.000Z',
938
610
  },
939
611
  {
612
+ runId: SAMPLE_RUN_ID,
940
613
  testId: SAMPLE_TEST_ID_FRESH_2,
941
- runId: SAMPLE_BATCH_FRESH_RUN_ID_2,
614
+ resultId: SAMPLE_BATCH_FRESH_RESULT_ID_2,
942
615
  enqueuedAt: '2026-06-09T10:00:00.000Z',
943
616
  },
944
617
  ],
@@ -948,44 +621,31 @@ const ENTRIES = [
948
621
  skippedIntegration: [],
949
622
  ...echoSkipDependencies(req),
950
623
  })),
951
- // M3.4 piece-3 — POST /tests/batch/rerun (batch rerun).
952
- // **MUST appear before `/tests/batch` (create)** so the more-specific
953
- // `/batch/rerun` path wins. Shows `accepted[]` with per-test runIds (C2)
954
- // plus a `deferred[]` example (C1) so dry-run learners see both shapes.
955
- entry('triggerBatchRerun', 'POST', '/tests/batch/rerun', {
956
- accepted: [
957
- {
958
- testId: SAMPLE_TEST_ID_BATCH_1,
959
- runId: SAMPLE_RERUN_BATCH_ID_1,
960
- enqueuedAt: '2026-06-03T10:00:00.000Z',
961
- },
962
- {
963
- testId: SAMPLE_TEST_ID_BATCH_2,
964
- runId: SAMPLE_RERUN_BATCH_ID_2,
965
- enqueuedAt: '2026-06-03T10:00:00.000Z',
624
+ // One entry answers `?run=` and `?test=`; only a test's history carries the
625
+ // plan's history window.
626
+ entry('listResults', 'GET', '/results', (_req, query) => query?.has('run')
627
+ ? {
628
+ run: {
629
+ runId: query.get('run'),
630
+ projectId: SAMPLE_PROJECT_ID,
631
+ status: 'finished',
632
+ cancelled: false,
633
+ created: '2026-11-15T00:00:00Z',
634
+ modified: '2026-11-15T00:00:00Z',
635
+ targetUrl: SAMPLE_TARGET_URL,
636
+ dashboardUrl: null,
966
637
  },
967
- ],
968
- deferred: [{ testId: SAMPLE_TEST_ID_DEFERRED, reason: 'rate_limited' }],
969
- conflicts: [],
970
- closure: {
971
- byProject: [
972
- {
973
- projectId: SAMPLE_PROJECT_ID_BACKEND,
974
- testIds: [SAMPLE_TEST_ID_BATCH_2],
975
- addedProducers: [],
976
- addedTeardowns: [],
977
- clearedCaptured: 0,
978
- },
979
- ],
980
- },
981
- }),
638
+ results: resultListSample.results,
639
+ }
640
+ : resultListSample),
641
+ entry('getResult', 'GET', '/results/{resultId}', resultDetailSample),
982
642
  // M3.3 piece-3 — GET /runs/{runId} (live status / long-poll).
983
643
  // A terminal `passed` row is the most useful dry-run shape: agents see
984
644
  // what a completed run looks like, and `--wait` terminates immediately.
985
645
  // fix(2026-05-21): a duplicate failed-shape entry that appeared before
986
646
  // this entry was removed; findSample first-match-wins was always
987
- // returning status: "failed" for `test wait --dry-run`.
988
- entry('getRun', 'GET', `/runs/${SAMPLE_FAILED_RUN_ID}`, failedRunSample),
647
+ // returning status: "failed" for `run wait --dry-run`.
648
+ entry('getRun', 'GET', `/runs/${SAMPLE_FAILED_RESULT_ID}`, failedRunSample),
989
649
  entry('getRun', 'GET', '/runs/{runId}', passedRunSample),
990
650
  // POST /runs/{runId}/cancel. Method-guarded in
991
651
  // `findSample` (POST vs `getRun`'s GET), so this can't be shadowed by the
@@ -994,34 +654,19 @@ const ENTRIES = [
994
654
  // for a dry-run learner than the idempotent no-op.
995
655
  entry('cancelRun', 'POST', '/runs/{runId}/cancel', {
996
656
  runId: SAMPLE_RUN_ID,
997
- testId: SAMPLE_TEST_ID_PASSED,
998
- projectId: SAMPLE_PROJECT_ID,
999
- userId: SAMPLE_USER_ID,
1000
- status: 'cancelled',
1001
- source: 'cli',
1002
- createdAt: '2026-05-15T19:32:00.000Z',
1003
- startedAt: '2026-05-15T19:32:05.000Z',
1004
- finishedAt: '2026-05-15T19:33:12.000Z',
1005
- codeVersion: 'v1',
1006
- targetUrl: SAMPLE_TARGET_URL,
1007
- createdFrom: null,
1008
- failedStepIndex: null,
1009
- failureKind: null,
1010
- error: null,
1011
- videoUrl: null,
1012
- stepSummary: {
1013
- total: 8,
1014
- completed: 3,
1015
- passedCount: 3,
1016
- failedCount: 0,
1017
- },
1018
657
  alreadyCancelled: false,
1019
- }),
1020
- // Schedules. The `/schedules/{id}/runs` entry MUST come before the
1021
- // `/schedules/{id}` entries so the more specific path wins the regex match
1022
- // (first-match-wins).
1023
- entry('listScheduleRuns', 'GET', '/schedules/{scheduleId}/runs', {
1024
- runs: [scheduleRun],
658
+ alreadyFinished: false,
659
+ results: [
660
+ {
661
+ resultId: SAMPLE_RESULT_ID,
662
+ runId: SAMPLE_RUN_ID,
663
+ testId: SAMPLE_TEST_ID_PASSED,
664
+ title: 'Sample test',
665
+ status: 'cancelled',
666
+ alreadyCancelled: false,
667
+ alreadyFinished: false,
668
+ },
669
+ ],
1025
670
  }),
1026
671
  entry('listSchedules', 'GET', '/schedules', { schedules: [schedule] }),
1027
672
  // `schedule create --dry-run` exits before the HTTP client is built, so this
@@ -1033,12 +678,27 @@ const ENTRIES = [
1033
678
  // reached the body, rather than showing an unrelated canned schedule.
1034
679
  entry('updateSchedule', 'PATCH', '/schedules/{scheduleId}', (req) => {
1035
680
  const patch = req != null && typeof req === 'object' ? req : {};
681
+ const parseIso = (val) => {
682
+ if (val === null)
683
+ return null;
684
+ if (typeof val !== 'string')
685
+ return undefined;
686
+ const d = new Date(val);
687
+ return Number.isNaN(d.getTime()) ? val : d.toISOString();
688
+ };
689
+ const startAt = parseIso(patch.startAt);
690
+ const endAt = parseIso(patch.endAt);
1036
691
  return {
1037
692
  ...schedule,
1038
693
  ...(typeof patch.name === 'string' ? { name: patch.name } : {}),
694
+ ...(typeof patch.environment === 'string'
695
+ ? { environment: patch.environment, environmentMode: 'pinned' }
696
+ : {}),
1039
697
  ...(typeof patch.enabled === 'boolean' ? { enabled: patch.enabled } : {}),
1040
698
  ...(typeof patch.cron === 'string' ? { cron: patch.cron } : {}),
1041
699
  ...(typeof patch.timezone === 'string' ? { timezone: patch.timezone } : {}),
700
+ ...(startAt !== undefined ? { startAt } : {}),
701
+ ...(endAt !== undefined ? { endAt } : {}),
1042
702
  ...(typeof patch.sendTo === 'string' ? { sendTo: patch.sendTo } : {}),
1043
703
  updatedAt: '2026-05-16T00:00:00.000Z',
1044
704
  };
@@ -1093,43 +753,6 @@ function pageOf(items) {
1093
753
  // fetch impl and return a synthetic next-page on the second call.
1094
754
  return { items, nextToken: null };
1095
755
  }
1096
- /**
1097
- * Resolve a fetch URL to its canned sample. Matches against the path
1098
- * portion only (query string is ignored — auto-pagination's `cursor`
1099
- * query is intentionally a no-op in M2 dry-run; see {@link pageOf}).
1100
- *
1101
- * Returns `undefined` when no pattern matches; the caller (the dry-run
1102
- * fetch impl) surfaces this as a 500 INTERNAL envelope so a missing
1103
- * sample is loud, not silent.
1104
- *
1105
- * `requestBody` is forwarded to input-derived entries (`updateTest`,
1106
- * `putPlanSteps`, `createTestBatch`) so their responses reflect the
1107
- * user's actual flags rather than static canned values.
1108
- */
1109
- /**
1110
- * Like {@link findSample}, but a missing sample throws instead of returning
1111
- * `undefined`. For dry-run paths that resolve samples DIRECTLY (bypassing the
1112
- * dry-run fetch impl, which has its own loud INTERNAL envelope for this):
1113
- * without the throw, a lost registry entry surfaces as a raw TypeError deep
1114
- * in a renderer (`samples.ts` is a real merge-conflict
1115
- * hotspot, so a silently dropped entry is a live hazard, not a hypothetical).
1116
- */
1117
- export function findSampleOrThrow(method, url, requestBody) {
1118
- const entry = findSample(method, url, requestBody);
1119
- if (entry === undefined) {
1120
- throw ApiError.fromEnvelope({
1121
- error: {
1122
- code: 'INTERNAL',
1123
- message: `dry-run sample registry has no entry for ${method.toUpperCase()} ${extractPath(url)} — ` +
1124
- 'a sample was removed or shadowed in src/lib/dry-run/samples.ts (internal CLI bug).',
1125
- nextAction: 'Please report this to support@testsprite.com.',
1126
- requestId: SAMPLE_DRY_RUN_REQUEST_ID,
1127
- details: { method: method.toUpperCase(), path: extractPath(url) },
1128
- },
1129
- });
1130
- }
1131
- return entry;
1132
- }
1133
756
  export function findSample(method, url, requestBody) {
1134
757
  const upper = method.toUpperCase();
1135
758
  const pathOnly = extractPath(url);
@@ -1137,11 +760,16 @@ export function findSample(method, url, requestBody) {
1137
760
  if (e.method === upper && e.pattern.test(pathOnly)) {
1138
761
  // Rebind body so downstream code can call `e.body` as before while
1139
762
  // still preserving the original lazy factory semantics.
1140
- return { ...e, body: () => e.body(requestBody) };
763
+ return { ...e, body: () => e.body(requestBody, queryOf(url)) };
1141
764
  }
1142
765
  }
1143
766
  return undefined;
1144
767
  }
768
+ /** The query of `url`, absolute or not. */
769
+ function queryOf(url) {
770
+ const queryIdx = url.indexOf('?');
771
+ return new URLSearchParams(queryIdx >= 0 ? url.slice(queryIdx + 1) : '');
772
+ }
1145
773
  function extractPath(url) {
1146
774
  // Strip protocol+host, then strip the `/api/cli/v1` facade prefix.
1147
775
  let path = url;