fix(editor): final review round, prettier on shell chrome files

This commit is contained in:
bchanot committed 2026-11-13 23:42:32 +01:00
1 parent 6bf9290da7
commit d6e501ef04
2 files changed
+69 -19

No files matched your search

+50 -14
View File
@@ -78,7 +78,10 @@ function mount(path = '/app') {
<Route path="/app" element={<AppLayout />}>
<Route index element={<p>dashboard page</p>} />
<Route path="account" element={<p>account page</p>} />
<Route path="admin/sheets/:sheetId/draft" element={<p>draft page</p>} />
<Route
path="admin/sheets/:sheetId/draft"
element={<p>draft page</p>}
/>
<Route path="admin/sheets/:sheetId" element={<p>overview page</p>} />
</Route>
</Routes>
@@ -122,7 +125,9 @@ describe('AppLayout', () => {
it('shows the photo everywhere once the store holds a blob URL, the monogram otherwise', () => {
mount()
expect(screen.queryAllByRole('img', { name: fr['account.avatar.alt'] })).toHaveLength(0)
expect(
screen.queryAllByRole('img', { name: fr['account.avatar.alt'] }),
).toHaveLength(0)
expect(screen.getAllByText('AL').length).toBeGreaterThan(0)
cleanup()
useAuthStore.setState({ avatarUrl: 'blob:photo' })
@@ -136,7 +141,9 @@ describe('AppLayout', () => {
it('marks the active destination', () => {
mount('/app/account')
const nav = screen.getByRole('navigation', { name: fr['shell.nav_label'] })
const link = within(nav).getByRole('link', { name: new RegExp(fr['shell.nav.account']) })
const link = within(nav).getByRole('link', {
name: new RegExp(fr['shell.nav.account']),
})
expect(link).toHaveAttribute('aria-current', 'page')
})
@@ -144,10 +151,16 @@ describe('AppLayout', () => {
const user = userEvent.setup()
stubScreen(40)
mount()
await user.click(screen.getByRole('button', { name: fr['shell.open_menu'] }))
const drawer = await screen.findByRole('dialog', { name: fr['shell.nav_label'] })
await user.click(
screen.getByRole('button', { name: fr['shell.open_menu'] }),
)
const drawer = await screen.findByRole('dialog', {
name: fr['shell.nav_label'],
})
expect(drawer).toBeInTheDocument()
const links = screen.getAllByRole('link', { name: new RegExp(fr['shell.nav.account']) })
const links = screen.getAllByRole('link', {
name: new RegExp(fr['shell.nav.account']),
})
await user.click(links[links.length - 1])
expect(await screen.findByText('account page')).toBeInTheDocument()
})
@@ -155,7 +168,9 @@ describe('AppLayout', () => {
it('signs out and returns to the local tool', async () => {
const user = userEvent.setup()
mount()
const [button] = screen.getAllByRole('button', { name: fr['shell.sign_out'] })
const [button] = screen.getAllByRole('button', {
name: fr['shell.sign_out'],
})
await user.click(button)
expect(fake.auth.signOut).toHaveBeenCalled()
expect(await screen.findByText('local tool')).toBeInTheDocument()
@@ -164,14 +179,17 @@ describe('AppLayout', () => {
describe('AppLayout, editor sidebar from 1 280 px', () => {
const sidebar = () => document.querySelector('aside') as HTMLElement
const topBarMenu = () => screen.getByRole('button', { name: fr['shell.open_menu'], hidden: true })
const topBarMenu = () =>
screen.getByRole('button', { name: fr['shell.open_menu'], hidden: true })
it('uses the xl class set on the editor path, the lg set elsewhere', () => {
mount('/app/admin/sheets/s-1/draft')
expect(sidebar()).toHaveClass('xl:flex')
expect(sidebar()).not.toHaveClass('lg:flex')
expect(topBarMenu()).toHaveClass('xl:hidden')
expect(screen.getByRole('heading', { level: 1, hidden: true })).toHaveClass('xl:block')
expect(screen.getByRole('heading', { level: 1, hidden: true })).toHaveClass(
'xl:block',
)
cleanup()
mount('/app/admin/sheets/s-1')
expect(sidebar()).toHaveClass('lg:flex')
@@ -181,10 +199,22 @@ describe('AppLayout, editor sidebar from 1 280 px', () => {
it('keeps the sidebar fixed while the content scrolls, with its own scroll', () => {
mount('/app/admin/sheets/s-1/draft')
expect(sidebar()).toHaveClass('sticky', 'top-0', 'h-dvh', 'self-start', 'overflow-y-auto')
expect(sidebar()).toHaveClass(
'sticky',
'top-0',
'h-dvh',
'self-start',
'overflow-y-auto',
)
cleanup()
mount('/app/admin/sheets/s-1')
expect(sidebar()).toHaveClass('sticky', 'top-0', 'h-dvh', 'self-start', 'overflow-y-auto')
expect(sidebar()).toHaveClass(
'sticky',
'top-0',
'h-dvh',
'self-start',
'overflow-y-auto',
)
})
it('keeps the drawer open at 1 180 px in the editor, closes it from 1 280 px', async () => {
@@ -192,7 +222,9 @@ describe('AppLayout, editor sidebar from 1 280 px', () => {
const fire = stubScreen(73.75)
mount('/app/admin/sheets/s-1/draft')
await user.click(topBarMenu())
expect(await screen.findByRole('dialog', { name: fr['shell.nav_label'] })).toBeInTheDocument()
expect(
await screen.findByRole('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)')
@@ -218,7 +250,9 @@ describe('AppLayout, editor sidebar from 1 280 px', () => {
cleanup()
mount('/app/admin/sheets/s-1/draft')
await user.click(topBarMenu())
expect(await screen.findByRole('dialog', { name: fr['shell.nav_label'] })).toBeInTheDocument()
expect(
await screen.findByRole('dialog', { name: fr['shell.nav_label'] }),
).toBeInTheDocument()
})
it('asks before leaving from a drawer link while changes are unsaved', async () => {
@@ -227,7 +261,9 @@ describe('AppLayout, editor sidebar from 1 280 px', () => {
mount('/app/admin/sheets/s-1/draft')
useLeaveGuardStore.getState().arm(true)
await user.click(topBarMenu())
const drawer = await screen.findByRole('dialog', { name: fr['shell.nav_label'] })
const drawer = await screen.findByRole('dialog', {
name: fr['shell.nav_label'],
})
const account = new RegExp(fr['shell.nav.account'])
await user.click(within(drawer).getByRole('link', { name: account }))
expect(screen.queryByText('account page')).toBeNull()