Add sidebar navigation and global command search

This commit is contained in:
2026-10-07 18:59:39 -04:00
parent 9999e80226
commit e4f37f6964
33 changed files with 660 additions and 151 deletions
+24
View File
@@ -0,0 +1,24 @@
import { expect, it, vi } from 'vitest';
import { render } from 'svelte/server';
import CommandPalette from '../../src/lib/ui/components/CommandPalette.svelte';
vi.mock('$app/navigation', () => ({ goto: vi.fn() }));
it('connects the search field to a labelled option list and its selected result', () => {
const body = render(CommandPalette, { props: { open: true, role: 'operator' } }).body;
expect(body).toContain('role="combobox"');
expect(body).toContain('aria-autocomplete="list"');
expect(body).toContain('aria-expanded="true"');
const list = /aria-controls="([^"]+)"/.exec(body)?.[1];
const active = /aria-activedescendant="([^"]+)"/.exec(body)?.[1];
expect(list).toBeTruthy(); expect(active).toBeTruthy();
expect(body).toContain(`id="${list}" role="listbox"`);
expect(body).toContain(`id="${active}" role="option" tabindex="-1" aria-selected="true"`);
expect(body).toContain('Create server'); expect(body).not.toContain('Add host');
});
it('keeps the navigation palette useful for viewers without offering write actions', () => {
const body = render(CommandPalette, { props: { open: true, role: 'viewer' } }).body;
expect(body).toContain('Campaigns'); expect(body).toContain('Leaderboard');
expect(body).not.toContain('Create server'); expect(body).not.toContain('Add host');
});