Skip to content

Commit c096dd2

Browse files
fix(e2e): pause-resume mock used item, real contract is resource (#93)
The pause-resume.spec.ts route mock returned `{ok, item}`, but the agent API's POST /resources/:id/pause|resume responds `{ok, id, token, status, message, resource}` and api.pauseResource() reads `r.resource`. With the wrong key adaptResource(undefined) threw, confirm()'s catch fired, and the modal never closed — failing "Pause → confirm → Resume label flips" on every run (incl. both retries). Mock now returns `resource`, matching the backend handler (resource.go Pause/Resume) and api/index.ts. Full chromium suite: 23 passed. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7ff4875 commit c096dd2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

e2e/pause-resume.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ test.describe('Pause + Resume', () => {
2222
// Mock POST /api/v1/resources/:id/pause to return the resource flipped
2323
// to 'paused'. After the click the page should re-read this state and
2424
// re-render the button label.
25+
//
26+
// The body key MUST be `resource` — that is the real contract: the
27+
// backend Pause/Resume handler responds `{ok, id, token, status,
28+
// message, resource}` and api.pauseResource() reads `r.resource`.
29+
// A stale `item` key here makes adaptResource(undefined) throw, the
30+
// confirm() catch fires, and the modal never closes.
2531
await page.route(`**/api/v1/resources/${r.token}/pause`, (route) => {
2632
if (route.request().method() !== 'POST') return route.continue()
2733
return route.fulfill({
2834
status: 200,
2935
contentType: 'application/json',
3036
body: JSON.stringify({
3137
ok: true,
32-
item: { ...r, status: 'paused' },
38+
resource: { ...r, status: 'paused' },
3339
}),
3440
})
3541
})
@@ -41,7 +47,7 @@ test.describe('Pause + Resume', () => {
4147
contentType: 'application/json',
4248
body: JSON.stringify({
4349
ok: true,
44-
item: { ...r, status: 'active' },
50+
resource: { ...r, status: 'active' },
4551
}),
4652
})
4753
})

0 commit comments

Comments
 (0)