test(enrich): smoke-cover the enrich document page
Mounts the page, renders the orchestrator, exposes the hidden skip-form, and renders the three submit-action buttons (skip, save, save+review). 4 tests covering the orchestration entry path of enrich/[id]. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
58
frontend/src/routes/enrich/[id]/page.svelte.test.ts
Normal file
58
frontend/src/routes/enrich/[id]/page.svelte.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { cleanup, render } from 'vitest-browser-svelte';
|
||||
import EnrichDocumentPage from './+page.svelte';
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
const baseDoc = {
|
||||
id: 'd1',
|
||||
title: 'Brief an Helene',
|
||||
originalFilename: 'brief.pdf',
|
||||
documentDate: '1923-04-15',
|
||||
sender: null,
|
||||
receivers: [],
|
||||
tags: [],
|
||||
filePath: null,
|
||||
contentType: null,
|
||||
location: null,
|
||||
status: 'UPLOADED',
|
||||
fileHash: null
|
||||
};
|
||||
|
||||
const baseData = (overrides: Record<string, unknown> = {}) => ({
|
||||
document: baseDoc,
|
||||
incompleteCount: 5,
|
||||
...overrides
|
||||
});
|
||||
|
||||
describe('enrich/[id] page', () => {
|
||||
it('renders the page with the DocumentEditLayout orchestrator', async () => {
|
||||
render(EnrichDocumentPage, { props: { data: baseData(), form: undefined } });
|
||||
|
||||
const main = document.body.firstElementChild;
|
||||
expect(main).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders the form-error banner via DocumentEditLayout when form.error is set', async () => {
|
||||
render(EnrichDocumentPage, {
|
||||
props: { data: baseData(), form: { error: 'Invalid input' } }
|
||||
});
|
||||
|
||||
const main = document.body.firstElementChild;
|
||||
expect(main).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders a hidden skip-form for the skip action', async () => {
|
||||
render(EnrichDocumentPage, { props: { data: baseData(), form: undefined } });
|
||||
|
||||
const skipForm = document.querySelector('form#skip-form');
|
||||
expect(skipForm).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders three submit-action buttons (skip, save, save&review)', async () => {
|
||||
render(EnrichDocumentPage, { props: { data: baseData(), form: undefined } });
|
||||
|
||||
const submits = document.querySelectorAll('button[type="submit"]');
|
||||
expect(submits.length).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user