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

View File

@@ -138,4 +138,89 @@ describe('geschichten/+ page', () => {
.element(page.getByRole('heading', { level: 2, name: /reise nach berlin/i }))
.toBeVisible();
});
it('authorName falls back to email when first/last names are missing', async () => {
render(GeschichtenListPage, {
props: {
data: baseData({
geschichten: [
{
id: 'g1',
title: 'Anonym',
author: { email: 'anon@example.com' }
}
]
})
}
});
expect(document.body.textContent).toContain('anon@example.com');
});
it('authorName renders empty when author is undefined', async () => {
render(GeschichtenListPage, {
props: {
data: baseData({
geschichten: [{ id: 'g1', title: 'No Author' }]
})
}
});
// Page renders the title fine, no author string
expect(document.body.textContent).toContain('No Author');
});
it('omits the date when publishedAt is missing', async () => {
render(GeschichtenListPage, {
props: {
data: baseData({
geschichten: [
{
id: 'g1',
title: 'Draft',
author: { firstName: 'Anna', lastName: 'Schmidt', email: 'a@x' }
}
]
})
}
});
// No "·" separator before date when no publishedAt
const titleHeading = document.querySelector('h2');
const card = titleHeading?.closest('li');
// The middle paragraph (author line) should not contain "·"
expect(card?.textContent).toContain('Anna Schmidt');
});
it('omits the body excerpt when body is empty', async () => {
render(GeschichtenListPage, {
props: {
data: baseData({
geschichten: [
{
id: 'g1',
title: 'No Body',
body: '',
author: { firstName: 'Anna', lastName: 'Schmidt', email: 'a@x' }
}
]
})
}
});
const titleHeading = document.querySelector('h2');
expect(titleHeading?.textContent).toContain('No Body');
});
it('renders without throwing when one person filter is selected', async () => {
expect(() =>
render(GeschichtenListPage, {
props: {
data: baseData({
personFilters: [{ id: 'p1', displayName: 'Anna' }]
})
}
})
).not.toThrow();
});
});