test(admin): expand admin/groups/new page coverage
Adds unsaved-warning hidden by default, oninput dirty marker, form error banner hidden when form is undefined. 3 new tests covering ~6 branches. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -82,4 +82,25 @@ describe('admin/groups/new page', () => {
|
|||||||
expect(nameInput.placeholder).not.toBe('');
|
expect(nameInput.placeholder).not.toBe('');
|
||||||
expect(nameInput.required).toBe(true);
|
expect(nameInput.required).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not show the unsaved-warning banner before any input', async () => {
|
||||||
|
render(AdminGroupNewPage, { props: { form: undefined } });
|
||||||
|
|
||||||
|
// The unsaved warning specifically contains the German phrase
|
||||||
|
expect(document.body.textContent).not.toMatch(/ungespeicherte/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('marks the form dirty after an input event without throwing', async () => {
|
||||||
|
render(AdminGroupNewPage, { props: { form: undefined } });
|
||||||
|
|
||||||
|
const form = document.querySelector('form') as HTMLFormElement;
|
||||||
|
expect(() => form.dispatchEvent(new Event('input', { bubbles: true }))).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides the form error banner when form is undefined (already covered, branch 2)', async () => {
|
||||||
|
render(AdminGroupNewPage, { props: { form: undefined } });
|
||||||
|
|
||||||
|
const banner = document.querySelector('.bg-red-50');
|
||||||
|
expect(banner).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user