test(routes): convert 3 .not.toThrow in home page to main/h1 assertions

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-11 17:48:34 +02:00
committed by marcel
parent d4ae74d9a5
commit fec2b2ccbd

View File

@@ -169,7 +169,7 @@ describe('home page (/)', () => {
expect(document.querySelector('main')).not.toBeNull(); expect(document.querySelector('main')).not.toBeNull();
}); });
it('renders without throwing when data props are undefined (uses ?? fallbacks)', async () => { it('renders the main region when data props are minimal (uses ?? fallbacks)', async () => {
const minimalData = { const minimalData = {
isReader: false, isReader: false,
user: { firstName: 'Anna' }, user: { firstName: 'Anna' },
@@ -177,17 +177,22 @@ describe('home page (/)', () => {
canBlogWrite: false canBlogWrite: false
}; };
expect(() => render(HomePage, { props: { data: minimalData } })).not.toThrow(); render(HomePage, { props: { data: minimalData } });
expect(document.querySelector('main')).not.toBeNull();
expect(document.querySelector('h1')).not.toBeNull();
}); });
it('renders without throwing when reader data has all undefined fields', async () => { it('renders the reader dashboard main region with only required reader fields', async () => {
const readerData = { const readerData = {
isReader: true, isReader: true,
user: { firstName: 'Anna' }, user: { firstName: 'Anna' },
canBlogWrite: false canBlogWrite: false
}; };
expect(() => render(HomePage, { props: { data: readerData } })).not.toThrow(); render(HomePage, { props: { data: readerData } });
expect(document.querySelector('main')).not.toBeNull();
}); });
it('renders without throwing when isReader and canBlogWrite are both true (drafts module)', async () => { it('renders without throwing when isReader and canBlogWrite are both true (drafts module)', async () => {
@@ -213,19 +218,19 @@ describe('home page (/)', () => {
expect(main).not.toBeNull(); expect(main).not.toBeNull();
}); });
it('renders writer dashboard without throwing with weeklyStats + pulse populated', async () => { it('renders the writer dashboard main region with weeklyStats + pulse populated', async () => {
// Stub-shaped objects that satisfy whichever child components expect them render(HomePage, {
expect(() => props: {
render(HomePage, { data: baseData({
props: { isReader: false,
data: baseData({ user: { firstName: 'Anna' },
isReader: false, canWrite: true,
user: { firstName: 'Anna' }, incompleteTotal: 25
canWrite: true, })
incompleteTotal: 25 }
}) });
}
}) expect(document.querySelector('main')).not.toBeNull();
).not.toThrow(); expect(document.querySelector('h1')).not.toBeNull();
}); });
}); });