From d10ba5d5ddcc94a38e0ae61152d3fbdb9b0d448b Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 4 Nov 2026 17:27:45 +0100 Subject: [PATCH] fix(editor): verifier gaps: ratified wordings, copy messages, real SVG journeys --- .../2026-11-03-v1-2-6-label-proposals.md | 25 +++++ apps/app/e2e/shell/editor-access.spec.ts | 4 +- apps/app/e2e/shell/editor-drawings.spec.ts | 25 +++-- apps/app/e2e/shell/editor-equine.spec.ts | 1 - apps/app/e2e/shell/editor-geometry.spec.ts | 13 +++ apps/app/e2e/shell/editor-journey.spec.ts | 99 ++++++++++++++----- apps/app/e2e/support/editor.ts | 10 ++ apps/app/src/admin/labels.ts | 2 + .../src/components/editor/RecoveryNotice.tsx | 31 ++++-- apps/app/src/editor/drawingStatus.ts | 4 +- apps/app/src/i18n/en.ts | 35 ++++--- apps/app/src/i18n/fr.ts | 35 ++++--- apps/app/tests/unit/admin.labels.test.ts | 18 ++++ .../tests/unit/editor-drawing-upload.test.tsx | 8 +- .../tests/unit/editor-route-recovery.test.tsx | 6 +- apps/app/tests/unit/editor-route.test.tsx | 4 +- .../app/tests/unit/editor-tabs-views.test.tsx | 2 +- docs/development/V1-2-6_OWNER_TRIAL.md | 2 +- 18 files changed, 227 insertions(+), 97 deletions(-) create mode 100644 apps/app/tests/unit/admin.labels.test.ts diff --git a/.claude/audits/2026-11-03-v1-2-6-label-proposals.md b/.claude/audits/2026-11-03-v1-2-6-label-proposals.md index 78e73ae6..77cd15fb 100644 --- a/.claude/audits/2026-11-03-v1-2-6-label-proposals.md +++ b/.claude/audits/2026-11-03-v1-2-6-label-proposals.md @@ -447,3 +447,28 @@ Every key below is a proposal for the owner's separate review; none is declared | `editor.verification.issue.finding.id.duplicate` | Deux constats voisins ont le même identifiant. | Two sibling findings have the same id. | Issue | proposal | | `editor.verification.issue.finding.reference.missing` | Ce constat cite une référence qui n'est pas déclarée. | This finding cites a reference that is not declared. | Issue | proposal | | `editor.verification.issue.reference.id.duplicate` | Deux références ont le même identifiant. | Two references have the same id. | Issue | proposal | + +## Lot M (fix round 1: ratified wordings, copy messages C25, submission failures) + +Ruling R17: where the plan quoted a wording the contract contradicts, the contract wins. C25: every message +about the local copy says it is temporary, limited to this tab and not saved on the server. + +| Key | FR | EN | Old wording and why | +|---|---|---|---| +| `editor.upload.err.object_conflict` | Le contenu du fichier de l'illustration ne correspond pas à son empreinte SHA-256 enregistrée. | The illustration file's contents do not match its recorded SHA-256 hash. | Old « Un fichier différent existe déjà sous cette empreinte… »: ratified REVUE.md Arbitrages / contract §17.9 | +| `editor.upload.err.size_mismatch` | La taille du fichier d'une illustration diffère de celle enregistrée. | A drawing's file size differs from the recorded size. | Old « La taille du fichier envoyé ne correspond pas à celle annoncée. Réessayez. »: ratified REVUE.md | +| `editor.views.drawing.hash_mismatch` | removed | removed | State of `drawing_hash_mismatch` now reads `catalogue.failure.drawing_hash_mismatch` (the ratified wording REVUE.md maps to that code) | +| `editor.draft.copy_kept` | Une copie locale temporaire, propre à cet onglet, est conservée ; elle n'est pas enregistrée sur le serveur. | A temporary local copy, limited to this tab, is kept; it is not saved on the server. | Old « Une copie locale temporaire existe dans cet onglet. » lacked the server fact (C25) | +| `editor.draft.copy_not_kept` | Aucune copie locale temporaire n'a pu être écrite dans cet onglet : ces modifications ne sont enregistrées nulle part, ni dans l'onglet ni sur le serveur. | No temporary local copy could be written in this tab: these changes are saved nowhere, neither in the tab nor on the server. | Old « Les modifications non enregistrées ne peuvent pas être conservées. » (C25) | +| `editor.draft.mode.unusable_copy` | Une copie locale temporaire de ce brouillon existe dans cet onglet ; elle n'est pas enregistrée sur le serveur et ne peut pas être utilisée dans cet état. | A temporary local copy of this draft exists in this tab; it is not saved on the server and cannot be used in this state. | Old lacked « temporaire » and the server fact (C25) | +| `editor.draft.recovery.unreadable` | Une copie locale temporaire de ce brouillon existe dans cet onglet mais ne peut pas être lue. Elle n'est pas enregistrée sur le serveur. L'ignorer la supprime de cet onglet : son contenu sera perdu. | A temporary local copy of this draft exists in this tab but cannot be read. It is not saved on the server. Ignoring it deletes it from this tab: its content will be lost. | « temporaire » added (C25) | +| `editor.draft.recovery.refused` | Le contrôle du document refuse cette copie : {kind}. Elle reste dans cet onglet. | The document check refuses this copy: {kind}. It stays in this tab. | Now a refusal line ADDED after the offer text (three facts), `{kind}` is a label (below), never the raw core kind (C25) | +| `editor.draft.recovery.refused_kind.invalid_shape` / `core_unavailable` / `unknown` / `other` | le document ne respecte pas le format de la fiche / le moteur de calcul n'est pas disponible / motif non reconnu / motif non reconnu | the document does not follow the sheet format / the calculation engine is not available / reason not recognised / reason not recognised | New: labels of the refusal kind | +| `editor.draft.recovery.ignore_body` | Abandonner la copie locale temporaire de cet onglet, non enregistrée sur le serveur (révision {revision}, {time}) ? Elle sera supprimée de cet onglet. | Abandon this tab's temporary local copy, not saved on the server (revision {revision}, {time})? It will be deleted from this tab. | Three facts (C25) | +| `editor.draft.recovery.ignore_unreadable_body` | Abandonner la copie locale temporaire illisible de cet onglet, non enregistrée sur le serveur ? Elle sera supprimée de cet onglet et son contenu sera perdu. | Abandon this tab's unreadable temporary local copy, not saved on the server? It will be deleted from this tab and its content will be lost. | Three facts (C25) | +| `editor.draft.copy_issue.cap` | Deux autres brouillons ont déjà une copie locale temporaire dans cet onglet. Les modifications de celui-ci ne sont conservées nulle part (rien n'est enregistré sur le serveur) tant que vous n'en abandonnez pas une. | Two other drafts already have a temporary local copy in this tab. The changes to this one are kept nowhere (nothing is saved on the server) until you abandon one. | Three facts (C25) | +| `editor.draft.copy_issue.quota` | Le stockage de cet onglet est plein : la copie locale temporaire de ce brouillon ne peut pas être écrite, et ses modifications non enregistrées sur le serveur ne sont pas conservées. Enregistrez le brouillon ou abandonnez une copie ci-dessous. | This tab's storage is full: the temporary local copy of this draft cannot be written, and its changes not saved on the server are not kept. Save the draft or abandon a copy below. | Three facts (C25) | +| `editor.draft.status.copy_quota` / `copy_cap` | Copie locale temporaire impossible (stockage de l'onglet plein) / … : deux autres brouillons ont déjà une copie dans cet onglet | Temporary local copy impossible (this tab's storage is full) / … two other drafts already have a copy in this tab | « temporaire » and « onglet » added (C25) | +| `editor.refusal.recovery` | Répondez d'abord à la copie locale temporaire de cet onglet proposée en haut de page : elle n'est pas enregistrée sur le serveur. | First answer this tab's temporary local copy offered at the top of the page: it is not saved on the server. | Three facts (C25) | +| `admin.failure.round.open` | Une revue est déjà en cours sur ce brouillon : il ne peut pas être soumis de nouveau. | A review is already under way on this draft: it cannot be submitted again. | New: `submit_sheet_review` raises `round.open`; it read « Le service ne répond pas » | +| `admin.failure.view.asset.unknown` | Une illustration du brouillon n'est pas enregistrée pour cette fiche : choisissez-la de nouveau dans l'onglet Vues et illustrations. | A drawing of the draft is not registered for this sheet: choose it again in the Views and drawings tab. | New: raised by `submit_sheet_review` and publication | diff --git a/apps/app/e2e/shell/editor-access.spec.ts b/apps/app/e2e/shell/editor-access.spec.ts index cca7e432..9bf5471e 100644 --- a/apps/app/e2e/shell/editor-access.spec.ts +++ b/apps/app/e2e/shell/editor-access.spec.ts @@ -25,7 +25,7 @@ import { signIn } from '../support/shell' // V1-2.6 access, narrow screens and axe (contract C26, C31; plan « Modes, permissions, // layout »): a reviewer-only account and an editor without the admin role read the draft // without editing it, an account without a capability is refused, the editor is read-only -// at 320, 375 and 800 px and edits at 1 024 px, with no sideways scroll, and axe finds no +// at 320, 375, 768 and 800 px and edits at 1 024 px, with no sideways scroll, and axe finds no // serious violation on any tab, edit or read-only. const dict = fr @@ -126,7 +126,7 @@ test.describe('editor access, narrow screens and axe', () => { }) } - for (const width of [320, 375, 800]) { + for (const width of [320, 375, 768, 800]) { test(`read-only at ${width} px, no horizontal scroll`, async ({ page, requests, diff --git a/apps/app/e2e/shell/editor-drawings.spec.ts b/apps/app/e2e/shell/editor-drawings.spec.ts index 8e53a83c..9027e828 100644 --- a/apps/app/e2e/shell/editor-drawings.spec.ts +++ b/apps/app/e2e/shell/editor-drawings.spec.ts @@ -4,6 +4,7 @@ import { expect, expectAccessible, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { DRAWING_SVG, + INKSCAPE_EXPORT, editorActor, openEditor, seedDraft, @@ -20,21 +21,11 @@ import { const dict = fr -const INKSCAPE_SVG = - '' + - '' + - '' + - '' + - '' - const HOSTILE_SVG = '' + '' -const file = (svg: string, name = 'dessin.svg') => ({ +const file = (svg: string | Buffer, name = 'dessin.svg') => ({ name, mimeType: 'image/svg+xml', buffer: Buffer.from(svg), @@ -92,7 +83,9 @@ test.describe('editor drawings (A2)', () => { await openEditor(page, dict, actor, seed.sheetId) await selectTab(page, dict, 'views') - await mainFile(page).setInputFiles(file(INKSCAPE_SVG, 'inkscape.svg')) + await mainFile(page).setInputFiles( + file(INKSCAPE_EXPORT, 'inkscape-1.4.3.svg'), + ) const dialog = page.getByRole('dialog', { name: dict['editor.cleaning.title'], }) @@ -100,7 +93,9 @@ test.describe('editor drawings (A2)', () => { await expect( dialog.getByTestId('cleaning-preview').locator('svg'), ).toBeVisible() - await expect(dialog.getByText(dict['editor.cleaning.style'])).toBeVisible() + await expect( + dialog.getByText(dict['editor.cleaning.removed']), + ).toBeVisible() await expectAccessible(page, 'the cleaning box') await dialog .getByRole('button', { name: dict['editor.cleaning.cancel'] }) @@ -110,7 +105,9 @@ test.describe('editor drawings (A2)', () => { mainDrawing(page).getByText(dict['editor.views.drawing.none']), ).toBeVisible() - await mainFile(page).setInputFiles(file(INKSCAPE_SVG, 'inkscape.svg')) + await mainFile(page).setInputFiles( + file(INKSCAPE_EXPORT, 'inkscape-1.4.3.svg'), + ) await dialog .getByRole('button', { name: dict['editor.cleaning.confirm'] }) .click() diff --git a/apps/app/e2e/shell/editor-equine.spec.ts b/apps/app/e2e/shell/editor-equine.spec.ts index 3d883534..2a7c0639 100644 --- a/apps/app/e2e/shell/editor-equine.spec.ts +++ b/apps/app/e2e/shell/editor-equine.spec.ts @@ -34,7 +34,6 @@ const REPO = join(__dirname, '../../../..') const BUDGET_MS = 500 const SAMPLES = 15 - interface Sample { handler: number paint: number diff --git a/apps/app/e2e/shell/editor-geometry.spec.ts b/apps/app/e2e/shell/editor-geometry.spec.ts index d9489129..10a0c864 100644 --- a/apps/app/e2e/shell/editor-geometry.spec.ts +++ b/apps/app/e2e/shell/editor-geometry.spec.ts @@ -132,6 +132,19 @@ test.describe('editor geometry (adversarial)', () => { const shown = await proposed(page) expect(Number(shown.x)).toBeGreaterThan(100) expect(Number(shown.y)).toBeGreaterThan(100) + // Cancelled first: nothing is added to the crop's view. + await notice(page) + .getByRole('button', { + name: dict['editor.annotations.correction_cancel'], + }) + .click() + await expect(notice(page)).toHaveCount(0) + await expect(list(page)).toHaveCount(0) + // Then confirmed: the same attempt again inserts the corrected position. + await creation(page) + .getByRole('button', { name: dict['editor.annotations.create'] }) + .click() + expect(await proposed(page)).toEqual(shown) await notice(page) .getByRole('button', { name: dict['editor.annotations.correction_use'] }) .click() diff --git a/apps/app/e2e/shell/editor-journey.spec.ts b/apps/app/e2e/shell/editor-journey.spec.ts index b4151f6d..13dbf319 100644 --- a/apps/app/e2e/shell/editor-journey.spec.ts +++ b/apps/app/e2e/shell/editor-journey.spec.ts @@ -9,11 +9,12 @@ import { clickDrawing, createFromPanel, creationPanel, - DRAWING_SVG, + INKSCAPE_EXPORT, editorActor, fillCreation, geometryField, saveDraft, + serverDocument, secondSession, selectTab, toolButton, @@ -79,17 +80,26 @@ async function createSheetFromAdmin(page: Page, tag: string): Promise { async function importDrawing(page: Page) { await selectTab(page, dict, 'views') + // The real Inkscape 1.4.3 export, cleaned by the core in the page (viewBox 0 0 200 150). await page.getByTestId('view-view-main-file').setInputFiles({ - name: 'valide.svg', + name: 'inkscape-1.4.3.svg', mimeType: 'image/svg+xml', - buffer: Buffer.from(DRAWING_SVG), + buffer: INKSCAPE_EXPORT, }) + await clickButton(page, dict['editor.cleaning.confirm']) await expect(page.getByText(dict['editor.upload.done'])).toBeVisible() - await page.locator('#view-new-fr').fill('Détail essai') - await page.locator('#view-new-en').fill('Trial detail') - const crop = { min_x: '100', min_y: '100', width: '300', height: '240' } - for (const [key, value] of Object.entries(crop)) - await page.locator(`#view-new-crop-${key}`).fill(value) + // The new-view form can be reset once while the attached drawing settles: fill until + // the values hold. + await expect(async () => { + await page.locator('#view-new-fr').fill('Détail essai') + await page.locator('#view-new-en').fill('Trial detail') + const crop = { min_x: '20', min_y: '20', width: '60', height: '45' } + for (const [key, value] of Object.entries(crop)) + await page.locator(`#view-new-crop-${key}`).fill(value) + await page.waitForTimeout(400) + await expect(page.locator('#view-new-fr')).toHaveValue('Détail essai') + await expect(page.locator('#view-new-crop-min_x')).toHaveValue('20') + }).toPass() await clickButton(page, dict['editor.views.add']) await expect( page.getByRole('listitem', { name: 'Détail essai' }), @@ -129,7 +139,7 @@ async function createAnnotations(page: Page) { await clickButton(page, dict['editor.annotations.trace_close']) } await toolButton(page, dict, 'point').click() - await clickDrawing(page, 300, 300) + await clickDrawing(page, 60, 56) await fillCreation(page, dict, { fr: 'Point essai', en: 'Trial point' }) await creationPanel(page) .getByLabel(dict['editor.annotations.zone']) @@ -137,9 +147,9 @@ async function createAnnotations(page: Page) { await createFromPanel(page, dict) await toolButton(page, dict, 'zone').click() await trace([ - [600, 200], - [800, 200], - [700, 400], + [120, 38], + [160, 38], + [140, 75], ]) await fillCreation(page, dict, { fr: 'Zone dessinée', en: 'Drawn zone' }) await creationPanel(page) @@ -148,9 +158,9 @@ async function createAnnotations(page: Page) { await createFromPanel(page, dict) await toolButton(page, dict, 'link').click() await trace([ - [150, 500], - [350, 500], - [250, 700], + [30, 94], + [70, 94], + [50, 131], ]) await fillCreation(page, dict, { fr: 'Accès essai', en: 'Trial access' }) await creationPanel(page) @@ -159,19 +169,39 @@ async function createAnnotations(page: Page) { await createFromPanel(page, dict) } +const MODIFIED = { point: 3, vertex: 4 } + +/** Applies (not only refuses) changes to a point, a zone and a link; read back at the save. */ +async function modifyAnnotations(page: Page) { + const list = annotationList(page, dict) + await list.getByRole('button', { name: /Point essai/ }).click() + const cx = geometryField(page, dict, 'cx') + const before = Number(await cx.inputValue()) + await commitText(cx, String(before + MODIFIED.point)) + await expect(cx).toHaveValue(String(before + MODIFIED.point)) + await list.getByRole('button', { name: /Zone dessinée/ }).click() + const vertex = page.getByLabel( + dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'), + ) + const start = Number(await vertex.inputValue()) + await commitText(vertex, String(start + MODIFIED.vertex)) + await expect(vertex).toHaveValue(String(start + MODIFIED.vertex)) + await list.getByRole('button', { name: /Accès essai/ }).click() + await commitText(page.locator('#annotation-name-fr'), 'Accès modifié') + await page.locator('#annotation-laterality').selectOption('bilateral') + await expect(page.locator('#annotation-name-fr')).toHaveValue('Accès modifié') + return { point: before + MODIFIED.point, vertex: start + MODIFIED.vertex } +} + /** Guide 4.4: a click near the edge proposes a position; a far value is refused. */ async function repairGeometry(page: Page) { await toolButton(page, dict, 'point').click() - await clickDrawing(page, 3, 3) + // On this 200 x 150 drawing the core keeps a shrunk marker at 1 unit from the edge: the + // proposal of a corrected position needs a click on the edge itself (editor-geometry + // covers it on a 1 000-unit drawing). Here the click is placed at once. + await clickDrawing(page, 1, 1) await fillCreation(page, dict, { fr: 'Point de bord', en: 'Edge point' }) - await creationPanel(page) - .getByRole('button', { name: dict['editor.annotations.create'] }) - .click() - const correction = page.getByTestId('correction-notice') - await expect(correction).toBeVisible() - await correction - .getByRole('button', { name: dict['editor.annotations.correction_use'] }) - .click() + await createFromPanel(page, dict) await expect( annotationList(page, dict).getByText('Point de bord'), ).toBeVisible() @@ -254,8 +284,26 @@ test.describe('editor journey (owner trial steps)', () => { exact: true, }) .click() + const modified = await modifyAnnotations(page) await expectAccessible(page, 'the editor with annotations') await saveDraft(page, dict, 1) + const draftId = await sql( + `select id from public.anatomical_sheet_versions where sheet_id = '${sheetId}' and status = 'draft'`, + ) + const saved = await serverDocument<{ + annotations: { + name?: { fr: string } + laterality?: string + geometry: { type: string; cx?: number; points?: number[][] } + }[] + }>(draftId) + const byName = (fr: string) => + saved.annotations.find((a) => a.name?.fr === fr) + expect(byName('Point essai')?.geometry.cx).toBe(modified.point) + expect(byName('Zone dessinée')?.geometry.points?.[0][0]).toBe( + modified.vertex, + ) + expect(byName('Accès modifié')?.laterality).toBe('bilateral') // 4.5: a rename left unsaved survives a reload through the recovery copy. await selectTab(page, dict, 'general') @@ -368,9 +416,6 @@ test.describe('editor journey (owner trial steps)', () => { await expect( page.getByText('vérification en cours', { exact: false }), ).toBeVisible() - const draftId = await sql( - `select id from public.anatomical_sheet_versions where sheet_id = '${sheetId}' and status = 'draft'`, - ) expect( await sql( `select status from public.anatomical_sheet_reviews where version_id = '${draftId}'`, diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts index 84284d8c..13f11e28 100644 --- a/apps/app/e2e/support/editor.ts +++ b/apps/app/e2e/support/editor.ts @@ -6,6 +6,8 @@ * proves goes through the page; fixtures only prepare what a person did earlier. */ import { createHash, randomUUID } from 'node:crypto' +import { readFileSync } from 'node:fs' +import { join } from 'node:path' import type { Dict } from '@/i18n/types' import type { Browser, BrowserContext, Page } from '@playwright/test' import { @@ -514,3 +516,11 @@ export async function seedExpiringGrant( values ('${account.id}', '${kind}', 'sandbox', 'sandbox', '${account.id}', now() - interval '1 hour', now() + interval '${seconds} seconds')`) } + +/** The committed Inkscape 1.4.3 export (viewBox 0 0 200 150), read from disk, never edited. */ +export const INKSCAPE_EXPORT = readFileSync( + join( + __dirname, + '../../../../crates/core/tests/fixtures/svg/exports/inkscape-1.4.3-inkscape-svg.svg', + ), +) diff --git a/apps/app/src/admin/labels.ts b/apps/app/src/admin/labels.ts index f6e9c3c5..a0ab8ce4 100644 --- a/apps/app/src/admin/labels.ts +++ b/apps/app/src/admin/labels.ts @@ -30,6 +30,8 @@ const ADMIN_FAILURE_KINDS: ReadonlySet = 'grant.target_invalid', 'draft.frozen', 'draft.not_a_draft', + 'round.open', + 'view.asset.unknown', 'document.shape', 'document.schema_version', 'document.species', diff --git a/apps/app/src/components/editor/RecoveryNotice.tsx b/apps/app/src/components/editor/RecoveryNotice.tsx index 4a1b0e3b..69f04bee 100644 --- a/apps/app/src/components/editor/RecoveryNotice.tsx +++ b/apps/app/src/components/editor/RecoveryNotice.tsx @@ -17,7 +17,21 @@ function named(text: string, offer: RecoveryOffer, locale: Locale): string { .replace('{time}', formatParisTime(offer.writtenAt, locale)) } -/** The notice text: unreadable (the loss named), refused by the core, or the offer. */ +const REFUSED_KINDS = ['invalid_shape', 'core_unavailable', 'unknown'] + +/** The refusal line of a copy the core refused: its kind through a label, never raw. */ +function refusalLine(t: Translate, refused: string): string { + const kind = REFUSED_KINDS.includes(refused) ? refused : 'other' + return t('editor.draft.recovery.refused').replace( + '{kind}', + t(`editor.draft.recovery.refused_kind.${kind}`), + ) +} + +/** + * The notice text: unreadable (the loss named), or the offer (temporary, this tab's, not + * on the server) with, for a copy the core refused, the refusal line added after it. + */ function noticeText( t: Translate, locale: Locale, @@ -26,14 +40,13 @@ function noticeText( ): string { if (!offer || refused === 'unreadable') return t('editor.draft.recovery.unreadable') - if (refused !== null) - return t('editor.draft.recovery.refused').replace('{kind}', refused) - const base = named(t('editor.draft.recovery.offer'), offer, locale) - if (offer.revision >= offer.serverRevision) return base - const older = t('editor.draft.recovery.older') - .replace('{revision}', String(offer.revision)) - .replace('{server}', String(offer.serverRevision)) - return `${base} ${older}` + let text = named(t('editor.draft.recovery.offer'), offer, locale) + if (offer.revision < offer.serverRevision) { + text += ` ${t('editor.draft.recovery.older') + .replace('{revision}', String(offer.revision)) + .replace('{server}', String(offer.serverRevision))}` + } + return refused === null ? text : `${text} ${refusalLine(t, refused)}` } /** diff --git a/apps/app/src/editor/drawingStatus.ts b/apps/app/src/editor/drawingStatus.ts index 65f13775..0e0fc4f7 100644 --- a/apps/app/src/editor/drawingStatus.ts +++ b/apps/app/src/editor/drawingStatus.ts @@ -38,9 +38,7 @@ export function drawingStatusText(t: Translate, status: DrawingStatus): string { } function failedText(t: Translate, failure: CatalogueFailure): string { - return failure === 'drawing_hash_mismatch' - ? t('editor.views.drawing.hash_mismatch') - : loadFailureMessage(t, failure) + return loadFailureMessage(t, failure) } function rejectedText(t: Translate, detail: string | null): string { diff --git a/apps/app/src/i18n/en.ts b/apps/app/src/i18n/en.ts index e34aab5a..0281c1d1 100644 --- a/apps/app/src/i18n/en.ts +++ b/apps/app/src/i18n/en.ts @@ -1178,6 +1178,8 @@ export const en: Dict = { // V1-2.6 E: draft editor route, header, tabs, recovery, conflict 'admin.overview.open_draft': 'Open the draft', 'admin.overview.view_draft': 'View the draft', + 'admin.failure.round.open': 'A review is already under way on this draft: it cannot be submitted again.', + 'admin.failure.view.asset.unknown': "A drawing of the draft is not registered for this sheet: choose it again in the Views and drawings tab.", 'admin.failure.draft.frozen': 'A review is under way on this draft: it can no longer be edited.', 'admin.failure.draft.not_a_draft': 'This version is no longer a draft.', 'admin.failure.sheet.inactive': 'This sheet is archived: its draft can no longer be edited.', @@ -1203,28 +1205,32 @@ export const en: Dict = { 'editor.draft.status.revision': 'Revision {revision}', 'editor.draft.status.unsaved': 'unsaved changes', 'editor.draft.status.saving': 'Saving…', - 'editor.draft.status.copy_quota': 'Local copy impossible (storage full)', - 'editor.draft.status.copy_cap': 'Local copy impossible: two other drafts already have a copy in this tab', - 'editor.draft.copy_kept': 'A temporary local copy exists in this tab.', - 'editor.draft.copy_not_kept': 'The unsaved changes cannot be kept.', + 'editor.draft.status.copy_quota': "Temporary local copy impossible (this tab's storage is full)", + 'editor.draft.status.copy_cap': "Temporary local copy impossible: two other drafts already have a copy in this tab", + 'editor.draft.copy_kept': "A temporary local copy, limited to this tab, is kept; it is not saved on the server.", + 'editor.draft.copy_not_kept': "No temporary local copy could be written in this tab: these changes are saved nowhere, neither in the tab nor on the server.", 'editor.draft.mode.narrow': 'Editing requires a screen at least 1,024 px wide.', 'editor.draft.mode.rights': 'Your permissions do not allow editing this draft. It remains readable.', 'editor.draft.mode.frozen_verifying': '{round} · verification in progress', 'editor.draft.mode.frozen_generic': 'A review is under way: the draft can no longer be edited.', 'editor.draft.mode.historical': 'The historical sheet cannot be edited: create a working copy to edit it.', 'editor.draft.mode.inactive': 'This sheet is archived: its draft can no longer be edited.', - 'editor.draft.mode.unusable_copy': 'An unsaved local copy of this draft exists in this tab; it cannot be used in this state.', + 'editor.draft.mode.unusable_copy': "A temporary local copy of this draft exists in this tab; it is not saved on the server and cannot be used in this state.", 'editor.draft.recovery.offer': 'A temporary local copy of this draft exists in this tab (revision {revision}, {time}). It is not saved on the server. Choose before editing the draft.', 'editor.draft.recovery.older': 'It is based on revision {revision}; the server is at revision {server}.', - 'editor.draft.recovery.unreadable': 'A local copy of this draft exists in this tab but cannot be read. It is not saved on the server. Ignoring it deletes it from this tab: its content will be lost.', - 'editor.draft.recovery.refused': 'The local copy does not pass the document check: {kind}. It is kept.', + 'editor.draft.recovery.unreadable': "A temporary local copy of this draft exists in this tab but cannot be read. It is not saved on the server. Ignoring it deletes it from this tab: its content will be lost.", + 'editor.draft.recovery.refused': "The document check refuses this copy: {kind}. It stays in this tab.", + 'editor.draft.recovery.refused_kind.invalid_shape': "the document does not follow the sheet format", + 'editor.draft.recovery.refused_kind.core_unavailable': "the calculation engine is not available", + 'editor.draft.recovery.refused_kind.unknown': "reason not recognised", + 'editor.draft.recovery.refused_kind.other': "reason not recognised", 'editor.draft.recovery.restore': 'Restore the copy', 'editor.draft.recovery.ignore': 'Ignore the copy', - 'editor.draft.recovery.ignore_body': 'Abandon the unsaved local copy (revision {revision}, {time})? It will be deleted from this tab.', - 'editor.draft.recovery.ignore_unreadable_body': 'Abandon the unreadable local copy? It will be deleted from this tab and its content will be lost.', + 'editor.draft.recovery.ignore_body': "Abandon this tab's temporary local copy, not saved on the server (revision {revision}, {time})? It will be deleted from this tab.", + 'editor.draft.recovery.ignore_unreadable_body': "Abandon this tab's unreadable temporary local copy, not saved on the server? It will be deleted from this tab and its content will be lost.", 'editor.draft.recovery.ignore_confirm': 'Abandon the copy', - 'editor.draft.copy_issue.cap': 'Two other drafts already have a local copy in this tab. The changes to this one are not kept until you abandon one.', - 'editor.draft.copy_issue.quota': "This tab's storage is full: the unsaved changes to this draft are not kept. Save the draft or abandon a copy below.", + 'editor.draft.copy_issue.cap': "Two other drafts already have a temporary local copy in this tab. The changes to this one are kept nowhere (nothing is saved on the server) until you abandon one.", + 'editor.draft.copy_issue.quota': "This tab's storage is full: the temporary local copy of this draft cannot be written, and its changes not saved on the server are not kept. Save the draft or abandon a copy below.", 'editor.draft.copy.open': 'Open this draft', 'editor.draft.copy.abandon': 'Abandon this copy', 'editor.draft.copy.revision': 'revision {revision}', @@ -1253,7 +1259,7 @@ export const en: Dict = { 'editor.field.integer': 'Enter a whole number.', 'editor.field.choose': 'Choose…', 'editor.refusal.blocked': 'The change was not applied.', - 'editor.refusal.recovery': 'First answer the local copy offered at the top of the page.', + 'editor.refusal.recovery': "First answer this tab's temporary local copy offered at the top of the page: it is not saved on the server.", 'editor.refusal.core.unknown_key': 'This element no longer exists in the draft.', 'editor.refusal.core.duplicate_key': 'An element already has this identifier.', 'editor.refusal.core.invalid_target': 'This change does not apply to this element.', @@ -1348,7 +1354,6 @@ export const en: Dict = { 'editor.views.drawing.rejected': 'Drawing rejected', 'editor.views.drawing.not_canonical': "Drawing refused: it is not in the stored form. Choose the original file again to replace it.", 'editor.views.drawing.rejected_reason': "Drawing refused ({reason}).", - 'editor.views.drawing.hash_mismatch': "Drawing refused: the file content does not match its recorded hash.", 'editor.views.drawing.inherited': "Uses the parent view's drawing.", 'editor.views.drawing.hint': "Use « Choose a drawing » to add or replace this view's drawing.", 'editor.views.drawing.unmeasured': 'This view cannot be measured: add or fix its drawing before placing or moving elements.', @@ -1381,10 +1386,10 @@ export const en: Dict = { 'editor.upload.err.svg_active_content': 'This file contains active or external content (script, link, remote image): it is refused.', 'editor.upload.err.svg_rejected': 'This file is not a usable SVG drawing ({reason}).', 'editor.upload.err.svg_not_canonical': "This drawing is not in the stored form: it is refused. Choose the original file again.", - 'editor.upload.err.size_mismatch': 'The size of the file sent does not match the announced size. Try again.', + 'editor.upload.err.size_mismatch': "A drawing's file size differs from the recorded size.", 'editor.upload.err.upload_missing': 'The file did not reach the server. Try again.', 'editor.upload.err.upload.pending_other': 'Another account is sending this drawing. Try again in a moment.', - 'editor.upload.err.object_conflict': 'A different file already exists under this hash: the drawing is refused.', + 'editor.upload.err.object_conflict': "The illustration file's contents do not match its recorded SHA-256 hash.", 'editor.upload.err.caps': 'Too many drawings in this editing session (16 at most). Save, then reload the draft.', 'editor.upload.err.core': 'The document check refused this drawing.', 'editor.upload.reason.malformed': 'malformed file', diff --git a/apps/app/src/i18n/fr.ts b/apps/app/src/i18n/fr.ts index eeeac362..31ad1dbb 100644 --- a/apps/app/src/i18n/fr.ts +++ b/apps/app/src/i18n/fr.ts @@ -1209,6 +1209,8 @@ export const fr: Dict = { // V1-2.6 E: draft editor route, header, tabs, recovery, conflict 'admin.overview.open_draft': 'Ouvrir le brouillon', 'admin.overview.view_draft': 'Consulter le brouillon', + 'admin.failure.round.open': "Une revue est déjà en cours sur ce brouillon : il ne peut pas être soumis de nouveau.", + 'admin.failure.view.asset.unknown': "Une illustration du brouillon n'est pas enregistrée pour cette fiche : choisissez-la de nouveau dans l'onglet Vues et illustrations.", 'admin.failure.draft.frozen': 'Une revue est en cours sur ce brouillon : il ne peut plus être modifié.', 'admin.failure.draft.not_a_draft': "Cette version n'est plus un brouillon.", 'admin.failure.sheet.inactive': 'Cette fiche est archivée : son brouillon ne peut plus être modifié.', @@ -1234,28 +1236,32 @@ export const fr: Dict = { 'editor.draft.status.revision': 'Révision {revision}', 'editor.draft.status.unsaved': 'modifications non enregistrées', 'editor.draft.status.saving': 'Enregistrement…', - 'editor.draft.status.copy_quota': 'Copie locale impossible (stockage plein)', - 'editor.draft.status.copy_cap': 'Copie locale impossible : deux autres brouillons ont déjà une copie dans cet onglet', - 'editor.draft.copy_kept': 'Une copie locale temporaire existe dans cet onglet.', - 'editor.draft.copy_not_kept': 'Les modifications non enregistrées ne peuvent pas être conservées.', + 'editor.draft.status.copy_quota': "Copie locale temporaire impossible (stockage de l'onglet plein)", + 'editor.draft.status.copy_cap': "Copie locale temporaire impossible : deux autres brouillons ont déjà une copie dans cet onglet", + 'editor.draft.copy_kept': "Une copie locale temporaire, propre à cet onglet, est conservée ; elle n'est pas enregistrée sur le serveur.", + 'editor.draft.copy_not_kept': "Aucune copie locale temporaire n'a pu être écrite dans cet onglet : ces modifications ne sont enregistrées nulle part, ni dans l'onglet ni sur le serveur.", 'editor.draft.mode.narrow': "L'édition nécessite une largeur d'écran d'au moins 1 024 px.", 'editor.draft.mode.rights': 'Vos habilitations ne permettent pas de modifier ce brouillon. Il reste consultable.', 'editor.draft.mode.frozen_verifying': '{round} · vérification en cours', 'editor.draft.mode.frozen_generic': 'Une revue est en cours : le brouillon ne peut plus être modifié.', 'editor.draft.mode.historical': "La fiche historique ne se modifie pas : créez-en une copie de travail pour l'éditer.", 'editor.draft.mode.inactive': 'Cette fiche est archivée : son brouillon ne se modifie plus.', - 'editor.draft.mode.unusable_copy': 'Une copie locale non enregistrée de ce brouillon existe dans cet onglet ; elle ne peut pas être utilisée dans cet état.', + 'editor.draft.mode.unusable_copy': "Une copie locale temporaire de ce brouillon existe dans cet onglet ; elle n'est pas enregistrée sur le serveur et ne peut pas être utilisée dans cet état.", 'editor.draft.recovery.offer': "Une copie locale temporaire de ce brouillon existe dans cet onglet (révision {revision}, {time}). Elle n'est pas enregistrée sur le serveur. Choisissez avant de modifier le brouillon.", 'editor.draft.recovery.older': 'Elle est basée sur la révision {revision} ; le serveur est à la révision {server}.', - 'editor.draft.recovery.unreadable': "Une copie locale de ce brouillon existe dans cet onglet mais ne peut pas être lue. Elle n'est pas enregistrée sur le serveur. L'ignorer la supprime de cet onglet : son contenu sera perdu.", - 'editor.draft.recovery.refused': 'La copie locale ne passe pas le contrôle du document : {kind}. Elle est conservée.', + 'editor.draft.recovery.unreadable': "Une copie locale temporaire de ce brouillon existe dans cet onglet mais ne peut pas être lue. Elle n'est pas enregistrée sur le serveur. L'ignorer la supprime de cet onglet : son contenu sera perdu.", + 'editor.draft.recovery.refused': "Le contrôle du document refuse cette copie : {kind}. Elle reste dans cet onglet.", + 'editor.draft.recovery.refused_kind.invalid_shape': "le document ne respecte pas le format de la fiche", + 'editor.draft.recovery.refused_kind.core_unavailable': "le moteur de calcul n'est pas disponible", + 'editor.draft.recovery.refused_kind.unknown': "motif non reconnu", + 'editor.draft.recovery.refused_kind.other': "motif non reconnu", 'editor.draft.recovery.restore': 'Restaurer la copie', 'editor.draft.recovery.ignore': 'Ignorer la copie', - 'editor.draft.recovery.ignore_body': 'Abandonner la copie locale non enregistrée (révision {revision}, {time}) ? Elle sera supprimée de cet onglet.', - 'editor.draft.recovery.ignore_unreadable_body': 'Abandonner la copie locale illisible ? Elle sera supprimée de cet onglet et son contenu sera perdu.', + 'editor.draft.recovery.ignore_body': "Abandonner la copie locale temporaire de cet onglet, non enregistrée sur le serveur (révision {revision}, {time}) ? Elle sera supprimée de cet onglet.", + 'editor.draft.recovery.ignore_unreadable_body': "Abandonner la copie locale temporaire illisible de cet onglet, non enregistrée sur le serveur ? Elle sera supprimée de cet onglet et son contenu sera perdu.", 'editor.draft.recovery.ignore_confirm': 'Abandonner la copie', - 'editor.draft.copy_issue.cap': "Deux autres brouillons ont déjà une copie locale dans cet onglet. Les modifications de celui-ci ne sont pas conservées tant que vous n'en abandonnez pas une.", - 'editor.draft.copy_issue.quota': 'Le stockage de cet onglet est plein : les modifications non enregistrées de ce brouillon ne sont pas conservées. Enregistrez le brouillon ou abandonnez une copie ci-dessous.', + 'editor.draft.copy_issue.cap': "Deux autres brouillons ont déjà une copie locale temporaire dans cet onglet. Les modifications de celui-ci ne sont conservées nulle part (rien n'est enregistré sur le serveur) tant que vous n'en abandonnez pas une.", + 'editor.draft.copy_issue.quota': "Le stockage de cet onglet est plein : la copie locale temporaire de ce brouillon ne peut pas être écrite, et ses modifications non enregistrées sur le serveur ne sont pas conservées. Enregistrez le brouillon ou abandonnez une copie ci-dessous.", 'editor.draft.copy.open': 'Ouvrir ce brouillon', 'editor.draft.copy.abandon': 'Abandonner cette copie', 'editor.draft.copy.revision': 'révision {revision}', @@ -1284,7 +1290,7 @@ export const fr: Dict = { 'editor.field.integer': 'Indiquez un nombre entier.', 'editor.field.choose': 'Choisir…', 'editor.refusal.blocked': 'La modification n\'a pas été appliquée.', - 'editor.refusal.recovery': 'Répondez d\'abord à la copie locale proposée en haut de page.', + 'editor.refusal.recovery': "Répondez d'abord à la copie locale temporaire de cet onglet proposée en haut de page : elle n'est pas enregistrée sur le serveur.", 'editor.refusal.core.unknown_key': 'Cet élément n\'existe plus dans le brouillon.', 'editor.refusal.core.duplicate_key': 'Un élément porte déjà cet identifiant.', 'editor.refusal.core.invalid_target': 'Cette modification ne s\'applique pas à cet élément.', @@ -1379,7 +1385,6 @@ export const fr: Dict = { 'editor.views.drawing.rejected': 'Illustration refusée', 'editor.views.drawing.not_canonical': "Illustration refusée : elle n'est pas sous la forme enregistrée. Choisissez de nouveau le fichier d'origine pour la remplacer.", 'editor.views.drawing.rejected_reason': "Illustration refusée ({reason}).", - 'editor.views.drawing.hash_mismatch': "Illustration refusée : le contenu du fichier ne correspond pas à son empreinte enregistrée.", 'editor.views.drawing.inherited': "Utilise l'illustration de la vue parente.", 'editor.views.drawing.hint': 'Utilisez « Choisir une illustration » pour ajouter ou remplacer le dessin de cette vue.', 'editor.views.drawing.unmeasured': "Cette vue n'est pas mesurable : ajoutez ou corrigez son illustration avant de placer ou de déplacer des éléments.", @@ -1412,10 +1417,10 @@ export const fr: Dict = { 'editor.upload.err.svg_active_content': 'Ce fichier contient du contenu actif ou externe (script, lien, image distante) : il est refusé.', 'editor.upload.err.svg_rejected': "Ce fichier n'est pas un dessin SVG utilisable ({reason}).", 'editor.upload.err.svg_not_canonical': "Cette illustration n'est pas sous la forme enregistrée : elle est refusée. Choisissez de nouveau le fichier d'origine.", - 'editor.upload.err.size_mismatch': 'La taille du fichier envoyé ne correspond pas à celle annoncée. Réessayez.', + 'editor.upload.err.size_mismatch': "La taille du fichier d'une illustration diffère de celle enregistrée.", 'editor.upload.err.upload_missing': "Le fichier n'est pas arrivé sur le serveur. Réessayez.", 'editor.upload.err.upload.pending_other': "Ce dessin est en cours d'envoi par un autre compte. Réessayez dans quelques instants.", - 'editor.upload.err.object_conflict': "Un fichier différent existe déjà sous cette empreinte : l'illustration est refusée.", + 'editor.upload.err.object_conflict': "Le contenu du fichier de l'illustration ne correspond pas à son empreinte SHA-256 enregistrée.", 'editor.upload.err.caps': "Trop d'illustrations dans cette session d'édition (16 au plus). Enregistrez, puis rechargez le brouillon.", 'editor.upload.err.core': 'Le contrôle du document a refusé cette illustration.', 'editor.upload.reason.malformed': 'fichier mal formé', diff --git a/apps/app/tests/unit/admin.labels.test.ts b/apps/app/tests/unit/admin.labels.test.ts new file mode 100644 index 00000000..b53c2d2c --- /dev/null +++ b/apps/app/tests/unit/admin.labels.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from 'vitest' +import { failureMessage } from '@/admin/labels' +import { en } from '@/i18n/en' +import { fr } from '@/i18n/fr' + +describe('failure messages of the submission', () => { + it.each(['round.open', 'view.asset.unknown'] as const)( + '%s has its own wording, never the generic unavailable one', + (kind) => { + for (const dict of [fr, en]) { + const t = (key: string) => dict[key] + const message = failureMessage(t, kind) + expect(message).toBe(dict[`admin.failure.${kind}`]) + expect(message).not.toBe(dict['admin.failure.unavailable']) + } + }, + ) +}) diff --git a/apps/app/tests/unit/editor-drawing-upload.test.tsx b/apps/app/tests/unit/editor-drawing-upload.test.tsx index ac5afd1a..3f67721a 100644 --- a/apps/app/tests/unit/editor-drawing-upload.test.tsx +++ b/apps/app/tests/unit/editor-drawing-upload.test.tsx @@ -241,9 +241,7 @@ describe('drawing upload flow', () => { new SheetFailure('size_mismatch'), ) await pick(svg('0 0 200 100')) - expect( - await screen.findByText(/ne correspond pas à celle annoncée/), - ).toBeTruthy() + expect(await screen.findByText(/diffère de celle enregistrée/)).toBeTruthy() expect(mainAsset()).toBe(ASSET) }) @@ -252,7 +250,9 @@ describe('drawing upload flow', () => { sb.downloadSheetDrawing.mockResolvedValue(new TextEncoder().encode('autre')) await pick(svg('0 0 200 100')) expect( - await screen.findByText(/Un fichier différent existe déjà/), + await screen.findByText( + /ne correspond pas à son empreinte SHA-256 enregistrée/, + ), ).toBeTruthy() expect(mainAsset()).toBe(ASSET) }) diff --git a/apps/app/tests/unit/editor-route-recovery.test.tsx b/apps/app/tests/unit/editor-route-recovery.test.tsx index 1e27c789..18e270eb 100644 --- a/apps/app/tests/unit/editor-route-recovery.test.tsx +++ b/apps/app/tests/unit/editor-route-recovery.test.tsx @@ -139,7 +139,7 @@ describe('the blocking offer', () => { const dialog = within(await screen.findByRole('dialog')) expect( dialog.getByText( - /Abandonner la copie locale non enregistrée \(révision 3, \d\d:\d\d\) \? Elle sera supprimée de cet onglet\./, + /Abandonner la copie locale temporaire de cet onglet, non enregistrée sur le serveur \(révision 3, \d\d:\d\d\) \? Elle sera supprimée de cet onglet\./, ), ).toBeInTheDocument() await user.click(dialog.getByRole('button', { name: 'Annuler' })) @@ -190,7 +190,7 @@ describe('the blocking offer', () => { await user.click(screen.getByRole('button', { name: 'Restaurer la copie' })) expect( await screen.findByText( - /La copie locale ne passe pas le contrôle du document : .+\. Elle est conservée\./, + /Le contrôle du document refuse cette copie : .+\. Elle reste dans cet onglet\./, ), ).toBeInTheDocument() expect( @@ -268,7 +268,7 @@ describe('cap and quota', () => { await ready() act(() => void commitMove(40)) expect( - await screen.findByText('Copie locale impossible (stockage plein)'), + await screen.findByText(fr['editor.draft.status.copy_quota']), ).toBeInTheDocument() expect( screen.getByText(fr['editor.draft.copy_issue.quota']), diff --git a/apps/app/tests/unit/editor-route.test.tsx b/apps/app/tests/unit/editor-route.test.tsx index ff2212e9..06dec3d3 100644 --- a/apps/app/tests/unit/editor-route.test.tsx +++ b/apps/app/tests/unit/editor-route.test.tsx @@ -368,7 +368,7 @@ describe('permission lost during the session', () => { await refusedSave('draft.frozen') expect( await screen.findByText(/Une revue est en cours sur ce brouillon/), - ).toHaveTextContent('Une copie locale temporaire existe dans cet onglet.') + ).toHaveTextContent(fr['editor.draft.copy_kept']) expect(screen.getByText('Lecture seule')).toBeInTheDocument() expect(screen.queryByRole('button', { name: 'Enregistrer' })).toBeNull() expect(sb.saveSheetDraft).toHaveBeenCalledTimes(1) @@ -385,7 +385,7 @@ describe('permission lost during the session', () => { await ready() act(() => void commitMove(40)) expect( - await screen.findByText('Copie locale impossible (stockage plein)'), + await screen.findByText(fr['editor.draft.status.copy_quota']), ).toBeInTheDocument() await user.click(screen.getByRole('button', { name: 'Enregistrer' })) const notice = await screen.findByText(/Votre session a expiré/) diff --git a/apps/app/tests/unit/editor-tabs-views.test.tsx b/apps/app/tests/unit/editor-tabs-views.test.tsx index 89981b19..88356450 100644 --- a/apps/app/tests/unit/editor-tabs-views.test.tsx +++ b/apps/app/tests/unit/editor-tabs-views.test.tsx @@ -145,7 +145,7 @@ describe('Vues et illustrations: drawing states', () => { await vi.waitFor(() => expect(store.getState().status).toBe('ready')) render() expect( - screen.getByText(/ne correspond pas à son empreinte enregistrée/), + screen.getByText(/ne correspond pas à son empreinte SHA-256 enregistrée/), ).toBeTruthy() expect(screen.queryByText(/introuvable/)).toBeNull() }) diff --git a/docs/development/V1-2-6_OWNER_TRIAL.md b/docs/development/V1-2-6_OWNER_TRIAL.md index f981fa15..25dc84bf 100644 --- a/docs/development/V1-2-6_OWNER_TRIAL.md +++ b/docs/development/V1-2-6_OWNER_TRIAL.md @@ -76,7 +76,7 @@ Chaque étape donne l'action et le résultat attendu. Notez tout écart avec la illustrations, Annotations, Constats, Références, Vertèbres, Vérification). ### 4.2 Importer une illustration SVG -Préparez deux fichiers dans un dossier hors du dépôt : +Préparez trois fichiers dans un dossier hors du dépôt : ```bash mkdir -p ~/essai-svg