feat(admin): add OCR admin routes — overview, global history, sender detail
Some checks failed
CI / Backend Unit Tests (push) Failing after 2m45s
CI / Unit & Component Tests (pull_request) Failing after 2m32s
CI / OCR Service Tests (pull_request) Successful in 27s
CI / Backend Unit Tests (pull_request) Failing after 2m44s
CI / Unit & Component Tests (push) Failing after 2m35s
CI / OCR Service Tests (push) Successful in 30s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-18 01:05:08 +02:00
parent 0d8ac46639
commit 8acb830649
9 changed files with 241 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { load } from './+page.server';
const mockApi = { GET: vi.fn() };
vi.mock('$lib/api.server', () => ({ createApiClient: () => mockApi }));
beforeEach(() => vi.clearAllMocks());
describe('admin/ocr/[personId] — load', () => {
it('returns sender history from API', async () => {
const personId = '123e4567-e89b-12d3-a456-426614174000';
mockApi.GET.mockResolvedValue({
response: { ok: true },
data: { runs: [], personNames: { [personId]: 'Anna Müller' } }
});
const result = (await load({ params: { personId }, fetch } as never))!;
expect(result.history.personNames?.[personId]).toBe('Anna Müller');
});
it('throws 404 when person not found', async () => {
mockApi.GET.mockResolvedValue({
response: { ok: false, status: 404 },
error: { code: 'PERSON_NOT_FOUND' }
});
await expect(
load({ params: { personId: 'unknown-id' }, fetch } as never)
).rejects.toMatchObject({ status: 404 });
});
});