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:
1 parent
580ff28214
commit
62fb8dc7b8
3 files changed
+31
-9
No files matched your search
@@ -274,7 +274,10 @@ test.describe('editor shell, sidebar from 1 280 px (F)', () => {
|
||||
scrollWidth: document.documentElement.scrollWidth,
|
||||
clientWidth: document.documentElement.clientWidth,
|
||||
}))
|
||||
console.log(`F-measure ${width}px canvas=${canvas?.width} ${JSON.stringify(scroll)}`)
|
||||
test.info().annotations.push({
|
||||
type: 'canvas-width',
|
||||
description: `${canvas?.width}px at ${width}px`,
|
||||
})
|
||||
return scroll
|
||||
}
|
||||
|
||||
@@ -302,7 +305,9 @@ test.describe('editor shell, sidebar from 1 280 px (F)', () => {
|
||||
await menu(page).click()
|
||||
await expect(drawer(page)).toBeVisible()
|
||||
await page.setViewportSize({ width: 1279, height: 800 })
|
||||
await page.waitForTimeout(300)
|
||||
await page.evaluate(
|
||||
() => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))),
|
||||
)
|
||||
await expect(drawer(page)).toBeVisible()
|
||||
await page.setViewportSize({ width: 1280, height: 800 })
|
||||
await expect(drawer(page)).toBeHidden()
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
||||
import Brand from '@/components/brand/Brand'
|
||||
import Icon from '@/components/ui/Icon'
|
||||
import ModalDialog from '@/components/ui/ModalDialog'
|
||||
import { DEFAULT_SHELL } from './ShellChrome'
|
||||
import SidebarNav from './SidebarNav'
|
||||
import SignOutButton from './SignOutButton'
|
||||
import UserBadge from './UserBadge'
|
||||
@@ -17,7 +18,7 @@ export interface MobileDrawerProps {
|
||||
}
|
||||
|
||||
/** Left-side navigation drawer for small screens (transform + opacity only). */
|
||||
export default function MobileDrawer({ open, onClose, closesFrom = '64rem' }: MobileDrawerProps) {
|
||||
export default function MobileDrawer({ open, onClose, closesFrom = DEFAULT_SHELL.closesFrom }: MobileDrawerProps) {
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{open && <DrawerSurface onClose={onClose} closesFrom={closesFrom} />}
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user