feat(app): editor sidebar hidden below 1 280 px, menu one tap away

AC9: on the draft editor path AppLayout uses the xl class set (sidebar
from 1 280 px, menu button and brand below); other pages keep lg.
AppLayout split: Sidebar and TopBar in ShellChrome.tsx. MobileDrawer
takes closesFrom ('64rem' | '80rem') and also closes at setup when
its query already matches.

Rewritten assertions (R-24):
- shell.AppLayout "opens the mobile drawer" and shell.navigation
  "carries the same entries into the mobile drawer": stub a narrow
  matchMedia, the drawer now closes at setup at the happy-dom width.
New: unit tests (class sets, 64rem/80rem close, setup close, leave
guard on a drawer link) and editor-shell.spec F journeys (sidebar at
1024/1180/1279/1280, one-tap menu, drawer open at 1180, guard).
This commit is contained in:
bchanot committed 2026-11-08 19:25:49 +01:00
1 parent 89da8d3f55
commit 580ff28214
6 files changed
+317 -74

No files matched your search

+83
View File
@@ -11,6 +11,7 @@ import {
openEditor,
openReferences,
openSection,
pickAnnotation,
place,
pointOf,
seedDraft,
@@ -244,3 +245,85 @@ test.describe('editor shell, width crossing (B2b)', () => {
await expect(field).toHaveValue('Brouillon')
})
})
// V1-2.6 U1 F (AC9): in the editor the sidebar shows from 1 280 px only; below, the top
// bar's menu button opens the drawer, which stays open while the sidebar stays hidden.
test.describe('editor shell, sidebar from 1 280 px (F)', () => {
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'the widths are set by the tests themselves') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
const nav = (page: Page) =>
page.getByRole('navigation', { name: dict['shell.nav_label'] })
const menu = (page: Page) =>
page.getByRole('button', { name: dict['shell.open_menu'] })
const drawer = (page: Page) =>
page.getByRole('dialog', { name: dict['shell.nav_label'] })
async function measure(page: Page, width: number) {
await page.setViewportSize({ width, height: 800 })
await selectTab(page, dict, 'annotations')
await pickAnnotation(page, dict, 'Point libre')
const canvas = await page.getByTestId('annotation-canvas').boundingBox()
const scroll = await page.evaluate(() => ({
scrollWidth: document.documentElement.scrollWidth,
clientWidth: document.documentElement.clientWidth,
}))
console.log(`F-measure ${width}px canvas=${canvas?.width} ${JSON.stringify(scroll)}`)
return scroll
}
test('the sidebar is hidden below 1 280 px and shown from 1 280 px', async ({
page,
}) => {
await open(page)
for (const width of [1024, 1180, 1279]) {
const scroll = await measure(page, width)
expect(scroll.scrollWidth, `${width} px`).toBeLessThanOrEqual(scroll.clientWidth)
await expect(nav(page), `${width} px`).toHaveCount(0)
await expect(menu(page), `${width} px`).toBeVisible()
}
const scroll = await measure(page, 1280)
expect(scroll.scrollWidth).toBeLessThanOrEqual(scroll.clientWidth)
await expect(nav(page)).toBeVisible()
await expect(menu(page)).toHaveCount(0)
})
test('the menu is one tap away and the drawer stays open at 1 180 px', async ({
page,
}) => {
await open(page)
await page.setViewportSize({ width: 1180, height: 800 })
await menu(page).click()
await expect(drawer(page)).toBeVisible()
await page.setViewportSize({ width: 1279, height: 800 })
await page.waitForTimeout(300)
await expect(drawer(page)).toBeVisible()
await page.setViewportSize({ width: 1280, height: 800 })
await expect(drawer(page)).toBeHidden()
await expect(nav(page)).toBeVisible()
})
test('a drawer link asks before leaving while the draft has unsaved changes', async ({
page,
}) => {
await open(page)
await page.setViewportSize({ width: 1180, height: 800 })
await selectTab(page, dict, 'general')
await page.locator('#general-name-fr').fill('Travail non enregistré')
await menu(page).click()
await drawer(page)
.getByRole('link', { name: new RegExp(dict['shell.nav.account']) })
.click()
const leave = page.getByRole('dialog', { name: dict['leave.title'] })
await expect(leave).toBeVisible()
await leave.getByRole('button', { name: dict['leave.stay'] }).click()
await expect(leave).toBeHidden()
await expect(page).toHaveURL(/\/draft/)
})
})