fix(app): Lot F review polish (tests, drawer default)

Measure kept as a canvas-width annotation, no console.log; positive
two-frame wait replaces the fixed sleep; 64rem listener asserted
absent in the editor; drawer default read from DEFAULT_SHELL; long
test lines wrapped.
This commit is contained in:
bchanot committed 2026-11-08 19:29:36 +01:00
1 parent 580ff28214
commit 62fb8dc7b8
3 files changed
+31 -9

No files matched your search

+22 -6
View File
@@ -1,8 +1,20 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react'
import {
act,
cleanup,
render,
screen,
waitFor,
within,
} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { MemoryRouter, Route, Routes } from 'react-router-dom'
import { createFakeSupabase, fakeProfile, fakeUser, type FakeSupabase } from '../helpers/fakeSupabase'
import {
createFakeSupabase,
fakeProfile,
fakeUser,
type FakeSupabase,
} from '../helpers/fakeSupabase'
const mocks = vi.hoisted(() => ({ fake: null as unknown }))
vi.mock('@/lib/supabase', () => ({
@@ -51,8 +63,11 @@ function stubScreen(widthRem: number) {
listeners.get(query)?.delete(fn)
},
}))
return (query: string) =>
const fire = (query: string) =>
act(() => listeners.get(query)?.forEach((fn) => fn({ matches: true })))
return Object.assign(fire, {
listening: (query: string) => (listeners.get(query)?.size ?? 0) > 0,
})
}
function mount(path = '/app') {
@@ -170,8 +185,8 @@ describe('AppLayout, editor sidebar from 1 280 px', () => {
mount('/app/admin/sheets/s-1/draft')
await user.click(topBarMenu())
expect(await screen.findByRole('dialog', { name: fr['shell.nav_label'] })).toBeInTheDocument()
fire('(min-width: 64rem)')
expect(screen.getByRole('dialog', { name: fr['shell.nav_label'] })).toBeInTheDocument()
expect(fire.listening('(min-width: 64rem)')).toBe(false)
expect(fire.listening('(min-width: 80rem)')).toBe(true)
fire('(min-width: 80rem)')
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
})
@@ -205,7 +220,8 @@ describe('AppLayout, editor sidebar from 1 280 px', () => {
useLeaveGuardStore.getState().arm(true)
await user.click(topBarMenu())
const drawer = await screen.findByRole('dialog', { name: fr['shell.nav_label'] })
await user.click(within(drawer).getByRole('link', { name: new RegExp(fr['shell.nav.account']) }))
const account = new RegExp(fr['shell.nav.account'])
await user.click(within(drawer).getByRole('link', { name: account }))
expect(screen.queryByText('account page')).toBeNull()
expect(await screen.findByText(fr['leave.title'])).toBeInTheDocument()
})