import { beforeEach, describe, expect, it } from 'vitest'; import { mountShell } from '../../src/ui/shell'; import { setDate, setSelectedHour, setLanguages } from '../../src/app-state'; describe('shell', () => { // app-state is a module-level singleton, so each test must reset every // field it might have mutated — not just the one it cares about — or // state leaks across tests in this file. beforeEach(() => { document.body.innerHTML = '
'; setDate('2026-08-09'); setSelectedHour('prime'); setLanguages(['en']); window.history.replaceState(null, '', '/vu/2026-08-09/prime'); }); it('renders the day nav, all 8 hours, and Prime content by default', () => { const root = document.getElementById('app')!; mountShell(root); expect(root.querySelector('.day-nav-date')?.textContent).toContain('August 9, 2026'); const hourNames = Array.from(root.querySelectorAll('.hour-name')).map((el) => el.textContent); expect(hourNames).toEqual([ 'Prime', 'Compline', 'Terce', 'Sext', 'None', 'Lauds', 'Vespers', 'Matins', ]); expect(root.querySelector('.hour-item.is-selected .hour-name')?.textContent).toBe('Prime'); expect(root.querySelector('.hour-view h2')?.textContent).toBe('Prime'); expect(root.querySelectorAll('.ordo-part-psalm').length).toBeGreaterThan(0); }); it('switches to a not-yet-built hour and shows the pending message', () => { const root = document.getElementById('app')!; mountShell(root); const complineBtn = Array.from(root.querySelectorAll