Commit 7689db70 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix back-button/navigation clobber, add in-app install banner

useBackButtonClose's cleanup unconditionally called history.back() to
consume its own leftover entry, which broke the More sheet: clicking
an item both navigates (route Link) and closes the sheet in the same
click, and the cleanup's history.back() undid that navigation since
it was now the top-most entry, making every More button appear to do
nothing. Each pushed entry now carries a unique id and cleanup only
consumes it if it's still current.

Also adds a custom in-app "Install Stax" banner (useInstallPrompt +
InstallBanner) since the browser's own install icon is easy to miss -
captures beforeinstallprompt at module load (not component-scoped,
since every page remounts its own <Layout>) and shows manual Share ->
Add to Home Screen instructions on iOS Safari, which has no
programmatic install API at all.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 03069f85
Pipeline #1147 passed with stage
in 8 minutes and 46 seconds
import { act, render, screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { InstallBanner } from './InstallBanner'
// useInstallPrompt's capture state is module-level (see its own file for why), so - same as
// its own test file - order matters within this file too. In particular, the iOS test below
// must run before any test that dispatches beforeinstallprompt without also consuming it via
// promptInstall (e.g. dismissing via the X button doesn't call promptInstall) - otherwise a
// leftover deferredEvent from an earlier test would make canInstall true and suppress the iOS
// instructions branch, which only shows when there's nothing to prompt.
function dispatchBeforeInstallPrompt(outcome: 'accepted' | 'dismissed' = 'dismissed') {
const prompt = vi.fn().mockResolvedValue(undefined)
const event = Object.assign(new Event('beforeinstallprompt', { cancelable: true }), {
prompt,
userChoice: Promise.resolve({ outcome }),
})
window.dispatchEvent(event)
return prompt
}
describe('InstallBanner', () => {
afterEach(() => {
vi.restoreAllMocks()
localStorage.clear()
})
it('renders nothing before installability is known', () => {
render(<InstallBanner />)
expect(screen.queryByRole('note', { name: 'Install Stax' })).not.toBeInTheDocument()
})
it('shows manual instructions instead of a button on iOS Safari', async () => {
vi.spyOn(window.navigator, 'userAgent', 'get').mockReturnValue(
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
)
render(<InstallBanner />)
const banner = await screen.findByRole('note', { name: 'Install Stax' })
expect(within(banner).queryByRole('button', { name: 'Install' })).not.toBeInTheDocument()
expect(within(banner).getByText(/Add to Home Screen/)).toBeInTheDocument()
})
it('shows an Install button once beforeinstallprompt fires, and triggers the real prompt', async () => {
render(<InstallBanner />)
let prompt!: ReturnType<typeof vi.fn>
act(() => {
prompt = dispatchBeforeInstallPrompt()
})
const banner = await screen.findByRole('note', { name: 'Install Stax' })
await userEvent.click(within(banner).getByRole('button', { name: 'Install' }))
expect(prompt).toHaveBeenCalledTimes(1)
})
it('dismissing hides the banner and persists across remounts', async () => {
const { unmount } = render(<InstallBanner />)
act(() => {
dispatchBeforeInstallPrompt()
})
const banner = await screen.findByRole('note', { name: 'Install Stax' })
await userEvent.click(within(banner).getByRole('button', { name: 'Dismiss install prompt' }))
expect(screen.queryByRole('note', { name: 'Install Stax' })).not.toBeInTheDocument()
unmount()
render(<InstallBanner />)
// Still installable (canInstall is true from the earlier dispatch, module-level state) but
// the dismissal itself is what's under test here - a fresh mount must not resurrect it.
expect(screen.queryByRole('note', { name: 'Install Stax' })).not.toBeInTheDocument()
})
})
import { useState } from 'react'
import { Share, Smartphone, X } from 'lucide-react'
import { useInstallPrompt } from '../hooks/useInstallPrompt'
import { Button } from './ui/Button'
const DISMISS_KEY = 'stax-install-banner-dismissed'
/** In-app "Install Stax" affordance - the browser's own install icon (Chrome's omnibox, etc.)
* is easy to miss entirely, so this surfaces the same action directly in the UI, matching how
* most consumer web apps do it rather than leaving it purely to browser chrome. Renders
* nothing once installed, once dismissed (persisted - a "no thanks" shouldn't reappear on
* every page), or before the browser has told us installability is even possible. */
export function InstallBanner() {
const { installed, canInstall, showIosInstructions, promptInstall } = useInstallPrompt()
const [dismissed, setDismissed] = useState(() => localStorage.getItem(DISMISS_KEY) === '1')
if (installed || dismissed || (!canInstall && !showIosInstructions)) return null
function dismiss() {
localStorage.setItem(DISMISS_KEY, '1')
setDismissed(true)
}
return (
<div
role="note"
aria-label="Install Stax"
className="mb-6 flex items-center gap-3 rounded-xl border border-outline-variant bg-surface-container px-4 py-3"
>
<Smartphone size={18} strokeWidth={2} className="shrink-0 text-primary" />
<div className="min-w-0 flex-1 text-sm text-on-surface">
{canInstall ? (
<p>Install Stax for the full app experience - its own window, no browser bar.</p>
) : (
<p className="flex flex-wrap items-center gap-1">
Install Stax: tap
<Share size={13} strokeWidth={2} className="inline shrink-0" aria-hidden="true" />
Share, then "Add to Home Screen".
</p>
)}
</div>
{canInstall && (
<Button size="sm" onClick={promptInstall} className="shrink-0">
Install
</Button>
)}
<button
onClick={dismiss}
aria-label="Dismiss install prompt"
className="shrink-0 rounded-full p-1.5 text-on-surface-variant transition-colors hover:bg-surface-container-high hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
<X size={16} strokeWidth={2} />
</button>
</div>
)
}
...@@ -24,6 +24,7 @@ import { Button } from './ui/Button' ...@@ -24,6 +24,7 @@ import { Button } from './ui/Button'
import { NowPlayingBar } from './NowPlayingBar' import { NowPlayingBar } from './NowPlayingBar'
import { FullPlayer } from './FullPlayer' import { FullPlayer } from './FullPlayer'
import { PlaybackErrorToast } from './PlaybackErrorToast' import { PlaybackErrorToast } from './PlaybackErrorToast'
import { InstallBanner } from './InstallBanner'
import { useBackButtonClose } from '../hooks/useBackButtonClose' import { useBackButtonClose } from '../hooks/useBackButtonClose'
// Rooms/Channels/Posts share one "Social" destination and Nearby/Drops share one // Rooms/Channels/Posts share one "Social" destination and Nearby/Drops share one
...@@ -146,6 +147,7 @@ export function Layout({ title, children }: { title: string; children: ReactNode ...@@ -146,6 +147,7 @@ export function Layout({ title, children }: { title: string; children: ReactNode
> >
<div className="mx-auto max-w-2xl sm:max-w-3xl"> <div className="mx-auto max-w-2xl sm:max-w-3xl">
<h1 className="mb-6 text-xl font-semibold tracking-tight sm:text-2xl">{title}</h1> <h1 className="mb-6 text-xl font-semibold tracking-tight sm:text-2xl">{title}</h1>
<InstallBanner />
{children} {children}
</div> </div>
</main> </main>
......
...@@ -73,6 +73,26 @@ describe('useBackButtonClose', () => { ...@@ -73,6 +73,26 @@ describe('useBackButtonClose', () => {
) )
}) })
it('does not undo a navigation that happens in the same action that closes the overlay', () => {
// Reproduces a real bug: a "More" sheet item is both a route Link (pushes its own history
// entry via React Router's navigate()) and calls onClose to dismiss the sheet, in the same
// click handler. Modeled here directly with history.pushState, since that's exactly what
// navigate() does under the hood - the overlay's own cleanup must not blindly call
// history.back() and undo that unrelated push.
const onClose = vi.fn()
const backSpy = vi.spyOn(window.history, 'back')
const { rerender } = renderHook(({ open }) => useBackButtonClose(open, onClose), {
initialProps: { open: true },
})
// Something else (a route navigation) pushes a new entry before this hook's cleanup runs.
window.history.pushState({}, '', '/somewhere-else')
rerender({ open: false })
expect(backSpy).not.toHaveBeenCalled()
expect(window.location.pathname).toBe('/somewhere-else')
})
it('a single back press closes only the top-most of two nested overlays', () => { it('a single back press closes only the top-most of two nested overlays', () => {
const closeOuter = vi.fn() const closeOuter = vi.fn()
const closeInner = vi.fn() const closeInner = vi.fn()
......
...@@ -12,6 +12,13 @@ let listenerAttached = false ...@@ -12,6 +12,13 @@ let listenerAttached = false
// the resulting popstate is recognized as self-inflicted and skipped rather than incorrectly // the resulting popstate is recognized as self-inflicted and skipped rather than incorrectly
// popping and closing whatever's now on top of the stack. // popping and closing whatever's now on top of the stack.
let suppressNextPopstate = 0 let suppressNextPopstate = 0
// Tags each pushed entry so cleanup can tell whether it's still the current one - a caller can
// close an overlay via an action that *also* navigates (e.g. a "More" sheet item that's both a
// route Link and calls onClose to dismiss the sheet); that navigation pushes its own entry on
// top of ours in the same tick, before this hook's cleanup effect runs. Without this check,
// cleanup would call history.back() unconditionally and undo that navigation instead of just
// consuming its own now-buried entry.
let nextEntryId = 0
function ensureListener() { function ensureListener() {
if (listenerAttached) return if (listenerAttached) return
...@@ -37,11 +44,14 @@ export function useBackButtonClose(isOpen: boolean, onClose: () => void) { ...@@ -37,11 +44,14 @@ export function useBackButtonClose(isOpen: boolean, onClose: () => void) {
const onCloseRef = useRef(onClose) const onCloseRef = useRef(onClose)
onCloseRef.current = onClose onCloseRef.current = onClose
const entryRef = useRef<(() => void) | null>(null) const entryRef = useRef<(() => void) | null>(null)
const entryIdRef = useRef<number | null>(null)
useEffect(() => { useEffect(() => {
if (!isOpen) return if (!isOpen) return
ensureListener() ensureListener()
window.history.pushState({}, '') const id = nextEntryId++
entryIdRef.current = id
window.history.pushState({ __backButtonCloseId: id }, '')
const callback = () => onCloseRef.current() const callback = () => onCloseRef.current()
stack.push(callback) stack.push(callback)
entryRef.current = callback entryRef.current = callback
...@@ -50,14 +60,23 @@ export function useBackButtonClose(isOpen: boolean, onClose: () => void) { ...@@ -50,14 +60,23 @@ export function useBackButtonClose(isOpen: boolean, onClose: () => void) {
if (!entryRef.current) return if (!entryRef.current) return
const idx = stack.lastIndexOf(entryRef.current) const idx = stack.lastIndexOf(entryRef.current)
entryRef.current = null entryRef.current = null
if (idx !== -1) { if (idx === -1) {
// Still on the stack, so this close wasn't the back button - consume the entry now. // Already popped by the listener itself (a real back press caused this close) - the
// history entry's already gone, nothing left to clean up.
return
}
stack.splice(idx, 1) stack.splice(idx, 1)
// Only consume the browser history entry if it's still the current one - if something
// else (e.g. a route navigation fired by the same click that closed this overlay)
// already pushed a newer entry on top, history.back() here would wrongly undo that
// navigation instead of just cleaning up after this overlay. Leaving it in place is
// harmless: the entry still points at the page this overlay was opened from, so a
// later real back press lands in the right place regardless.
const state = window.history.state as { __backButtonCloseId?: number } | null
if (state?.__backButtonCloseId === id) {
suppressNextPopstate++ suppressNextPopstate++
window.history.back() window.history.back()
} }
// else: already popped by the listener itself (a real back press caused this close) -
// the history entry's already gone, nothing left to clean up.
} }
}, [isOpen]) }, [isOpen])
} }
import { act, renderHook } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { useInstallPrompt } from './useInstallPrompt'
// deferredEvent/installedFlag are module-level (see the hook's own comment on why), so these
// tests share state across the whole file the same way useBackButtonClose's stack does - order
// matters. Anything that needs `installed: false` as a starting point must run before the
// "accepted outcome" test below, since that one permanently flips it true for the rest of the
// file's run.
function dispatchBeforeInstallPrompt(userChoice: Promise<{ outcome: 'accepted' | 'dismissed' }>) {
const prompt = vi.fn().mockResolvedValue(undefined)
const event = Object.assign(new Event('beforeinstallprompt', { cancelable: true }), { prompt, userChoice })
window.dispatchEvent(event)
return prompt
}
describe('useInstallPrompt', () => {
afterEach(() => {
vi.restoreAllMocks()
})
it('starts with nothing installable and no iOS instructions on a non-iOS UA', () => {
const { result } = renderHook(() => useInstallPrompt())
expect(result.current.installed).toBe(false)
expect(result.current.canInstall).toBe(false)
expect(result.current.showIosInstructions).toBe(false)
})
it('shows iOS instructions instead of canInstall on an iPhone Safari UA', () => {
vi.spyOn(window.navigator, 'userAgent', 'get').mockReturnValue(
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
)
const { result } = renderHook(() => useInstallPrompt())
expect(result.current.showIosInstructions).toBe(true)
expect(result.current.canInstall).toBe(false)
})
it('does not treat iOS Chrome (crios) as Safari - no instructions shown', () => {
vi.spyOn(window.navigator, 'userAgent', 'get').mockReturnValue(
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0 Mobile/15E148 Safari/604.1',
)
const { result } = renderHook(() => useInstallPrompt())
expect(result.current.showIosInstructions).toBe(false)
})
it('captures beforeinstallprompt and exposes canInstall', () => {
const { result } = renderHook(() => useInstallPrompt())
act(() => {
dispatchBeforeInstallPrompt(Promise.resolve({ outcome: 'dismissed' }))
})
expect(result.current.canInstall).toBe(true)
expect(result.current.installed).toBe(false)
})
it('promptInstall calls prompt(), awaits userChoice, and resets canInstall on a dismissed outcome', async () => {
const { result } = renderHook(() => useInstallPrompt())
let prompt!: ReturnType<typeof vi.fn>
act(() => {
prompt = dispatchBeforeInstallPrompt(Promise.resolve({ outcome: 'dismissed' }))
})
await act(() => result.current.promptInstall())
expect(prompt).toHaveBeenCalledTimes(1)
expect(result.current.canInstall).toBe(false)
expect(result.current.installed).toBe(false)
})
it('an accepted outcome sets installed to true', async () => {
const { result } = renderHook(() => useInstallPrompt())
act(() => {
dispatchBeforeInstallPrompt(Promise.resolve({ outcome: 'accepted' }))
})
await act(() => result.current.promptInstall())
expect(result.current.installed).toBe(true)
})
it('appinstalled clears any pending prompt', () => {
const { result } = renderHook(() => useInstallPrompt())
act(() => {
dispatchBeforeInstallPrompt(Promise.resolve({ outcome: 'dismissed' }))
})
expect(result.current.canInstall).toBe(true)
act(() => {
window.dispatchEvent(new Event('appinstalled'))
})
expect(result.current.installed).toBe(true)
expect(result.current.canInstall).toBe(false)
})
})
import { useEffect, useReducer } from 'react'
// Non-standard - not in TS's default DOM lib, so it's typed here directly rather than pulling
// in a whole @types package for one event shape.
interface BeforeInstallPromptEvent extends Event {
prompt: () => Promise<void>
userChoice: Promise<{ outcome: 'accepted' | 'dismissed' }>
}
function isStandalone(): boolean {
if (typeof window === 'undefined') return false
if (window.matchMedia('(display-mode: standalone)').matches) return true
// iOS Safari has no beforeinstallprompt/display-mode support at all - this non-standard flag
// is the only signal it exposes for "already added to the home screen".
return (window.navigator as Navigator & { standalone?: boolean }).standalone === true
}
function isIosSafari(): boolean {
if (typeof window === 'undefined') return false
const ua = window.navigator.userAgent
const isIos = /iphone|ipad|ipod/i.test(ua) && !('MSStream' in window)
// Chrome/Firefox/Edge on iOS all use the system WebKit view and still match /safari/i in
// their UA string - excluding their own tokens is the only way to tell them apart from
// actual Safari, which is the only iOS browser where "Add to Home Screen" is reachable at
// all (the others don't expose the share sheet action for it).
const isSafari = /safari/i.test(ua) && !/crios|fxios|edgios/i.test(ua)
return isIos && isSafari
}
// Module-level, not component state - deliberately mirrors useBackButtonClose's pattern.
// Every page wraps its own <Layout> (see App.tsx's routes), so a listener registered inside a
// component effect could miss the event entirely if it fires before that particular page
// happens to mount, and there's no second chance: browsers dispatch beforeinstallprompt at
// most once per page load, not once per component mount. Registering here at module load time
// instead means it's caught regardless of what's mounted yet.
let deferredEvent: BeforeInstallPromptEvent | null = null
let installedFlag = isStandalone()
const listeners = new Set<() => void>()
function notify() {
listeners.forEach((listener) => listener())
}
if (typeof window !== 'undefined') {
window.addEventListener('beforeinstallprompt', (e) => {
// Suppresses the browser's own automatic install UI so this app's own prompt/button is
// the one source of truth for triggering it - otherwise both could show at once.
e.preventDefault()
deferredEvent = e as BeforeInstallPromptEvent
notify()
})
window.addEventListener('appinstalled', () => {
installedFlag = true
deferredEvent = null
notify()
})
}
/** Drives a custom in-app "Install Stax" affordance instead of relying solely on the browser's
* own (easy to miss) omnibox icon - `canInstall` + `promptInstall` cover Chrome/Edge/Android,
* `showIosInstructions` covers iOS Safari, which has no programmatic install API at all and
* needs a manual Share -> Add to Home Screen nudge instead. */
export function useInstallPrompt() {
const [, forceRender] = useReducer((c: number) => c + 1, 0)
useEffect(() => {
listeners.add(forceRender)
return () => {
listeners.delete(forceRender)
}
}, [forceRender])
async function promptInstall() {
if (!deferredEvent) return
const event = deferredEvent
await event.prompt()
const { outcome } = await event.userChoice
deferredEvent = null
if (outcome === 'accepted') installedFlag = true
notify()
}
return {
installed: installedFlag,
canInstall: !!deferredEvent,
showIosInstructions: !installedFlag && !deferredEvent && isIosSafari(),
promptInstall,
}
}
...@@ -209,13 +209,19 @@ const FRONTEND_DONE: DoneGroup[] = [ ...@@ -209,13 +209,19 @@ const FRONTEND_DONE: DoneGroup[] = [
area: 'PWA & Navigation', area: 'PWA & Navigation',
items: [ items: [
'Installable as a real app (2026-08-31): vite-plugin-pwa generates a manifest.webmanifest + service worker at build time, standalone display, cobalt-themed icons (incl. maskable variants for Android\'s adaptive-icon safe zone) - "Add to Home Screen" on iOS/Android now launches Stax in its own window, not a browser tab. Deliberately no runtimeCaching config: only the built app shell is precached, so authenticated/streamed/API requests always hit the network fresh rather than risking a stale or cross-account cache hit', 'Installable as a real app (2026-08-31): vite-plugin-pwa generates a manifest.webmanifest + service worker at build time, standalone display, cobalt-themed icons (incl. maskable variants for Android\'s adaptive-icon safe zone) - "Add to Home Screen" on iOS/Android now launches Stax in its own window, not a browser tab. Deliberately no runtimeCaching config: only the built app shell is precached, so authenticated/streamed/API requests always hit the network fresh rather than risking a stale or cross-account cache hit',
'System/Android back button closes overlays instead of leaving the page underneath them (2026-08-31): useBackButtonClose pushes one history entry per open overlay onto a shared stack (not one popstate listener per instance, since a single back press must close only the top-most of several nested overlays - e.g. FullPlayer\'s Queue screen on top of FullPlayer itself - not all of them at once) - wired into FullPlayer (+ its Queue screen as a second nested level), Layout\'s mobile More sheet, AddToPlaylistModal, SongPicker, and RemixSongPicker', 'In-app "Install Stax" banner (2026-08-31): the browser\'s own install icon is easy to miss entirely, so useInstallPrompt captures beforeinstallprompt at module load (not inside a component effect - each page wraps its own <Layout>, so a component-scoped listener could miss the one-per-page-load event if it fires before that particular page happens to mount) and InstallBanner surfaces a real "Install" button from it; iOS Safari has no such event at all, so it shows manual Share -> Add to Home Screen instructions instead',
'System/Android back button closes overlays instead of leaving the page underneath them (2026-08-31): useBackButtonClose pushes one history entry per open overlay onto a shared stack (not one popstate listener per instance, since a single back press must close only the top-most of several nested overlays - e.g. FullPlayer\'s Queue screen on top of FullPlayer itself - not all of them at once) - wired into FullPlayer (+ its Queue screen as a second nested level), Layout\'s mobile More sheet, AddToPlaylistModal, SongPicker, and RemixSongPicker. Fixed same day: closing an overlay via an action that *also* navigates (e.g. a More-sheet item, which is both a route Link and calls onClose) was clobbering that navigation - the cleanup unconditionally called history.back() to consume its own entry, which by then was buried under the Link\'s own pushState, so it undid the navigation instead. Each pushed entry now carries a unique id and cleanup only consumes it if it\'s still the current one',
'Swipe gestures on Library rows (2026-08-31): useSwipeAction (pointer-events based, no gesture library) drives a swipe-right-to-queue / swipe-left-to-delete interaction, sharing the same PlayerContext.addToQueue used elsewhere - queueing appends without touching whatever is currently playing, unlike toggle() which replaces the whole queue and starts playback', 'Swipe gestures on Library rows (2026-08-31): useSwipeAction (pointer-events based, no gesture library) drives a swipe-right-to-queue / swipe-left-to-delete interaction, sharing the same PlayerContext.addToQueue used elsewhere - queueing appends without touching whatever is currently playing, unlike toggle() which replaces the whole queue and starts playback',
], ],
}, },
] ]
const FRONTEND_TODO: WorkItem[] = [ const FRONTEND_TODO: WorkItem[] = [
{
item: "Browser-native install banner/omnibox icon (Chrome's own, distinct from the in-app InstallBanner)",
status: 'blocked',
note: "Verified 2026-08-31: the deployed preview server's cert is self-signed (issuer=subject=CN=example.org, from @vitejs/plugin-basic-ssl) bound to a bare IP - Chrome/Android are stricter than a manually-trusted secure context and won't reliably fire beforeinstallprompt or show the omnibox icon over it, which is what made install feel broken even with a correct manifest+service worker. Same blocker as the reverse-proxy item below: needs a real domain + a browser-trusted cert (Let's Encrypt) before this can work end to end, not a frontend fix.",
},
{ {
item: 'Delete buttons + confirm dialogs for playlists and playlist tracks', item: 'Delete buttons + confirm dialogs for playlists and playlist tracks',
status: 'ready', status: 'ready',
......
...@@ -20,3 +20,17 @@ window.HTMLElement.prototype.scrollIntoView = vi.fn() ...@@ -20,3 +20,17 @@ window.HTMLElement.prototype.scrollIntoView = vi.fn()
window.Element.prototype.setPointerCapture = vi.fn() window.Element.prototype.setPointerCapture = vi.fn()
window.Element.prototype.releasePointerCapture = vi.fn() window.Element.prototype.releasePointerCapture = vi.fn()
window.Element.prototype.hasPointerCapture = vi.fn(() => false) window.Element.prototype.hasPointerCapture = vi.fn(() => false)
// jsdom doesn't implement matchMedia at all - useInstallPrompt's isStandalone() check
// (display-mode: standalone) throws "not a function" without this. Always reports no match,
// which is correct for tests: nothing is ever actually running in standalone display mode.
window.matchMedia = vi.fn().mockImplementation((query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
}))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment