feat: add Header with language switcher and theme toggle
Also disables Vitest file parallelism since concurrent astro builds across test files raced on the shared dist/ output.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
describe('Header, language switcher, theme toggle', () => {
|
||||
beforeAll(() => {
|
||||
execSync('npm run build', { stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('renders the brand link on both locales', () => {
|
||||
const en = readFileSync('dist/en/index.html', 'utf-8');
|
||||
const fr = readFileSync('dist/fr/index.html', 'utf-8');
|
||||
expect(en).toContain('class="brand" href="/en/"');
|
||||
expect(fr).toContain('class="brand" href="/fr/"');
|
||||
});
|
||||
|
||||
it('language switcher on /en/ links to /fr/ and vice versa', () => {
|
||||
const en = readFileSync('dist/en/index.html', 'utf-8');
|
||||
const fr = readFileSync('dist/fr/index.html', 'utf-8');
|
||||
expect(en).toContain('class="language-switcher" href="/fr/"');
|
||||
expect(fr).toContain('class="language-switcher" href="/en/"');
|
||||
});
|
||||
|
||||
it('theme toggle button carries localized aria-labels', () => {
|
||||
const en = readFileSync('dist/en/index.html', 'utf-8');
|
||||
const fr = readFileSync('dist/fr/index.html', 'utf-8');
|
||||
expect(en).toContain('aria-label="Switch to dark mode"');
|
||||
expect(fr).toContain('aria-label="Passer en mode sombre"');
|
||||
});
|
||||
|
||||
it('theme toggle click handler flips data-theme and persists to localStorage', () => {
|
||||
const en = readFileSync('dist/en/index.html', 'utf-8');
|
||||
expect(en).toContain("localStorage.setItem('ombrora-theme', next)");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user