diff --git a/frontend/src/routes/admin/invites/page.svelte.test.ts b/frontend/src/routes/admin/invites/page.svelte.test.ts index 9e43e7aa..04d4cab5 100644 --- a/frontend/src/routes/admin/invites/page.svelte.test.ts +++ b/frontend/src/routes/admin/invites/page.svelte.test.ts @@ -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(); + }); });