Board 23 / 24 / 27 tiles: closed (citation on two lines, type, « Citée
{n} fois » / « Non citée »), open (Type, DOI, URL as safe links, the
citers with « famille » badge and « Aller à »), edit (« Terminer » with a
leave guard re-committing every changed field; a refusal keeps edit
and focuses the field). A cited reference shows the deletion hint, an
uncited one keeps « Supprimer ». Read-only keeps DOI, URL, « Aller à ».
« Terminer » keeps focus in the field on press, so a refusal message
can no longer move the button under the pointer.
Gates: typecheck, lint, test:run (app 1419), build, e2e:ui 251;
e2e:shell 16 specs on db:sandbox (editor-equine never listed): 111
passed / 99 skipped / 3 failed in the new editor-references.spec (two
test bugs, one app bug), fixed and rerun: 5 passed / 4 skipped; full-row
guard: no pre-existing row changed in any table.
## R-24 (removed or rewritten assertions)
| file | old | new |
|---|---|---|
| editor-citations.test.ts | `citationCounts` counts 2/1/0, memoised, empty | `citersOf`: ordered citers (Cat, Node), family flag, trail from zone, key, memoised, empty |
| editor-references-tab.test.tsx | cards say « citée N fois » (ref-a 1, ref-c 0) | « Citée 2 fois » (fixture gains a node citing ref-a), « Citée 1 fois », « Non citée » |
| same | ids `#tab-reference-ref-a-citation` exist when closed | header id `#tab-reference-0-ref-a-header`; field ids only inside an open edit tile |
| same | ↑/↓ on every card | in open tiles only, absent under a search |
| same | Ctrl+Z on an always-visible field | open tile, Modifier, then same assertion on `#tab-reference-0-ref-a-citation` |
| same | « Aller à » focuses the card (`listitem` count 3, focus key) | tile opened (aria-expanded true), header focused, 3 tiles |
| same | add: `getByText('Nouvelle source')` | tile header named « Nouvelle source » |
| same | read-only: no Supprimer / add | same after opening every tile |
| editor-tabs-lists.test.tsx | edit on blur and arrows on always-open cards | open tile, Modifier, blur applies, Terminer, Monter on opened tile |
| same | cited reference deletion refused in a dialog listing citers | REMOVED: no Supprimer on a cited tile (hint asserted, citer listed); uncited delete kept. The dialog's blocked path stays covered by `DeleteDialog`'s own tests |
| same | read-only: no button at all | read-only: facts shown, no Modifier / Supprimer / Citation textbox (header buttons exist now) |
| editor-keep-alive.test.tsx:~330 | tab-click commit of `#tab-reference-ref-1-citation` | opens tile + Modifier first, id `#tab-reference-0-ref-1-citation` |
| editor-keep-alive.test.tsx:~350,367 | `#panel-reference-ref-1-citation` | `#panel-reference-0-ref-1-citation` |
| editor-references-panel.test.tsx | « citée 2 fois / 1 fois » | « Citée 2 fois / 1 fois » |
| same | `#panel-reference-ref-a-citation`; no `#tab-reference-ref-a-citation` | `#panel-reference-0-ref-a-citation`; no `[id^="tab-reference-"]` while the tab tiles are closed |
| same | ids unique, tab and panel field ids present | tab tile opened in edit first; `tab-reference-0-ref-a-citation` and `panel-reference-0-ref-a-citation` unique |
| e2e editor-structures.spec.ts:~88-110 | citation inputs count 3/1/2, « citée 0 fois » x2, « citée 1 fois », move via row buttons | tile headers count, « Non citée » x2, « Citée 1 fois », tile opened before Monter/Supprimer, `tiles.nth(1)` contains the moved text (saved-list assertion unchanged) |
## i18n (fr / en)
Changed (in place, P18): `editor.references.cited_one|other`: « citée {count} fois » -> « Citée {count} fois »; « cited {count} time(s) » -> « Cited {count} time(s) ».
Added: `editor.references.uncited` Non citée / Not cited; `citers_one|other` « Citée {count} fois, par : » / « Cited {count} time(s), by: »; `no_citers` « Aucun constat ni aucune famille ne cite cette référence. » / « No finding or family cites this reference. »; `family` famille / family; `go_to` Aller à / Go to; `edit` Modifier / Edit; `done` Terminer / Done; `edit_title` Modifier la référence / Edit the reference; `url_label` URL / URL; `none_doi` Aucun / None; `none_url` Aucune / None; `new_tab` (nouvel onglet) / (new tab) (sr-only); `delete_hint` (REVUE wording, fr and en).
Removed: none. R10 grep (src, tests, e2e incl. editor-equine) found no reader of the old lowercase wording left.
88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
|
|
import { citersOf } from '@/editor/references/citations'
|
|
import { edit, insert } from '../helpers/editorFixtures'
|
|
import { baseText } from '../helpers/editorHarness'
|
|
|
|
const name = (n: string) => ({ fr: n, en: n })
|
|
const reference = (id: string) =>
|
|
({
|
|
kind: 'reference',
|
|
value: { id, type: 'book', citation: id, url: null, doi: null },
|
|
}) as const
|
|
|
|
function citing(): AnatomicalSheetDocument {
|
|
let text = insert(baseText(), reference('ref-a'))
|
|
text = insert(text, reference('ref-b'))
|
|
text = insert(text, reference('ref-none'))
|
|
text = insert(text, {
|
|
kind: 'zone',
|
|
value: { id: 'zone-a', name: name('Zone'), categories: [] },
|
|
})
|
|
text = edit(text, {
|
|
op: 'insert',
|
|
parent: { kind: 'zone', id: 'zone-a' },
|
|
element: {
|
|
kind: 'finding_category',
|
|
value: {
|
|
id: 'fcat-a',
|
|
kind: 'dysfunction',
|
|
name: name('Cat'),
|
|
description: {},
|
|
reference_ids: ['ref-a', 'ref-b'],
|
|
review_status: 'to_confirm',
|
|
children: [],
|
|
},
|
|
},
|
|
})
|
|
text = edit(text, {
|
|
op: 'insert',
|
|
parent: { kind: 'finding', zone_id: 'zone-a', path: ['fcat-a'] },
|
|
element: {
|
|
kind: 'finding_node',
|
|
value: {
|
|
id: 'fnode-a',
|
|
name: name('Node'),
|
|
description: {},
|
|
requires_vet_referral: false,
|
|
reference_ids: ['ref-a'],
|
|
review_status: 'to_confirm',
|
|
children: [],
|
|
},
|
|
},
|
|
})
|
|
return JSON.parse(text)
|
|
}
|
|
|
|
describe('citersOf', () => {
|
|
it('lists the citers of a category and of nested nodes, in document order', () => {
|
|
const citers = citersOf(citing())
|
|
const names = (id: string) => (citers.get(id) ?? []).map((c) => c.name.fr)
|
|
expect(names('ref-a')).toEqual(['Cat', 'Node'])
|
|
expect(names('ref-b')).toEqual(['Cat'])
|
|
expect(citers.get('ref-none')).toBeUndefined()
|
|
})
|
|
|
|
it('marks families and gives the trail from the zone', () => {
|
|
const [family, node] = citersOf(citing()).get('ref-a')!
|
|
expect(family.isFamily).toBe(true)
|
|
expect(family.trail.map((t) => t.fr)).toEqual(['Zone'])
|
|
expect(node.isFamily).toBe(false)
|
|
expect(node.trail.map((t) => t.fr)).toEqual(['Zone', 'Cat'])
|
|
expect(node.key).toEqual({
|
|
kind: 'finding',
|
|
zone_id: 'zone-a',
|
|
path: ['fcat-a', 'fnode-a'],
|
|
})
|
|
})
|
|
|
|
it('is memoised on the parsed document', () => {
|
|
const doc = citing()
|
|
expect(citersOf(doc)).toBe(citersOf(doc))
|
|
})
|
|
|
|
it('is empty without findings', () => {
|
|
expect(citersOf(JSON.parse(baseText())).size).toBe(0)
|
|
})
|
|
})
|