diff --git a/apps/app/src/components/shell/ShellChrome.tsx b/apps/app/src/components/shell/ShellChrome.tsx index 05153de0..dd580aaf 100644 --- a/apps/app/src/components/shell/ShellChrome.tsx +++ b/apps/app/src/components/shell/ShellChrome.tsx @@ -39,7 +39,9 @@ export const EDITOR_SHELL: ShellBreakpoint = { /** Title of the current /app page for the top bar, from the nav table. */ function pageTitleKey(pathname: string): string { const match = NAV_ITEMS.find((item) => - item.end ? item.to === pathname : pathname.startsWith(item.to) && item.to !== '/', + item.end + ? item.to === pathname + : pathname.startsWith(item.to) && item.to !== '/', ) return match?.labelKey ?? 'shell.nav.dashboard' } @@ -51,7 +53,11 @@ export function Sidebar({ shell }: { shell: ShellBreakpoint }) { className={`${shell.sidebar} sticky top-0 h-dvh self-start overflow-y-auto border-r border-[var(--color-border)] bg-[var(--color-surface)]`} >
- +
@@ -90,10 +96,16 @@ export function TopBar({ shell, menuOpen, onOpenMenu }: TopBarProps) { > - + -

+

{t(pageTitleKey(pathname))}

@@ -105,7 +117,9 @@ export function TopBar({ shell, menuOpen, onOpenMenu }: TopBarProps) { className="flex min-h-11 items-center gap-2 rounded-full pr-1 pl-1 text-sm text-[var(--color-ink)] hover:bg-[var(--color-surface-strong)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)] sm:pr-3" > - {displayName} + + {displayName} +
diff --git a/apps/app/tests/unit/shell.AppLayout.test.tsx b/apps/app/tests/unit/shell.AppLayout.test.tsx index 03691113..bb71d84d 100644 --- a/apps/app/tests/unit/shell.AppLayout.test.tsx +++ b/apps/app/tests/unit/shell.AppLayout.test.tsx @@ -78,7 +78,10 @@ function mount(path = '/app') { }> dashboard page

} /> account page

} /> - draft page

} /> + draft page

} + /> overview page

} />
@@ -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()