From c893dec60b85e7a95aeede1df8d33b05d21e436f Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 19:23:48 +0100 Subject: [PATCH] =?UTF-8?q?feat(editor):=20=C2=AB=20Aller=20=C3=A0=20?= =?UTF-8?q?=C2=BB=20opens=20the=20finding=20dialog,=20spec=20races=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit « Aller à » a finding shows its row and opens its dialog in view mode. E2e helpers wait for the history to settle after a layer or section pop; the layout walk waits out the write budget. Label rows for the nine new keys. --- apps/app/e2e/shell/editor-citations.spec.ts | 10 ++++++-- apps/app/e2e/shell/editor-deselect.spec.ts | 2 ++ .../e2e/shell/editor-shell-crossing.spec.ts | 1 + .../e2e/shell/editor-shell-journeys.spec.ts | 12 ++++++++++ .../app/e2e/shell/editor-shell-layout.spec.ts | 8 +++++++ apps/app/e2e/shell/editor-structures.spec.ts | 1 + apps/app/e2e/support/editor.ts | 22 ++++++++++++++++++ .../components/editor/tabs/FindingsTab.tsx | 3 +++ .../unit/editor-references-panel.test.tsx | 10 +++++++- docs/development/V1-2-6_R2_LABELS.md | 23 +++++++++++++++++++ 10 files changed, 89 insertions(+), 3 deletions(-) diff --git a/apps/app/e2e/shell/editor-citations.spec.ts b/apps/app/e2e/shell/editor-citations.spec.ts index ac1bbb47..f8d6db9b 100644 --- a/apps/app/e2e/shell/editor-citations.spec.ts +++ b/apps/app/e2e/shell/editor-citations.spec.ts @@ -434,7 +434,7 @@ for (const reduced of [false, true]) { await expect(page.locator('dialog[open]')).toHaveCount(2) }) - test('« Tout afficher » and « Aller à » land where the pending move says', async ({ + test('« Tout afficher » and « Aller à » land where the move says', async ({ page, }) => { test.setTimeout(150_000) @@ -450,7 +450,13 @@ for (const reduced of [false, true]) { .getByRole('button', { name: dict['editor.references.go_to'] }) .first() .click() - await expectNoDialog(page) + // 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) + await expect( + findingDialog(page).getByRole('heading', { name: 'Dysfonction A' }), + ).toBeVisible() + await closeFinding(page, dict) await expect( page.getByRole('treeitem', { name: /Dysfonction A/ }), ).toBeFocused() diff --git a/apps/app/e2e/shell/editor-deselect.spec.ts b/apps/app/e2e/shell/editor-deselect.spec.ts index 3c79a9cd..85a5a610 100644 --- a/apps/app/e2e/shell/editor-deselect.spec.ts +++ b/apps/app/e2e/shell/editor-deselect.spec.ts @@ -13,6 +13,7 @@ import { openEditor, expectNoDialog, findingDialog, + layersSettled, openCitations, pickAnnotation, place, @@ -234,6 +235,7 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { await expect(findingDialog(page)).toBeVisible() await page.keyboard.press('Escape') await expectNoDialog(page) + await layersSettled(page) await selectTab(page, dict, 'annotations') await expectKept(page, POINT) await box(page).focus() diff --git a/apps/app/e2e/shell/editor-shell-crossing.spec.ts b/apps/app/e2e/shell/editor-shell-crossing.spec.ts index b135f17d..a7d82654 100644 --- a/apps/app/e2e/shell/editor-shell-crossing.spec.ts +++ b/apps/app/e2e/shell/editor-shell-crossing.spec.ts @@ -200,6 +200,7 @@ test.describe('editor shell, width crossing (H)', () => { await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) await page.keyboard.press('Escape') await page + .locator('dialog[open]') .getByRole('button', { name: dict['editor.findings.discard'] }) .click() await expect(dialogs(page)).toHaveCount(0) diff --git a/apps/app/e2e/shell/editor-shell-journeys.spec.ts b/apps/app/e2e/shell/editor-shell-journeys.spec.ts index e927c488..907c42d8 100644 --- a/apps/app/e2e/shell/editor-shell-journeys.spec.ts +++ b/apps/app/e2e/shell/editor-shell-journeys.spec.ts @@ -4,8 +4,10 @@ import { expect, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { TABS, + closeFinding, draftTitle, editorActor, + findingDialog, historyButton, openEditor, place, @@ -239,6 +241,16 @@ test.describe('editor shell journeys (H)', () => { await selectTab(page, dict, 'verification') await goTo('Constat A') await expect(place(page, 'findings')).toBeVisible() + // The finding opens in its dialog, in view mode; closed, its row holds the focus. + await expect( + findingDialog(page).getByRole('heading', { name: 'Constat A' }), + ).toBeVisible() + await expect( + findingDialog(page).getByRole('button', { + name: dict['editor.findings.edit'], + }), + ).toBeVisible() + await closeFinding(page, dict) await expect(place(page, 'findings').locator(':focus')).toHaveCount(1) await selectTab(page, dict, 'verification') diff --git a/apps/app/e2e/shell/editor-shell-layout.spec.ts b/apps/app/e2e/shell/editor-shell-layout.spec.ts index 92d4f4d9..af9a2122 100644 --- a/apps/app/e2e/shell/editor-shell-layout.spec.ts +++ b/apps/app/e2e/shell/editor-shell-layout.spec.ts @@ -15,6 +15,7 @@ import { closeFinding, draftPath, expectNoDialog, + layersSettled, draftTitle, editorActor, historyButton, @@ -146,6 +147,9 @@ test.describe('editor shell layout (H)', () => { await expectNoHorizontalOverflow(page, `the sheet at ${width} px`) await closeCitations(page, dict) await closeFinding(page, dict) + // The walk is a script: about 20 history entries per width would pass the adapter's + // write budget (40 pushes in 10 s) over four widths. A person never does. + await page.waitForTimeout(4_000) } }) @@ -223,8 +227,10 @@ test.describe('editor shell layout (H)', () => { }) await openCitations(page, dict, 'Constat A') await page.keyboard.press('Escape') + await expect(place(page, 'citations')).toHaveCount(0) await page.keyboard.press('Escape') await expectNoDialog(page) + await layersSettled(page) await selectTab(page, dict, 'annotations') await expect(place(page, 'citations')).toHaveCount(0) await expect(page.getByTestId('annotation-canvas')).toBeVisible() @@ -382,8 +388,10 @@ test.describe('editor shell keyboard order (H)', () => { } expect(met.has('panel')).toBe(true) await page.keyboard.press('Escape') + await expect(place(page, 'citations')).toHaveCount(0) await page.keyboard.press('Escape') await expectNoDialog(page) + await layersSettled(page) await selectTab(page, dict, 'annotations') const after = await walk(page, 'side') expect(after.slice(0, 3)).toEqual(['tab', 'undo', 'redo']) diff --git a/apps/app/e2e/shell/editor-structures.spec.ts b/apps/app/e2e/shell/editor-structures.spec.ts index 2096e12d..4d0a59fd 100644 --- a/apps/app/e2e/shell/editor-structures.spec.ts +++ b/apps/app/e2e/shell/editor-structures.spec.ts @@ -326,6 +326,7 @@ test.describe('editor structures (A4)', () => { ).toBeVisible() await deleteDialog(page) .getByRole('button', { name: dict['editor.delete.close'], exact: true }) + .last() .click() await expect(page.locator('dialog[open]')).toHaveCount(1) await closeFinding(page, dict) diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts index 023ec5b1..e2465d18 100644 --- a/apps/app/e2e/support/editor.ts +++ b/apps/app/e2e/support/editor.ts @@ -362,6 +362,12 @@ export function place(page: Page, name: string): Locator { export async function backToDrawing(page: Page, dict: Dict) { await page.getByRole('button', { name: dict['editor.section.back'] }).click() await expect(place(page, 'annotations.drawing')).toBeVisible() + // The move pops its section entry from an effect: a click made before the pop lands + // would be undone by it (a user cannot be that quick, a script can). + await page.waitForFunction(() => { + const view = history.state?.usr?.editorEntry?.view + return !view || view.section === 'drawing' + }) } /** The Annotations tab on its drawing, whatever section it was left on. */ @@ -466,12 +472,27 @@ export async function openFinding( await expect(findingDialog(page)).toBeVisible() } +/** + * Waits for the history to settle on a view without the finding layer (or without its + * sheet): a close pops its entry from an effect, and a move made before the pop lands + * would be undone by it (a user cannot be that quick, a script can). + */ +export async function layersSettled(page: Page, keepDialog = false) { + await page.waitForFunction((dialogStays) => { + const view = history.state?.usr?.editorEntry?.view + if (!view) return true + if (dialogStays) return !view.finding?.citations + return view.finding === null + }, keepDialog) +} + /** Closes the finding dialog with its ✕ and waits until no dialog is left. */ export async function closeFinding(page: Page, dict: Dict) { await findingDialog(page) .getByRole('button', { name: dict['common.close'], exact: true }) .click() await expectNoDialog(page) + await layersSettled(page) } /** @@ -502,6 +523,7 @@ export async function closeCitations(page: Page, dict: Dict) { .click() await expect(place(page, 'citations')).toHaveCount(0) await expect(page.locator('dialog[open]')).toHaveCount(1) + await layersSettled(page, true) } /** The revision the server holds for the draft. */ diff --git a/apps/app/src/components/editor/tabs/FindingsTab.tsx b/apps/app/src/components/editor/tabs/FindingsTab.tsx index 30f2cc07..bf6c67fc 100644 --- a/apps/app/src/components/editor/tabs/FindingsTab.tsx +++ b/apps/app/src/components/editor/tabs/FindingsTab.tsx @@ -198,6 +198,9 @@ export default function FindingsTab({ const found = target.key && itemForKey(items, target.key) if (!found) return 'none' reveal(found) + // « Aller à » shows the element as its row selected and its dialog open in view + // mode; the row takes the focus again when the dialog is closed. + layer.open(found.item.key) setFocusId({ id: found.item.id }) return 'found' }) diff --git a/apps/app/tests/unit/editor-references-panel.test.tsx b/apps/app/tests/unit/editor-references-panel.test.tsx index c4ec722e..333db6be 100644 --- a/apps/app/tests/unit/editor-references-panel.test.tsx +++ b/apps/app/tests/unit/editor-references-panel.test.tsx @@ -351,13 +351,21 @@ describe.each(MODES)('closing, %s', (_label, reduced) => { expect(within(tabPanel).getAllByRole('listitem')).toHaveLength(3) }) - it('« Aller à » a citer from a panel tile closes it and lands on that finding', async () => { + it('« Aller à » a citer from a panel tile closes the sheet and opens that finding in its dialog', async () => { const user = await mount() await openFromFinding(user) await user.click(within(panel()).getByRole('button', { name: /^Barone/ })) const go = within(panel()).getAllByRole('button', { name: /^Aller à / }) await user.click(go[0]) await closed() + await waitFor(() => + expect( + inFindingDialog().getByRole('heading', { name: 'Cat A' }), + ).toBeVisible(), + ) + // Closed, the dialog hands the focus back to the row of that finding. + await user.click(inFindingDialog().getByRole('button', { name: 'Fermer' })) + await waitFor(() => expect(findingDialog()).toBeNull()) await focusIs(() => screen.getByRole('treeitem', { name: /Cat A/ })) }) diff --git a/docs/development/V1-2-6_R2_LABELS.md b/docs/development/V1-2-6_R2_LABELS.md index da5c9060..a451ebb5 100644 --- a/docs/development/V1-2-6_R2_LABELS.md +++ b/docs/development/V1-2-6_R2_LABELS.md @@ -114,3 +114,26 @@ Aucune n'est lue par le code (recherche faite sur `src`, `tests` et `e2e`, `edit et Échap abandonnent le brouillon sans rien écrire dans le document ni dans l'historique ; le focus revient à « Ajouter une référence ». Le libellé EN reste provisoire, en attente de validation du propriétaire. - **Aucun libellé EN ratifié.** Voir la note de tête. + +## 5. Finition du 2026-11-13 : dialogue des constats (tâche 2) + +Neuf clés nouvelles dans `fr.ts` et `en.ts` (une ligne chacune), une clé retirée. Les libellés EN sont provisoires, +comme tous les autres. + +| Clé | FR | EN (provisoire) | Où | +|---|---|---|---| +| `editor.findings.edit` | Modifier | Edit | Dialogue d'un constat, mode lecture, bouton | +| `editor.findings.save` | Enregistrer | Save | Dialogue, mode modification, une seule modification du document | +| `editor.findings.saved` | Modifications enregistrées | Changes saved | Dialogue, ligne d'état après un enregistrement | +| `editor.findings.discard_ask` | Abandonner les modifications ? | Discard your changes? | Dialogue, pied de confirmation d'une fermeture avec saisie | +| `editor.findings.keep_typing` | Continuer la saisie | Keep editing | Confirmation, bouton qui prend le focus | +| `editor.findings.discard` | Abandonner | Discard | Confirmation ; seul bouton restant quand l'éditeur est en lecture seule | +| `editor.findings.gone` | Ce constat n'existe plus | This finding no longer exists | Annonce quand l'élément d'un dialogue disparaît | +| `editor.findings.flip_narrow` | Élargissez la fenêtre pour poursuivre : votre saisie est conservée. | Widen the window to continue: your entry is kept. | Dialogue, formulaire gardé quand la largeur passe sous 1 024 px | +| `editor.findings.flip_blocked` | La modification n'est plus possible : votre saisie est conservée, vous pouvez seulement l'abandonner. | Editing is no longer possible: your entry is kept, you can only discard it. | Dialogue, formulaire gardé quand les droits, la revue ou l'archivage coupent l'édition | + +Retirée : `editor.live.references_closed` (« Références fermées »). La fermeture de la feuille n'est plus annoncée : le +focus revient sur « n références » et la lecture d'écran le dit. + +Comportement modifié : « Tout afficher dans l'onglet Références » vide la recherche et garde le tri (le tri était +remis à « Ordre de la fiche »).