test(routes): expand aktivitaeten page coverage
loadError branches (FuerDichBox skipped vs shown), first-run vs filter-empty empty-state variants, timeline rendering when feed has items, FilterPills + FuerDichBox conditional render. 7 tests covering ~12 branches in the page file. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,17 +63,87 @@ describe('aktivitaeten page', () => {
|
|||||||
// ChronikErrorCard renders some retry mechanism
|
// ChronikErrorCard renders some retry mechanism
|
||||||
const main = document.querySelector('main');
|
const main = document.querySelector('main');
|
||||||
expect(main).not.toBeNull();
|
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() } });
|
render(AktivitaetenPage, { props: { data: baseData() } });
|
||||||
|
|
||||||
const main = document.querySelector('main');
|
// FuerDichBox shows the inbox-zero state when no unread
|
||||||
expect(main).not.toBeNull();
|
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 () => {
|
it('renders the first-run empty state when activityFeed is empty', async () => {
|
||||||
render(AktivitaetenPage, { props: { data: baseData({ filter: 'mentions' as const }) } });
|
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');
|
const main = document.querySelector('main');
|
||||||
expect(main).not.toBeNull();
|
expect(main).not.toBeNull();
|
||||||
|
|||||||
Reference in New Issue
Block a user