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

View File

@@ -97,30 +97,37 @@ describe('EntityNav', () => {
expect(mintIcons.length).toBeGreaterThan(0);
});
it('opens the flyout on tablet trigger button click', async () => {
it('opens the flyout dialog when a tablet section trigger is clicked', async () => {
mockPage.url = new URL('http://localhost/admin/users');
const EntityNav = await loadComponent();
render(EntityNav, { props: baseProps() });
// The tablet flyout triggers are the section buttons (not links)
// The first <button> in the DOM is the tablet trigger of the first section.
const triggerButton = document.querySelector('button') as HTMLButtonElement;
if (triggerButton) {
triggerButton.click();
await new Promise((r) => setTimeout(r, 50));
}
expect(triggerButton).not.toBeNull();
triggerButton.click();
// Render did not throw — branch reached
expect(true).toBe(true);
await vi.waitFor(() => {
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
});
});
it('handles Escape keypress on window without throwing', async () => {
it('Escape closes the open flyout', async () => {
mockPage.url = new URL('http://localhost/admin/users');
const EntityNav = await loadComponent();
render(EntityNav, { props: baseProps() });
expect(() =>
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
).not.toThrow();
// Open the flyout first.
(document.querySelector('button') as HTMLButtonElement).click();
await vi.waitFor(() => {
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
});
// Then Escape should close it (handler is bound via svelte:document).
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
await vi.waitFor(() => {
expect(document.querySelector('[role="dialog"]')).toBeNull();
});
});
it('renders the user count badge on the users link', async () => {