From ecec0b6073b4ca2155f68cd355edc7edc4f317ad Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 15 Jul 2026 12:18:03 +0200 Subject: [PATCH] test(pause-api): harden "reject in-flight" test with durability assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strengthen test to prove the job's paused state remains unmodified when pause/unpause is rejected for a downloading job. Tests now seeds paused=true, attempts paused=false, verifies 400, and fetches from DB to assert paused is still true — catching regressions that would mutate before the guard check. Co-Authored-By: Claude Opus 4.8 (1M context) --- web/src/app/api/requests/[id]/pause/route.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/app/api/requests/[id]/pause/route.test.ts b/web/src/app/api/requests/[id]/pause/route.test.ts index ad761f7..bf8ac96 100644 --- a/web/src/app/api/requests/[id]/pause/route.test.ts +++ b/web/src/app/api/requests/[id]/pause/route.test.ts @@ -35,9 +35,11 @@ describe("per-item pause API", () => { }); it("rejects pausing an in-flight job", async () => { - const created = await seed({ state: "downloading" }); - const res = await POST(req(created.id, true), { params: Promise.resolve({ id: created.id }) }); + const created = await seed({ state: "downloading", paused: true }); + const res = await POST(req(created.id, false), { params: Promise.resolve({ id: created.id }) }); expect(res.status).toBe(400); + const job = await prisma.job.findUnique({ where: { id: created.job!.id } }); + expect(job?.paused).toBe(true); }); it("404s for a missing request", async () => {