test(coverage): drive browser tests to 80% on all metrics (#496) #505

Merged
marcel merged 189 commits from feat/issue-496-browser-coverage-tests into main 2026-05-11 21:50:39 +02:00
Showing only changes of commit a5a8674fd0 - Show all commits

View File

@@ -112,4 +112,95 @@ describe('documents/+ page', () => {
.element(page.getByRole('button', { name: /alle .* editieren/i }))
.not.toBeInTheDocument();
});
it('hides the bulk-edit-all and new-doc CTAs when canWrite is false', async () => {
render(DocumentsListPage, {
props: { data: baseData({ canWrite: false, totalElements: 12 }) }
});
await expect
.element(page.getByRole('link', { name: /neues dokument/i }))
.not.toBeInTheDocument();
await expect.element(page.getByRole('button', { name: /alle 12/i })).not.toBeInTheDocument();
});
it('displays the no-results state when items is empty (via DocumentList)', async () => {
render(DocumentsListPage, { props: { data: baseData({ items: [], totalElements: 0 }) } });
// DocumentList renders the empty placeholder
expect(document.body.textContent).toMatch(/keine|noch|empty/i);
});
it('renders the document list when items are present', async () => {
render(DocumentsListPage, {
props: {
data: baseData({
items: [
{
document: {
id: 'd1',
title: 'Brief 1899',
status: 'TRANSCRIBED',
documentDate: '1899-04-14',
summary: '',
originalFilename: 'b1.pdf',
receivers: []
},
matchData: {
titleOffsets: [],
senderMatched: false,
matchedReceiverIds: [],
matchedTagIds: [],
snippetOffsets: [],
summaryOffsets: []
},
completionPercentage: 80,
contributors: []
}
],
totalElements: 1
})
}
});
expect(document.body.textContent).toContain('Brief 1899');
});
it('preselects the search input from data.q', async () => {
render(DocumentsListPage, { props: { data: baseData({ q: 'kurrent' }) } });
const input = document.querySelector('input[type="text"]') as HTMLInputElement;
expect(input?.value).toBe('kurrent');
});
it('renders without throwing when from/to date filters are preselected', async () => {
expect(() =>
render(DocumentsListPage, {
props: { data: baseData({ from: '1899-01-01', to: '1950-12-31' }) }
})
).not.toThrow();
});
it('renders without throwing when tag filters are preselected', async () => {
expect(() =>
render(DocumentsListPage, {
props: { data: baseData({ tags: ['Kurrent', 'Familie'] }) }
})
).not.toThrow();
});
it('renders without throwing when sender/receiver filters are set', async () => {
expect(() =>
render(DocumentsListPage, {
props: {
data: baseData({
senderId: 'p-1',
initialSenderName: 'Anna Schmidt',
receiverId: 'p-2',
initialReceiverName: 'Bert Meier'
})
}
})
).not.toThrow();
});
});