feat(editor): header history, save line and Abandonner les modifications

Header Annuler/Retablir on every tab (aria-disabled, commit on pointerdown,
refused blur commit skips the undo). Save line: unsaved count selector
(savedDistance), saveLineState forms, server save time via readSaveTime
(lastSave in the store, never the browser clock). Discard relabelled and
names the stored copy. Tool column pair removed, glyphs in EditorGlyph.

Rewritten or removed assertions (R-24):
- editor-route.test: Revision 3 / unsaved text / Annuler les modifications
  -> save-line testid, Abandonner label, copy sentence in the dialog
- editor-route-conflict, editor-route-recovery: Revision n and copy_cap/
  copy_quota text queries -> save-line testid
- editor-no-loss: discard button label
- editor-annotations-tab: tool column undo/redo test -> no pair left
  (behaviour moved to editor-history-buttons.test)
- e2e journey/annotations/recovery/structures/support saveDraft/lan:
  undo/redo and revision/unsaved text -> historyButton, saveLine helpers;
  structures toHaveCount(0) on old text -> exact Revision n line
- editor-shell clickability: header Annuler/Retablir added
This commit is contained in:
bchanot committed 2026-11-08 17:55:49 +01:00
1 parent ab51ea764d
commit 99b669bf8f
29 files changed
+1397 -248

No files matched your search

+46 -10
View File
@@ -410,18 +410,54 @@ export async function serverDocument<T = Record<string, unknown>>(
) as T
}
/** Saves through « Enregistrer » and waits until the server revision line moves. */
/** The visible save line (the hidden status region is another element). */
export const saveLine = (page: Page) => page.getByTestId('save-line')
const withRevision = (text: string, revision: number) =>
text.replace('{revision}', String(revision))
/** « Révision n », the line of a draft with nothing saved in this session. */
export const revisionText = (dict: Dict, revision: number) =>
withRevision(dict['editor.draft.status.revision'], revision)
/** The unsaved line, with or without its count. */
export const UNSAVED_LINE = /non enregistrée|unsaved/i
/** « Enregistré · révision n », with or without the server's time of the save. */
export function savedLine(dict: Dict, revision: number): RegExp {
const escape = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const plain = escape(
withRevision(dict['editor.draft.status.saved'], revision),
)
const timed = escape(
withRevision(dict['editor.draft.status.saved_at'], revision),
)
return new RegExp(
`^(${plain}|${timed.replace('\\{time\\}', '\\d\\d:\\d\\d')})$`,
)
}
/** The header « Annuler » / « Rétablir » button (enabled ones take a plain click). */
export const historyButton = (page: Page, dict: Dict, kind: 'undo' | 'redo') =>
page.getByRole('button', {
name: dict[`editor.history.${kind}_title`],
exact: true,
})
/**
* Presses a button that may be `aria-disabled` at its box: Playwright's actionability
* treats `aria-disabled` as disabled, a person's pointer does not.
*/
export async function pressAtBox(page: Page, button: Locator) {
const box = await button.boundingBox()
if (!box) throw new Error('the button has no box')
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2)
}
/** Saves through « Enregistrer » and waits until the save line shows the new revision. */
export async function saveDraft(page: Page, dict: Dict, revision: number) {
await page.getByRole('button', { name: dict['common.save'] }).click()
await expect(
page.getByText(
dict['editor.draft.status.revision'].replace(
'{revision}',
String(revision),
),
{ exact: true },
),
).toBeVisible()
await expect(saveLine(page)).toHaveText(savedLine(dict, revision))
}
/** Client coordinates of a drawing point, through the overlay's own matrix. */