From 3e72157ee16cad355d430cf2eb9d7357dc74bc85 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 19 May 2026 20:43:21 +0200 Subject: [PATCH] test(transcription): update markAllReviewed non-OK test to expect throw The function now throws instead of silently returning on failure. Update the test name and assertion to match the new behaviour, and verify blocks remain unchanged after the error. Co-Authored-By: Claude Sonnet 4.6 --- .../transcription/useTranscriptionBlocks.svelte.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/document/transcription/useTranscriptionBlocks.svelte.test.ts b/frontend/src/lib/document/transcription/useTranscriptionBlocks.svelte.test.ts index a7670791..dd837f48 100644 --- a/frontend/src/lib/document/transcription/useTranscriptionBlocks.svelte.test.ts +++ b/frontend/src/lib/document/transcription/useTranscriptionBlocks.svelte.test.ts @@ -259,12 +259,15 @@ describe('createTranscriptionBlocks.markAllReviewed', () => { expect(ctrl.blocks.every((b) => b.reviewed)).toBe(true); }); - it('is a no-op when PUT returns non-OK', async () => { + it('throws and leaves blocks unchanged when PUT returns non-OK', async () => { const fetchImpl = vi.fn(async (url: RequestInfo | URL, init?: RequestInit) => { const u = url.toString(); const method = init?.method ?? 'GET'; if (u.includes('/review-all') && method === 'PUT') { - return new Response('', { status: 500 }); + return new Response(JSON.stringify({ code: 'INTERNAL_ERROR' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); } return new Response(JSON.stringify([baseBlock({ id: 'b-1', reviewed: false })]), { status: 200, @@ -274,7 +277,7 @@ describe('createTranscriptionBlocks.markAllReviewed', () => { const ctrl = createTranscriptionBlocks({ documentId: () => 'doc-1', fetchImpl }); await ctrl.load(); - await ctrl.markAllReviewed(); + await expect(ctrl.markAllReviewed()).rejects.toThrow('INTERNAL_ERROR'); expect(ctrl.blocks[0].reviewed).toBe(false); }); });