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 d51552ed11 - Show all commits

View File

@@ -63,17 +63,87 @@ describe('aktivitaeten page', () => {
// ChronikErrorCard renders some retry mechanism
const main = document.querySelector('main');
expect(main).not.toBeNull();
// FuerDichBox should NOT render when loadError is set
const fuerDich = document.querySelector('[data-testid="chronik-inbox-zero"]');
expect(fuerDich).toBeNull();
});
it('renders the empty state when activityFeed is empty', async () => {
it('renders the FuerDichBox and FilterPills when loadError is null', async () => {
render(AktivitaetenPage, { props: { data: baseData() } });
const main = document.querySelector('main');
expect(main).not.toBeNull();
// FuerDichBox shows the inbox-zero state when no unread
const fuerDich = document.querySelector('[data-testid="chronik-inbox-zero"]');
expect(fuerDich).not.toBeNull();
// FilterPills present
const radiogroup = document.querySelector('[role="radiogroup"]');
expect(radiogroup).not.toBeNull();
});
it('renders without crashing when filter is set to non-default value', async () => {
render(AktivitaetenPage, { props: { data: baseData({ filter: 'mentions' as const }) } });
it('renders the first-run empty state when activityFeed is empty', async () => {
render(AktivitaetenPage, { props: { data: baseData() } });
const empty = document.querySelector('[data-testid="chronik-empty-state"]');
expect(empty?.getAttribute('data-variant')).toBe('first-run');
});
it('renders the filter-empty empty state when feed has items but filter rules out all', async () => {
render(AktivitaetenPage, {
props: {
data: baseData({
filter: 'fuer-dich' as const,
activityFeed: [
{
kind: 'TEXT_SAVED',
documentId: 'doc-1',
documentTitle: 'Brief',
actor: { id: 'u1', name: 'Anna', initials: 'AS', color: '#000' },
count: 1,
happenedAt: '2026-01-01T00:00:00Z',
happenedAtUntil: null,
youMentioned: false
}
]
})
}
});
const empty = document.querySelector('[data-testid="chronik-empty-state"]');
expect(empty?.getAttribute('data-variant')).toBe('filter-empty');
});
it('renders the timeline when displayFeed is non-empty', async () => {
render(AktivitaetenPage, {
props: {
data: baseData({
filter: 'alle' as const,
activityFeed: [
{
kind: 'TEXT_SAVED',
documentId: 'doc-1',
documentTitle: 'Brief 1899',
actor: { id: 'u1', name: 'Anna', initials: 'AS', color: '#000' },
count: 1,
happenedAt: '2026-01-01T00:00:00Z',
happenedAtUntil: null,
youMentioned: false
}
]
})
}
});
// Timeline renders the document title from the feed item
expect(document.body.textContent).toContain('Brief 1899');
// No empty-state in this case
const empty = document.querySelector('[data-testid="chronik-empty-state"]');
expect(empty).toBeNull();
});
it('renders without crashing when filter is set to a non-default value', async () => {
render(AktivitaetenPage, {
props: { data: baseData({ filter: 'transkription' as const }) }
});
const main = document.querySelector('main');
expect(main).not.toBeNull();