22ac86f200
The main nav was carrying surfaces that didn't belong on it: - Search led to an empty page when clicked (you only ever want to land there from the global SearchInput typing into /search?q=...). Drop it. - Requests is downstream of Discover (you discover, then you request). Lift both onto a shared horizontal tab strip; keep their URLs so bookmarks survive. New DiscoverTabs component used by both pages. - Settings + Admin are operator chrome, not primary surfaces. Move them into the username dropdown alongside Log out, with Admin gated on is_admin. Users see Settings + Log out; admins see Settings + Admin + Log out. Final main nav: Home / Artists / Albums / Liked / Discover / Playlists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/svelte';
|
|
|
|
const state = vi.hoisted(() => ({
|
|
pageUrl: new URL('http://localhost/discover')
|
|
}));
|
|
|
|
vi.mock('$app/state', () => ({
|
|
page: { get url() { return state.pageUrl; } }
|
|
}));
|
|
|
|
import DiscoverTabs from './DiscoverTabs.svelte';
|
|
|
|
describe('DiscoverTabs', () => {
|
|
test('Discover tab is current on /discover', () => {
|
|
state.pageUrl = new URL('http://localhost/discover');
|
|
render(DiscoverTabs);
|
|
expect(screen.getByRole('link', { name: /discover/i })).toHaveAttribute('aria-current', 'page');
|
|
expect(screen.getByRole('link', { name: /requests/i })).not.toHaveAttribute('aria-current');
|
|
});
|
|
|
|
test('Requests tab is current on /requests', () => {
|
|
state.pageUrl = new URL('http://localhost/requests');
|
|
render(DiscoverTabs);
|
|
expect(screen.getByRole('link', { name: /requests/i })).toHaveAttribute('aria-current', 'page');
|
|
expect(screen.getByRole('link', { name: /discover/i })).not.toHaveAttribute('aria-current');
|
|
});
|
|
|
|
test('renders both tabs in order', () => {
|
|
state.pageUrl = new URL('http://localhost/discover');
|
|
render(DiscoverTabs);
|
|
const labels = screen.getAllByRole('link').map((l) => l.textContent?.trim());
|
|
expect(labels).toEqual(['Discover', 'Requests']);
|
|
});
|
|
});
|