fix(editor): final review round, history, dialogs, Plus and limits

I1 scroll restored at once on a Back into layers; I2 Aller a opens the target dialog in one push; M1-M9, criteria 8 and 17 (left-draft notice), entry caps, no exhaustive-deps disables, locals within 5.
This commit is contained in:
bchanot committed 2026-11-13 23:42:32 +01:00
1 parent ce171427c0
commit 6bf9290da7
25 files changed
+1002 -202

No files matched your search

+12 -1
View File
@@ -491,9 +491,20 @@ for (const reduced of [false, true]) {
// The sheet closes and the family opens in the dialog (view mode); closed, the
// row holds the focus.
await expect(place(page, 'citations')).toHaveCount(0)
const family = findingDialog(page).getByRole('heading', {
name: 'Dysfonction A',
})
await expect(family).toBeVisible()
// Back returns to the place « Aller à » left: Constat A with its sheet open.
await page.goBack()
await expect(page.locator('dialog[open]')).toHaveCount(2)
await expect(place(page, 'citations')).toBeVisible()
await expect(
findingDialog(page).getByRole('heading', { name: 'Dysfonction A' }),
findingDialog(page).getByRole('heading', { name: 'Constat A' }),
).toBeVisible()
await page.goForward()
await expect(place(page, 'citations')).toHaveCount(0)
await expect(family).toBeVisible()
await closeFinding(page, dict)
await expect(
page.getByRole('treeitem', { name: /Dysfonction A/ }),
@@ -80,6 +80,31 @@ async function entryHolds(page: Page, test: string) {
)
}
/** A Back restores the page offset within this many pixels. */
const SCROLL_SLACK = 4
const scrollY = (page: Page) => page.evaluate(() => window.scrollY)
/**
* Pads the page so it can scroll whatever the viewport, then moves it to `y` (a page
* behind a modal still scrolls by script). Answers the offset reached.
*/
async function scrollTreeTo(page: Page, y: number): Promise<number> {
await page.evaluate((top) => {
document.body.style.paddingBottom = '3000px'
window.scrollTo(0, top)
}, y)
const reached = await scrollY(page)
expect(reached).toBeGreaterThan(0)
return reached
}
async function expectScrollNear(page: Page, y: number) {
await expect
.poll(async () => Math.abs((await scrollY(page)) - y))
.toBeLessThanOrEqual(SCROLL_SLACK)
}
/** Whether the sheet is the dialog on top at the right edge of the viewport. */
const sheetOnTop = (page: Page) =>
page.evaluate(() => {
@@ -127,6 +152,9 @@ test.describe('the owner journey through the history', () => {
await expect(place(page, 'citations')).toBeVisible()
await expect(sheetHeaders(page)).toHaveCount(2)
await entryHolds(page, 'view.finding && view.finding.citations')
// The tree behind the dialogs sits at an offset of its own (the page is padded so it
// can scroll whatever the viewport): Back must return to it.
const left = await scrollTreeTo(page, 400)
// 5. « Tout afficher dans l'onglet Références »; 6. the tab filtered on A's two references.
await panel(page)
.getByRole('button', { name: dict['editor.references.panel_show_all'] })
@@ -141,6 +169,7 @@ test.describe('the owner journey through the history', () => {
await expect(
libraryRoot(page).getByText('2 références', { exact: true }),
).toBeVisible()
expect(Math.abs((await scrollY(page)) - left)).toBeGreaterThan(SCROLL_SLACK)
// 7. browser Back; 8. finding A with its sheet on top, as left.
await page.goBack()
await expect(dialogs(page)).toHaveCount(2)
@@ -148,6 +177,13 @@ test.describe('the owner journey through the history', () => {
await expect(findingDialog(page)).toContainText('Constat A')
expect(await sheetOnTop(page)).toBe(true)
await expect(sheetHeaders(page)).toHaveCount(2)
await expectScrollNear(page, left)
// Closed by Escape (sheet, then dialog): the tree stays where it was left.
await page.keyboard.press('Escape')
await expect(dialogs(page)).toHaveCount(1)
await page.keyboard.press('Escape')
await expectNoDialog(page)
await expectScrollNear(page, left)
})
test('eight steps: finding, sheet, filter, edit, Back, Forward, Revenir au constat, every Back', async ({