peregrine/web/src/test-setup.ts
pyr0ball 49e3265132 feat(web): merge Vue SPA from feature/vue-spa; add ClassicUIButton + useFeatureFlag
- Import web/ directory (Vue 3 + Vite + UnoCSS SPA) from feature/vue-spa branch
- Add web/src/components/ClassicUIButton.vue: switch-back to Streamlit via
  cookie (prgn_ui=streamlit) + ?prgn_switch=streamlit query param bridge
- Add web/src/composables/useFeatureFlag.ts: reads prgn_demo_tier cookie for
  demo toolbar visual consistency (not an authoritative gate, see issue #8)
- Update .gitignore: add .superpowers/, pytest-output.txt, docs/superpowers/
2026-03-22 18:46:11 -07:00

35 lines
1 KiB
TypeScript

// jsdom does not implement window.matchMedia — stub it so useMotion and other
// composables that check prefers-reduced-motion can import without throwing.
// Gotcha #12.
if (typeof window !== 'undefined' && !window.matchMedia) {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {},
removeListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => false,
}),
})
}
// navigator.vibrate not in jsdom — stub so useHaptics doesn't throw. Gotcha #9.
if (typeof window !== 'undefined' && !('vibrate' in window.navigator)) {
Object.defineProperty(window.navigator, 'vibrate', {
writable: true,
value: () => false,
})
}
// ResizeObserver not in jsdom — stub if any component uses it.
if (typeof window !== 'undefined' && !window.ResizeObserver) {
window.ResizeObserver = class {
observe() {}
unobserve() {}
disconnect() {}
}
}