users/[id]: full-name derivation across all four branches (both/firstName-only/lastName-only/email fallback), avatar initials matrix, email/contact row visibility tied to data presence. admin/ocr/global: heading + back link, runs prop pass-through, defensive default for missing history fields. geschichten/[id]: title rendering, author full-name vs email fallback vs null, publishedAt suffix conditional, persons and documents sections gated on array length, edit/delete actions gated on canBlogWrite. Mocks the confirm service since it requires a ConfirmDialog mounted in layout. 26 tests across three files. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { describe, it, expect, afterEach } from 'vitest';
|
|
import { cleanup, render } from 'vitest-browser-svelte';
|
|
import { page } from 'vitest/browser';
|
|
import OcrGlobalPage from './+page.svelte';
|
|
|
|
afterEach(cleanup);
|
|
|
|
describe('admin/ocr/global page', () => {
|
|
it('renders the heading and back link to /admin/ocr', async () => {
|
|
render(OcrGlobalPage, {
|
|
props: { data: { history: { runs: [], personNames: {} } } }
|
|
});
|
|
|
|
await expect.element(page.getByRole('heading', { name: /globaler verlauf/i })).toBeVisible();
|
|
await expect
|
|
.element(page.getByRole('link', { name: /ocr/i }))
|
|
.toHaveAttribute('href', '/admin/ocr');
|
|
});
|
|
|
|
it('passes the runs array through to TrainingHistory', async () => {
|
|
render(OcrGlobalPage, {
|
|
props: {
|
|
data: { history: { runs: [], personNames: { 'p-1': 'Anna Schmidt' } } }
|
|
}
|
|
});
|
|
|
|
await expect.element(page.getByRole('heading', { name: /globaler verlauf/i })).toBeVisible();
|
|
});
|
|
|
|
it('handles a missing history.runs by defaulting to an empty list', async () => {
|
|
render(OcrGlobalPage, {
|
|
props: { data: { history: { runs: undefined, personNames: undefined } } }
|
|
});
|
|
|
|
await expect.element(page.getByRole('heading', { name: /globaler verlauf/i })).toBeVisible();
|
|
});
|
|
});
|