test(admin): expand admin/invites page coverage
Status color paths (exhausted/expired/revoked), new-invite form toggle, loadError banner. 5 new tests covering ~10 branches. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -198,4 +198,59 @@ describe('admin/invites page', () => {
|
||||
|
||||
await expect.element(page.getByText('Kein Ablauf')).toBeVisible();
|
||||
});
|
||||
|
||||
it('renders the exhausted status with the correct color class', async () => {
|
||||
render(AdminInvitesPage, {
|
||||
props: { data: baseData({ invites: [makeInvite({ status: 'exhausted' })] }) }
|
||||
});
|
||||
|
||||
// gray color for exhausted
|
||||
const pill = Array.from(document.querySelectorAll('.bg-gray-100'));
|
||||
expect(pill.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('renders the expired status with the correct color class', async () => {
|
||||
render(AdminInvitesPage, {
|
||||
props: { data: baseData({ invites: [makeInvite({ status: 'expired' })] }) }
|
||||
});
|
||||
|
||||
// amber color for expired
|
||||
const pill = Array.from(document.querySelectorAll('.bg-amber-50'));
|
||||
expect(pill.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('renders the revoked status with the correct color class', async () => {
|
||||
render(AdminInvitesPage, {
|
||||
props: { data: baseData({ invites: [makeInvite({ status: 'revoked' })] }) }
|
||||
});
|
||||
|
||||
const pill = Array.from(document.querySelectorAll('.bg-red-50'));
|
||||
// May have other red elements (like loadError) — at least one
|
||||
expect(pill.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('toggles the new-invite form when the button is clicked', async () => {
|
||||
render(AdminInvitesPage, { props: { data: baseData(), form: undefined } });
|
||||
|
||||
const formBefore = document.querySelector('form[action="?/create"]');
|
||||
expect(formBefore).toBeNull();
|
||||
|
||||
const newBtn = Array.from(document.querySelectorAll('button')).find((b) =>
|
||||
/neue|invite|einladung/i.test(b.textContent ?? '')
|
||||
) as HTMLButtonElement | undefined;
|
||||
newBtn?.click();
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
|
||||
const formAfter = document.querySelector('form[action="?/create"]');
|
||||
expect(formAfter).not.toBeNull();
|
||||
});
|
||||
|
||||
it('shows the load error banner when data.loadError is set', async () => {
|
||||
render(AdminInvitesPage, {
|
||||
props: { data: baseData({ loadError: 'INTERNAL_ERROR' }), form: undefined }
|
||||
});
|
||||
|
||||
const banner = document.querySelector('.bg-red-50');
|
||||
expect(banner).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user