Files
familysync/apps/pwa/src/test-setup.ts
T
Lucas Berger 3eebfbff42 feat(02-05): EventDetailPopover read-only popover, XSS-safe, wired into CalendarShell
- EventDetailPopover: reads openEventId from Zustand, resolves occurrence from TanStack Query cache
- Dual-mode: standalone (Zustand-driven) + customComponents.eventModal (Schedule-X)
- Plain-text JSX children for all event fields (T-02e-01 XSS guard)
- Focus trap, Escape to close, backdrop-click to close, aria-label=Close (44px target)
- Phone: bottom sheet layout; tablet/desktop: centered popover (max-width 360px)
- Phase-3 footer action area reserved with comment
- CalendarShell: passes customComponents.eventModal=EventDetailPopover to ScheduleXCalendar
- test-setup.ts: import @testing-library/jest-dom for toHaveTextContent matcher
- All 36 tests pass, tsc clean
2026-06-05 10:51:57 -04:00

33 lines
1.1 KiB
TypeScript

/**
* Vitest global test setup for apps/pwa.
*
* This file runs before each test file, before module imports that trigger
* module-level side effects (e.g. Zustand store initialisation calls
* window.matchMedia at create() time).
*
* Polyfills required for jsdom:
* - window.matchMedia: used by calendarStore to resolve the default view
* from viewport width at store initialisation time.
*/
// Extend Vitest's expect with jest-dom matchers (toHaveTextContent, etc.)
import '@testing-library/jest-dom'
// Polyfill window.matchMedia for jsdom.
// jsdom does not implement the CSSOM MediaQueryList API.
// calendarStore.ts calls window.matchMedia during Zustand create(), so this
// must be set before the store module is imported in any test.
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false, // tablet-desktop default — week-start-day tests are unaffected
media: query,
onchange: null,
addListener: () => undefined,
removeListener: () => undefined,
addEventListener: () => undefined,
removeEventListener: () => undefined,
dispatchEvent: () => false,
}),
})