Non-modal panel in a relative container after the tab row (scrim over the tab panels, which are inert while it is open). Chip "Citées par" opened from a finding's Citations block, "Tout afficher (N)", accent- and case-insensitive search on citation, DOI and URL, "citée n fois" per card (citationCounts, memoised TS read; the core stays the authority for refused deletions). Up/down only without filter or search. "Aller à" a reference clears a hiding search then focuses the card. Rewritten assertions (R-24): editor-shell "the references panel keeps its form text and no id repeats" closes the panel before reaching the inert tab panels. Added: Chromium clickability at 1 024 and 1 280 px (top and scrolled), editor-structures count and search, unit editor-references-panel, editor-citations, navigation clear_cited_by.
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
|
|
import { citationCounts } 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('citationCounts', () => {
|
|
it('counts the citers of a category and of nested nodes, zero when uncited', () => {
|
|
const counts = citationCounts(citing())
|
|
expect(counts.get('ref-a')).toBe(2)
|
|
expect(counts.get('ref-b')).toBe(1)
|
|
expect(counts.get('ref-none') ?? 0).toBe(0)
|
|
})
|
|
|
|
it('is memoised on the parsed document', () => {
|
|
const doc = citing()
|
|
expect(citationCounts(doc)).toBe(citationCounts(doc))
|
|
})
|
|
|
|
it('is empty without findings', () => {
|
|
expect(citationCounts(JSON.parse(baseText())).size).toBe(0)
|
|
})
|
|
})
|