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 951538cc..dd5f437c 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 @@ -478,3 +478,22 @@ about the local copy says it is temporary, limited to this tab and not saved on |---|---|---|---| | `editor.draft.status.copy_quota` | Copie locale temporaire impossible (onglet plein) : non enregistré sur le serveur | Temporary local copy impossible (tab full): not saved on the server | C25: header status said nothing about the server (was « …(stockage de l'onglet plein) ») | | `editor.draft.status.copy_cap` | Copie locale temporaire impossible (deux autres copies dans cet onglet) : non enregistré sur le serveur | Temporary local copy impossible (two other copies in this tab): not saved on the server | C25 (was « …: deux autres brouillons ont déjà une copie dans cet onglet ») | + +## Lot N1 (owner decisions 2026-11-04: plurals, parent illustration, category hint) + +Plural keys use `_one` / `_other` (French 0 and 1 are singular). The base key is replaced by its two forms. + +| Key | FR | EN | Old wording and why | +|---|---|---|---| +| `editor.annotations.tracing_one` / `_other` | {count} sommet posé. / {count} sommets posés. | {count} vertex placed. / {count} vertices placed. | Old « {count} sommet(s) posé(s). » / « {count} vertex(es) placed. »: agreement (C36) | +| `editor.annotations.geometry.vertices_one` / `_other` | {count} sommet / {count} sommets | {count} vertex / {count} vertices | Old single form « {count} sommets »: agreement (C36) | +| `editor.verification.errors_one` / `_other` | {count} erreur bloquante / {count} erreurs bloquantes | {count} blocking error / {count} blocking errors | Old L28 « {count} erreurs bloquantes »: its plural stays the ratified wording, the singular is new | +| `editor.verification.warnings_one` / `_other` | {count} avertissement / {count} avertissements | {count} warning / {count} warnings | Agreement (C36) | +| `editor.verification.to_confirm_one` / `_other` | {count} élément à confirmer / {count} éléments à confirmer | {count} item to confirm / {count} items to confirm | Agreement (C36) | +| `editor.verification.vet_referrals_one` / `_other` | {count} renvoi vers un vétérinaire / {count} renvois vers un vétérinaire | {count} veterinary referral / {count} veterinary referrals | Old « {count} renvoi(s) … » / « {count} veterinary referral(s) » | +| `editor.verification.uncited_one` / `_other` | {count} constat sans référence citée / {count} constats sans référence citée | {count} finding citing no reference / {count} findings citing no reference | Old « {count} constat(s) … » / « {count} finding(s) … » | +| `editor.verification.hint.errors_one` / `_other` | Corrigez l'erreur bloquante pour soumettre. / Corrigez les {count} erreurs bloquantes pour soumettre. | Fix the blocking error to submit. / Fix the {count} blocking errors to submit. | Old « Corrigez les {count} erreurs bloquantes pour soumettre. » / « Fix the {count} blocking errors to submit. » read « 1 erreurs » | +| `editor.views.drawing.use_parent_title` | Utiliser l'illustration de la vue parente ? | Use the parent view's drawing? | New: confirmation dialog (C39). The button label is unchanged | +| `editor.views.drawing.use_parent_body` | La vue affichera l'illustration de la vue parente à travers son recadrage. Son propre fichier d'illustration reste enregistré, et vous pouvez annuler ce changement (Annuler). Les annotations de la vue repassent « à confirmer ». | The view will show the parent view's drawing through its crop. Its own drawing file stays stored, and you can undo this change (Undo). The view's annotations go back to "to confirm". | New: names the effect (nothing deleted, undo, `reconfirm_redrawn_views`) | +| `editor.views.drawing.use_parent_confirm` / `_cancel` | Utiliser l'illustration parente / Annuler | Use the parent drawing / Cancel | New: dialog buttons | +| `editor.findings.new.category_in_zone` | Nouvelle catégorie dans la zone « {zone} » | New category in the zone « {zone} » | Replaces `editor.findings.new.category` (« Nouvelle catégorie de constats » / « New findings category »): the form names the zone the category lands in (C42) | diff --git a/apps/app/e2e/shell/editor-drawings.spec.ts b/apps/app/e2e/shell/editor-drawings.spec.ts index 3e3203a9..084b3b8e 100644 --- a/apps/app/e2e/shell/editor-drawings.spec.ts +++ b/apps/app/e2e/shell/editor-drawings.spec.ts @@ -154,6 +154,12 @@ test.describe('editor drawings (A2)', () => { await detail .getByRole('button', { name: dict['editor.views.drawing.use_parent'] }) .click() + await page + .getByRole('dialog') + .getByRole('button', { + name: dict['editor.views.drawing.use_parent_confirm'], + }) + .click() await expect( detail.getByText(dict['editor.views.drawing.inherited']), ).toBeVisible() diff --git a/apps/app/e2e/shell/editor-geometry.spec.ts b/apps/app/e2e/shell/editor-geometry.spec.ts index e98652f8..7001830a 100644 --- a/apps/app/e2e/shell/editor-geometry.spec.ts +++ b/apps/app/e2e/shell/editor-geometry.spec.ts @@ -229,6 +229,8 @@ test.describe('editor geometry (adversarial)', () => { requests.forbid(actor.account.email, actor.account.password) const seed = await seedDraft(actor, { drawing: null, shape: standardShape }) await openEditor(page, dict, actor, seed.sheetId) + // No measurable view: the draft opens on Général (C40). + await selectTab(page, dict, 'annotations') await expect( page.getByText(dict['editor.annotations.unmeasured.hint'], { exact: false, diff --git a/apps/app/e2e/shell/editor-journey.spec.ts b/apps/app/e2e/shell/editor-journey.spec.ts index 311a022b..3ca099e3 100644 --- a/apps/app/e2e/shell/editor-journey.spec.ts +++ b/apps/app/e2e/shell/editor-journey.spec.ts @@ -382,7 +382,7 @@ test.describe('editor journey (owner trial steps)', () => { const verification = page.getByTestId('editor-tab-verification') await expect( verification.getByText( - dict['editor.verification.errors'].replace('{count}', '0'), + dict['editor.verification.errors_one'].replace('{count}', '0'), ), ).toBeVisible() await expect( diff --git a/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx b/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx index befd22ee..7a7710d4 100644 --- a/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx +++ b/apps/app/src/app/routes/app/admin/AdminSheetDraftRoute.tsx @@ -31,16 +31,17 @@ import { } from '@/editor/mode' import { leaveGuardArmed, useEditorStore } from '@/editor/state/editorStore' import { FocusConsumedContext, type FocusRequest } from '@/editor/focusRequest' -import type { EditorTabId, EditorTabProps } from '@/editor/tabs' +import { + initialTab, + type EditorTabId, + type EditorTabProps, +} from '@/editor/tabs' import { useUndoShortcuts } from '@/editor/useUndoShortcuts' import { useTabTier } from '@/editor/useViewport' import { useAuthStore } from '@/state/authStore' import { useT } from '@/i18n/useT' import { SheetNotFound } from './AdminSheetRoute' -/** The tab the boards open on (04 and 05 both show the annotations). */ -const FIRST_TAB: EditorTabId = 'annotations' - interface DraftEditorProps { sheet: OfficialSheetAdmin versionId: string @@ -78,7 +79,7 @@ function DraftEditor({ }: DraftEditorProps) { const t = useT() const tier = useTabTier() - const [tab, setTab] = useState(FIRST_TAB) + const [chosen, setTab] = useState(null) const [focus, setFocus] = useState() const clearFocus = (serial: number) => setFocus((prev) => (prev?.serial === serial ? undefined : prev)) @@ -91,6 +92,13 @@ function DraftEditor({ const sessionVersion = useEditorStore((s) => s.versionId) const failure = useEditorStore((s) => s.failure) const recovery = useEditorStore((s) => s.recovery) + const previewState = useEditorStore((s) => s.previewState) + const opened = status === 'ready' && sessionVersion === versionId + // Chosen once per opened version: later edits never move the user off their tab. + if (chosen === null && opened && previewState) { + setTab(initialTab(previewState, tier)) + } + const tab = chosen ?? 'annotations' const mode = modeAfterSave( editorMode({ hasRight, sheet, wide: tier === 'wide' }), saveFailure, diff --git a/apps/app/src/components/editor/annotations/AnnotationFields.tsx b/apps/app/src/components/editor/annotations/AnnotationFields.tsx index 54305671..0521ff2b 100644 --- a/apps/app/src/components/editor/annotations/AnnotationFields.tsx +++ b/apps/app/src/components/editor/annotations/AnnotationFields.tsx @@ -60,6 +60,7 @@ function NameFields(props: Props) { value={annotation.name?.[locale] ?? ''} onCommit={rename(locale)} readOnly={readOnly} + trim error={edit.fieldError(locale)} /> ))} diff --git a/apps/app/src/components/editor/annotations/GeometryGroup.tsx b/apps/app/src/components/editor/annotations/GeometryGroup.tsx index 8727abb4..bcd70f0d 100644 --- a/apps/app/src/components/editor/annotations/GeometryGroup.tsx +++ b/apps/app/src/components/editor/annotations/GeometryGroup.tsx @@ -12,6 +12,7 @@ import { type EditableGeometry, type GroupFields, } from '@/editor/annotations/geometryEdit' +import { usePlural } from '@/editor/plural' import { useT } from '@/i18n/useT' /** What applying the group answers: kept, or the words that say why not. */ @@ -208,7 +209,6 @@ function CircleRows(props: RowsProps>) { } function PolygonRows(props: RowsProps) { - const t = useT() const [selected, setSelected] = useState(0) const { fields } = props const change = (index: number, axis: 'x' | 'y', value: string) => @@ -218,11 +218,11 @@ function PolygonRows(props: RowsProps) { i === index ? { ...row, [axis]: value } : row, ), }) - const count = String(fields.rows.length) + const plural = usePlural() return (

- {t('editor.annotations.geometry.vertices').replace('{count}', count)} + {plural('editor.annotations.geometry.vertices', fields.rows.length)}

{fields.rows.map((row, index) => ( void }) { const t = useT() + const plural = usePlural() return (

- {t('editor.annotations.tracing').replace('{count}', String(count))} + {plural('editor.annotations.tracing', count)}

+ +
+ + ) +} diff --git a/apps/app/src/components/editor/views/ViewDrawing.tsx b/apps/app/src/components/editor/views/ViewDrawing.tsx index 3623000e..3d161d3d 100644 --- a/apps/app/src/components/editor/views/ViewDrawing.tsx +++ b/apps/app/src/components/editor/views/ViewDrawing.tsx @@ -1,4 +1,4 @@ -import { useRef, type ChangeEvent } from 'react' +import { useRef, useState, type ChangeEvent } from 'react' import type { SheetView } from '@faunosteo/core-wasm/types' import ActionButton from '@/components/editor/fields/ActionButton' import Notice from '@/components/ui/Notice' @@ -16,6 +16,7 @@ import { useViewUpdate } from '@/editor/useViewUpdate' import { useT } from '@/i18n/useT' import { useLocaleStore } from '@/state/localeStore' import CleaningDialog from './CleaningDialog' +import ParentDrawingDialog from './ParentDrawingDialog' /** * A view's drawing: its state, the hint when it is not usable, « Choisir une @@ -92,6 +93,11 @@ function DrawingActions({ const t = useT() const upload = useDrawingUpload(view.id) const views = useViewUpdate() + const [asking, setAsking] = useState(false) + const usesParent = () => { + setAsking(false) + views.update('drawing', view.id, { svg_asset_id: null }, true) + } return ( <>
@@ -101,14 +107,17 @@ function DrawingActions({ readOnly={false} variant="ghost" size="sm" - onClick={() => - views.update('drawing', view.id, { svg_asset_id: null }, true) - } + onClick={() => setAsking(true)} > {t('editor.views.drawing.use_parent')} )}
+ setAsking(false)} + /> {views.error('drawing') && ( {views.error('drawing')} diff --git a/apps/app/src/components/editor/views/ViewNames.tsx b/apps/app/src/components/editor/views/ViewNames.tsx index f3bf1652..6ffaeacd 100644 --- a/apps/app/src/components/editor/views/ViewNames.tsx +++ b/apps/app/src/components/editor/views/ViewNames.tsx @@ -35,6 +35,7 @@ export default function ViewNames({ value={view.name[locale]} onCommit={rename(locale)} readOnly={readOnly} + trim error={views.error(locale)} /> ))} diff --git a/apps/app/src/editor/annotations/creation.ts b/apps/app/src/editor/annotations/creation.ts index 229e2a3b..06471dfd 100644 --- a/apps/app/src/editor/annotations/creation.ts +++ b/apps/app/src/editor/annotations/creation.ts @@ -137,14 +137,14 @@ export function annotationOf( return { ...common, kind: 'detail_trigger', - name: named ? { fr: form.fr, en: form.en } : null, + name: named ? { fr: form.fr.trim(), en: form.en.trim() } : null, opens_view_id: form.opensViewId, } } return { ...common, kind: pending.kind, - name: { fr: form.fr, en: form.en }, + name: { fr: form.fr.trim(), en: form.en.trim() }, finding_zone_id: orNull(form.zoneId), vertebral_region_code: orNull(form.regionCode), } diff --git a/apps/app/src/editor/plural.ts b/apps/app/src/editor/plural.ts new file mode 100644 index 00000000..830c1c12 --- /dev/null +++ b/apps/app/src/editor/plural.ts @@ -0,0 +1,17 @@ +import { useT } from '@/i18n/useT' +import { useLocaleStore } from '@/state/localeStore' +import type { Locale } from '@/i18n/types' + +/** `_one` or `_other` by the locale's plural rule (fr: 0 and 1 are singular). */ +export function pluralKey(locale: Locale, key: string, count: number): string { + const category = new Intl.PluralRules(locale).select(count) + return `${key}_${category === 'one' ? 'one' : 'other'}` +} + +/** A count phrase: picks the plural form of `key` and fills `{count}`. */ +export function usePlural(): (key: string, count: number) => string { + const t = useT() + const locale = useLocaleStore((s) => s.locale) + return (key, count) => + t(pluralKey(locale, key, count)).replace('{count}', String(count)) +} diff --git a/apps/app/src/editor/tabs.ts b/apps/app/src/editor/tabs.ts index 6728e9a5..1387d333 100644 --- a/apps/app/src/editor/tabs.ts +++ b/apps/app/src/editor/tabs.ts @@ -1,5 +1,6 @@ -import type { ElementKey } from '@faunosteo/core-wasm/types' +import type { ElementKey, PreviewState } from '@faunosteo/core-wasm/types' import type { FocusRequest } from './focusRequest' +import { unmeasuredViews } from './issues' import type { TabTier } from './useViewport' export const EDITOR_TABS = [ @@ -28,6 +29,17 @@ export function tabsFor(tier: TabTier): { return { shown, more: EDITOR_TABS.filter((tab) => !shown.includes(tab)) } } +/** + * The tab a version opens on: Annotations once a view can be annotated, Général while + * there is nothing to annotate yet. A tier that does not list Général keeps Annotations. + */ +export function initialTab(state: PreviewState, tier: TabTier): EditorTabId { + const unmeasured = unmeasuredViews(state) + const measurable = state.document.views.some((v) => !unmeasured.has(v.id)) + const wanted = measurable ? 'annotations' : 'general' + return SHOWN[tier].includes(wanted) ? wanted : 'annotations' +} + /** Props of every tab body (Lots F-J fill them): read-only flag, tab jump, sheet reload. */ export interface EditorTabProps { /** Not editable now: a mode that cannot save, or a recovery offer not answered yet. */ diff --git a/apps/app/src/i18n/en.ts b/apps/app/src/i18n/en.ts index 29812caf..683455fb 100644 --- a/apps/app/src/i18n/en.ts +++ b/apps/app/src/i18n/en.ts @@ -1360,6 +1360,10 @@ export const en: Dict = { 'editor.views.drawing.choose': 'Choose a drawing', 'editor.views.drawing.file': 'Drawing file (SVG)', 'editor.views.drawing.use_parent': "Use the parent view's drawing", + 'editor.views.drawing.use_parent_title': "Use the parent view's drawing?", + 'editor.views.drawing.use_parent_body': "The view will show the parent view's drawing through its crop. Its own drawing file stays stored, and you can undo this change (Undo). The view's annotations go back to \"to confirm\".", + 'editor.views.drawing.use_parent_confirm': "Use the parent drawing", + 'editor.views.drawing.use_parent_cancel': 'Cancel', 'editor.views.crop.title': 'Crop', 'editor.views.crop.toggle': 'Edit the crop', 'editor.views.crop.min_x': 'Crop: minimum x', @@ -1426,7 +1430,7 @@ export const en: Dict = { 'editor.findings.add_category': 'Add a category', 'editor.findings.add_node': 'Add a finding', 'editor.findings.new.zone': 'New findings zone', - 'editor.findings.new.category': 'New findings category', + 'editor.findings.new.category_in_zone': 'New category in the zone « {zone} »', 'editor.findings.new.node': 'New finding', 'editor.findings.kind': 'Category type', 'editor.findings.kind.dysfunction': 'Dysfunction', @@ -1495,7 +1499,8 @@ export const en: Dict = { 'editor.annotations.selection': 'Selection: {kind} « {name} »', 'editor.annotations.select_hint': 'Select an annotation on the drawing or in the list to see its properties.', 'editor.annotations.properties': 'Annotation properties', - 'editor.annotations.tracing': '{count} vertex(es) placed.', + 'editor.annotations.tracing_one': '{count} vertex placed.', + 'editor.annotations.tracing_other': '{count} vertices placed.', 'editor.annotations.trace_close': 'Close the tracing', 'editor.annotations.trace_cancel': 'Cancel the tracing', 'editor.annotations.replace_polygon': 'Replace with a polygon', @@ -1508,7 +1513,8 @@ export const en: Dict = { 'editor.annotations.geometry.r': 'Radius', 'editor.annotations.geometry.vertex_x': 'x of vertex {n}', 'editor.annotations.geometry.vertex_y': 'y of vertex {n}', - 'editor.annotations.geometry.vertices': '{count} vertices', + 'editor.annotations.geometry.vertices_one': '{count} vertex', + 'editor.annotations.geometry.vertices_other': '{count} vertices', 'editor.annotations.geometry.add_vertex': 'Add a vertex', 'editor.annotations.geometry.unapplied': 'Values not applied: the draft is unchanged.', 'editor.annotations.geometry.unapplied_tag': 'not applied', @@ -1523,16 +1529,21 @@ export const en: Dict = { 'editor.findings.references_none': 'No reference cited.', 'editor.findings.reference_add': 'Cite a reference', 'editor.verification.title': 'Draft check', - 'editor.verification.errors': '{count} blocking errors', - 'editor.verification.warnings': '{count} warnings', - 'editor.verification.to_confirm': '{count} items to confirm', + 'editor.verification.errors_one': '{count} blocking error', + 'editor.verification.errors_other': '{count} blocking errors', + 'editor.verification.warnings_one': '{count} warning', + 'editor.verification.warnings_other': '{count} warnings', + 'editor.verification.to_confirm_one': '{count} item to confirm', + 'editor.verification.to_confirm_other': '{count} items to confirm', 'editor.verification.none': 'No issues found', 'editor.verification.warnings_title': 'Warnings', 'editor.verification.goto': 'Go to {tab}', 'editor.verification.to_confirm_info': 'Some items are still to confirm: this does not prevent submission.', 'editor.verification.completeness': 'Completeness', - 'editor.verification.vet_referrals': '{count} veterinary referral(s)', - 'editor.verification.uncited': '{count} finding(s) citing no reference', + 'editor.verification.vet_referrals_one': '{count} veterinary referral', + 'editor.verification.vet_referrals_other': '{count} veterinary referrals', + 'editor.verification.uncited_one': '{count} finding citing no reference', + 'editor.verification.uncited_other': '{count} findings citing no reference', 'editor.verification.groups': 'Statuses per group', 'editor.verification.group_removed': 'removed', 'editor.verification.status.to_confirm': 'To confirm', @@ -1554,7 +1565,8 @@ export const en: Dict = { 'editor.verification.note': 'Submission note (required)', 'editor.verification.submit_title': 'Submission', 'editor.verification.submit': 'Submit for review', - 'editor.verification.hint.errors': 'Fix the {count} blocking errors to submit.', + 'editor.verification.hint.errors_one': 'Fix the blocking error to submit.', + 'editor.verification.hint.errors_other': 'Fix the {count} blocking errors to submit.', 'editor.verification.hint.unsaved': 'Save the draft before submitting it.', 'editor.verification.hint.note': 'Enter the submission note to submit.', 'editor.verification.issue.unknown': 'This item breaks a rule of the sheet. Fix the item shown.', diff --git a/apps/app/src/i18n/fr.ts b/apps/app/src/i18n/fr.ts index 60390b54..c752306a 100644 --- a/apps/app/src/i18n/fr.ts +++ b/apps/app/src/i18n/fr.ts @@ -1391,6 +1391,10 @@ export const fr: Dict = { 'editor.views.drawing.choose': 'Choisir une illustration', 'editor.views.drawing.file': "Fichier d'illustration (SVG)", 'editor.views.drawing.use_parent': "Utiliser l'illustration de la vue parente", + 'editor.views.drawing.use_parent_title': "Utiliser l'illustration de la vue parente ?", + 'editor.views.drawing.use_parent_body': "La vue affichera l'illustration de la vue parente à travers son recadrage. Son propre fichier d'illustration reste enregistré, et vous pouvez annuler ce changement (Annuler). Les annotations de la vue repassent « à confirmer ».", + 'editor.views.drawing.use_parent_confirm': "Utiliser l'illustration parente", + 'editor.views.drawing.use_parent_cancel': 'Annuler', 'editor.views.crop.title': 'Recadrage', 'editor.views.crop.toggle': 'Modifier le recadrage', 'editor.views.crop.min_x': 'Recadrage : x minimum', @@ -1457,7 +1461,7 @@ export const fr: Dict = { 'editor.findings.add_category': 'Ajouter une catégorie', 'editor.findings.add_node': 'Ajouter un constat', 'editor.findings.new.zone': 'Nouvelle zone de constats', - 'editor.findings.new.category': 'Nouvelle catégorie de constats', + 'editor.findings.new.category_in_zone': 'Nouvelle catégorie dans la zone « {zone} »', 'editor.findings.new.node': 'Nouveau constat', 'editor.findings.kind': 'Type de catégorie', 'editor.findings.kind.dysfunction': 'Dysfonction', @@ -1526,7 +1530,8 @@ export const fr: Dict = { 'editor.annotations.selection': 'Sélection : {kind} « {name} »', 'editor.annotations.select_hint': 'Sélectionnez une annotation sur le dessin ou dans la liste pour voir ses propriétés.', 'editor.annotations.properties': "Propriétés de l'annotation", - 'editor.annotations.tracing': '{count} sommet(s) posé(s).', + 'editor.annotations.tracing_one': '{count} sommet posé.', + 'editor.annotations.tracing_other': '{count} sommets posés.', 'editor.annotations.trace_close': 'Fermer le tracé', 'editor.annotations.trace_cancel': 'Annuler le tracé', 'editor.annotations.replace_polygon': 'Remplacer par un polygone', @@ -1539,7 +1544,8 @@ export const fr: Dict = { 'editor.annotations.geometry.r': 'Rayon', 'editor.annotations.geometry.vertex_x': 'x du sommet {n}', 'editor.annotations.geometry.vertex_y': 'y du sommet {n}', - 'editor.annotations.geometry.vertices': '{count} sommets', + 'editor.annotations.geometry.vertices_one': '{count} sommet', + 'editor.annotations.geometry.vertices_other': '{count} sommets', 'editor.annotations.geometry.add_vertex': 'Ajouter un sommet', 'editor.annotations.geometry.unapplied': 'Valeurs non appliquées : le brouillon est inchangé.', 'editor.annotations.geometry.unapplied_tag': 'non appliqué', @@ -1554,16 +1560,21 @@ export const fr: Dict = { 'editor.findings.references_none': 'Aucune référence citée.', 'editor.findings.reference_add': 'Citer une référence', 'editor.verification.title': 'Contrôle du brouillon', - 'editor.verification.errors': '{count} erreurs bloquantes', - 'editor.verification.warnings': '{count} avertissements', - 'editor.verification.to_confirm': '{count} éléments à confirmer', + 'editor.verification.errors_one': '{count} erreur bloquante', + 'editor.verification.errors_other': '{count} erreurs bloquantes', + 'editor.verification.warnings_one': '{count} avertissement', + 'editor.verification.warnings_other': '{count} avertissements', + 'editor.verification.to_confirm_one': '{count} élément à confirmer', + 'editor.verification.to_confirm_other': '{count} éléments à confirmer', 'editor.verification.none': 'Aucun problème détecté', 'editor.verification.warnings_title': 'Avertissements', 'editor.verification.goto': 'Aller à {tab}', 'editor.verification.to_confirm_info': "Des éléments restent à confirmer : cela n'empêche pas la soumission.", 'editor.verification.completeness': 'Complétude', - 'editor.verification.vet_referrals': '{count} renvoi(s) vers un vétérinaire', - 'editor.verification.uncited': '{count} constat(s) sans référence citée', + 'editor.verification.vet_referrals_one': '{count} renvoi vers un vétérinaire', + 'editor.verification.vet_referrals_other': '{count} renvois vers un vétérinaire', + 'editor.verification.uncited_one': '{count} constat sans référence citée', + 'editor.verification.uncited_other': '{count} constats sans référence citée', 'editor.verification.groups': 'Statuts par groupe', 'editor.verification.group_removed': 'supprimé', 'editor.verification.status.to_confirm': 'À confirmer', @@ -1585,7 +1596,8 @@ export const fr: Dict = { 'editor.verification.note': 'Note de soumission (obligatoire)', 'editor.verification.submit_title': 'Soumission', 'editor.verification.submit': 'Soumettre à la revue', - 'editor.verification.hint.errors': 'Corrigez les {count} erreurs bloquantes pour soumettre.', + 'editor.verification.hint.errors_one': "Corrigez l'erreur bloquante pour soumettre.", + 'editor.verification.hint.errors_other': 'Corrigez les {count} erreurs bloquantes pour soumettre.', 'editor.verification.hint.unsaved': 'Enregistrez le brouillon avant de le soumettre.', 'editor.verification.hint.note': 'Saisissez la note de soumission pour soumettre.', 'editor.verification.issue.unknown': "Ce point ne respecte pas une règle de la fiche. Corrigez l'élément indiqué.", diff --git a/apps/app/tests/unit/editor-annotations-tab.test.tsx b/apps/app/tests/unit/editor-annotations-tab.test.tsx index ba3c7d7b..a0b5fd86 100644 --- a/apps/app/tests/unit/editor-annotations-tab.test.tsx +++ b/apps/app/tests/unit/editor-annotations-tab.test.tsx @@ -577,11 +577,11 @@ describe('tracing a zone or a link', () => { ) await userEvent.setup().click(screen.getByRole('button', { name: 'Zone' })) clickAt(20, 20) - expect(screen.getByText('1 sommet(s) posé(s).')).toBeInTheDocument() + expect(screen.getByText('1 sommet posé.')).toBeInTheDocument() fireEvent.keyDown(screen.getByTestId('annotation-canvas'), { key: 'Escape', }) - expect(screen.queryByText('1 sommet(s) posé(s).')).toBeNull() + expect(screen.queryByText('1 sommet posé.')).toBeNull() expect(annotations()).toHaveLength(0) }) diff --git a/apps/app/tests/unit/editor-fields.test.tsx b/apps/app/tests/unit/editor-fields.test.tsx index 83fc8932..bb0296b0 100644 --- a/apps/app/tests/unit/editor-fields.test.tsx +++ b/apps/app/tests/unit/editor-fields.test.tsx @@ -47,6 +47,42 @@ describe('TextField', () => { expect(onCommit).toHaveBeenCalledWith('Chevalz') }) + it('trim commits a padded name without its edge spaces', async () => { + const user = userEvent.setup() + const onCommit = vi.fn() + render( + , + ) + await user.type(screen.getByLabelText('Nom'), ' {Enter}') + expect(onCommit).not.toHaveBeenCalled() + await user.type(screen.getByLabelText('Nom'), 'x ') + await user.tab() + expect(onCommit).toHaveBeenCalledWith('Chevalx') + }) + + it('trim: a blank value commits as empty; unmount trims too', async () => { + const user = userEvent.setup() + const onCommit = vi.fn() + const view = render( + , + ) + await user.type(screen.getByLabelText('Nom'), ' ') + await user.tab() + expect(onCommit).not.toHaveBeenCalled() + await user.type(screen.getByLabelText('Nom'), ' a ') + view.unmount() + expect(onCommit).toHaveBeenCalledWith('a') + }) + + it('without trim a padded description commits unchanged', async () => { + const user = userEvent.setup() + const onCommit = vi.fn() + render() + await user.type(screen.getByLabelText('Texte'), ' a ') + await user.tab() + expect(onCommit).toHaveBeenCalledWith(' a ') + }) + it('a new committed value replaces what was typed; the refusal shows next to the control', () => { const view = render( { expect(doc().finding_zones[0].categories[1].children).toHaveLength(1) }) + it('names the zone a category lands in and appends it at zone level, a node selected', async () => { + await openReady({ text: treeText() }) + const user = userEvent.setup() + render() + items()[0].focus() + await user.keyboard('{ArrowDown}{ArrowRight}{ArrowRight}') + expect(items()[2]).toHaveAttribute('aria-selected', 'true') + await user.click( + screen.getByRole('button', { name: 'Ajouter une catégorie' }), + ) + expect( + screen.getByText('Nouvelle catégorie dans la zone « Zone A »'), + ).toBeInTheDocument() + await user.type( + screen.getByLabelText('Nom (FR)', { selector: '#finding-new-name-fr' }), + 'Nouv', + ) + await user.type( + screen.getByLabelText('Nom (EN)', { selector: '#finding-new-name-en' }), + 'New', + ) + await user.selectOptions( + screen.getByLabelText('Type de catégorie'), + 'anamnesis', + ) + await user.click(screen.getByRole('button', { name: 'Créer' })) + const categories = doc().finding_zones[0].categories + expect(categories.map((c) => c.id)).toEqual(['fcat-a', expect.any(String)]) + expect(categories[0].children[0].children).toHaveLength(1) + }) + it('disables « Ajouter un constat » on a zone and at depth 8', async () => { let text = treeText() let path = ['fcat-a', 'node-a', 'node-b'] diff --git a/apps/app/tests/unit/editor-initial-tab.test.ts b/apps/app/tests/unit/editor-initial-tab.test.ts new file mode 100644 index 00000000..78607eca --- /dev/null +++ b/apps/app/tests/unit/editor-initial-tab.test.ts @@ -0,0 +1,41 @@ +/** N1 (C40): the tab a version opens on. */ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { initialTab } from '@/editor/tabs' +import { emptyText } from '../helpers/editorFixtures' +import { + baseText, + openReady, + resetStore, + store, +} from '../helpers/editorHarness' + +vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) })) +vi.mock('@faunosteo/supabase', async (orig) => ({ + ...(await orig()), + getSheetVersion: vi.fn(), + downloadSheetDrawing: vi.fn(), + saveSheetDraft: vi.fn(), + getOfficialSheetAdmin: vi.fn(), + submitSheetReview: vi.fn(), +})) + +afterEach(resetStore) + +async function stateOf(text: string) { + await openReady({ text }) + return store.getState().previewState! +} + +describe('initialTab', () => { + it('opens an empty new draft on Général', async () => { + expect(initialTab(await stateOf(emptyText()), 'wide')).toBe('general') + }) + + it('opens a draft with a measured view on Annotations', async () => { + expect(initialTab(await stateOf(baseText()), 'wide')).toBe('annotations') + }) + + it('keeps Annotations on a tier that does not list Général', async () => { + expect(initialTab(await stateOf(emptyText()), 'small')).toBe('annotations') + }) +}) diff --git a/apps/app/tests/unit/editor-plural.test.tsx b/apps/app/tests/unit/editor-plural.test.tsx new file mode 100644 index 00000000..1523c557 --- /dev/null +++ b/apps/app/tests/unit/editor-plural.test.tsx @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' +import { pluralKey } from '@/editor/plural' + +describe('pluralKey', () => { + it('treats 0 and 1 as singular in French', () => { + expect(pluralKey('fr', 'k', 0)).toBe('k_one') + expect(pluralKey('fr', 'k', 1)).toBe('k_one') + expect(pluralKey('fr', 'k', 2)).toBe('k_other') + }) + + it('treats only 1 as singular in English', () => { + expect(pluralKey('en', 'k', 0)).toBe('k_other') + expect(pluralKey('en', 'k', 1)).toBe('k_one') + expect(pluralKey('en', 'k', 2)).toBe('k_other') + }) +}) diff --git a/apps/app/tests/unit/editor-tabs-views.test.tsx b/apps/app/tests/unit/editor-tabs-views.test.tsx index 88356450..d54f5836 100644 --- a/apps/app/tests/unit/editor-tabs-views.test.tsx +++ b/apps/app/tests/unit/editor-tabs-views.test.tsx @@ -150,6 +150,36 @@ describe('Vues et illustrations: drawing states', () => { expect(screen.queryByText(/introuvable/)).toBeNull() }) + it('use-parent asks first: cancel changes nothing, confirm commits once, undo restores', async () => { + const own = detail() + ;(own.value as { svg_asset_id: string | null }).svg_asset_id = ASSET + await openReady({ text: insert(baseText(), own) }) + const user = userEvent.setup() + render() + const open = () => + user.click( + screen.getByRole('button', { + name: "Utiliser l'illustration de la vue parente", + }), + ) + await open() + const dialog = screen.getByRole('dialog') + expect(dialog).toHaveTextContent(/reste enregistré/) + await user.click(within(dialog).getByRole('button', { name: 'Annuler' })) + expect(doc().views[1]).toMatchObject({ svg_asset_id: ASSET }) + expect(store.getState().undo).toHaveLength(0) + await open() + await user.click( + within(screen.getByRole('dialog')).getByRole('button', { + name: "Utiliser l'illustration parente", + }), + ) + expect(doc().views[1]).toMatchObject({ svg_asset_id: null }) + expect(store.getState().undo).toHaveLength(1) + store.getState().undoStep() + expect(doc().views[1]).toMatchObject({ svg_asset_id: ASSET }) + }) + it('read-only shows states as text and no action', async () => { await openReady({ text: insert(baseText(), detail()) }) render() diff --git a/apps/app/tests/unit/editor-verification.test.tsx b/apps/app/tests/unit/editor-verification.test.tsx index e3ac4028..7c2a2683 100644 --- a/apps/app/tests/unit/editor-verification.test.tsx +++ b/apps/app/tests/unit/editor-verification.test.tsx @@ -57,9 +57,9 @@ describe('Vérification panel', () => { it('shows the counts, the warning apart, the size and the groups', async () => { await openReady() render() - expect(screen.getByText('0 erreurs bloquantes')).toBeTruthy() - expect(screen.getByText('1 avertissements')).toBeTruthy() - expect(screen.getByText('1 éléments à confirmer')).toBeTruthy() + expect(screen.getByText('0 erreur bloquante')).toBeTruthy() + expect(screen.getByText('1 avertissement')).toBeTruthy() + expect(screen.getByText('1 élément à confirmer')).toBeTruthy() expect(screen.getByRole('heading', { name: 'Avertissements' })).toBeTruthy() expect( screen.getByText(/lié(e)? à aucune zone|liée à aucune zone/), @@ -75,7 +75,7 @@ describe('Vérification panel', () => { await openReady({ text: textWithError() }) const user = userEvent.setup() render() - expect(screen.getByText('1 erreurs bloquantes')).toBeTruthy() + expect(screen.getByText('1 erreur bloquante')).toBeTruthy() expect(screen.getAllByText('Sans tracé')).toHaveLength(2) expect(screen.getByText(/n'a pas de géométrie/)).toBeTruthy() await user.click( @@ -96,7 +96,7 @@ describe('Vérification panel', () => { }) as HTMLButtonElement expect(button.disabled).toBe(true) expect( - screen.getByText('Corrigez les 1 erreurs bloquantes pour soumettre.'), + screen.getByText("Corrigez l'erreur bloquante pour soumettre."), ).toBeTruthy() }) @@ -104,7 +104,7 @@ describe('Vérification panel', () => { useLocaleStore.setState({ locale: 'en' }) await openReady({ text: textWithError() }) render() - expect(screen.getByText('1 blocking errors')).toBeTruthy() + expect(screen.getByText('1 blocking error')).toBeTruthy() expect(screen.getByText(/This annotation has no geometry/)).toBeTruthy() expect(screen.getAllByRole('button', { name: 'Go to Bare' })).toHaveLength( 2, @@ -115,7 +115,7 @@ describe('Vérification panel', () => { await openReady() render() expect(screen.queryByRole('button', { name: SUBMIT })).toBeNull() - expect(screen.getByText('0 erreurs bloquantes')).toBeTruthy() + expect(screen.getByText('0 erreur bloquante')).toBeTruthy() }) })