feat(editor): « Aller à » opens the finding dialog, spec races fixed

« 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.
This commit is contained in:
bchanot committed 2026-11-13 19:23:48 +01:00
1 parent 4731a3376a
commit c893dec60b
10 files changed
+89 -3

No files matched your search

+8 -2
View File
@@ -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()
@@ -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()
@@ -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)
@@ -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')
@@ -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'])
@@ -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)
+22
View File
@@ -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. */
@@ -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'
})
@@ -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/ }))
})
+23
View File
@@ -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 »).