refactor(editor): rename the reference panel's place to citations

Frees the name « references » for the fifth tab (R2.1). The panel's
data-place, PlaceName and ids become citations; no visible change.
EditorTarget, move kind, i18n keys and domain fields keep their names
(removed in R2.1).

R-24 (no assertion removed or weakened): unit editor-route, no-loss,
references-panel, route-recovery ids editor-references-* -> editor-citations-*;
keep-alive inPlace/place('references') -> 'citations'; focus-request
ownedBy 'references' -> 'citations'. e2e support openReferences /
closeReferences, crossing 204/271, journeys 247, layout 234/305,
deselect 229, shell 135 -> place 'citations'; crossing 205 searchbox and
structures 95 « citée 0 fois » -> libraryRoot(page) (new helper).

Gates: typecheck, lint, test:run (app 1382), build, e2e:ui 251 passed,
e2e:shell 7 specs 63 passed / 63 skipped on db:sandbox (editor-equine
not listed); full-row guard: no pre-existing row changed in any table.
This commit is contained in:
bchanot committed 2026-11-12 20:01:47 +01:00
1 parent 65a8fd37b8
commit fc3fec7654
18 files changed
+46 -40

No files matched your search

+1 -1
View File
@@ -226,7 +226,7 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
// The references panel: it closes, the selection stays, a second Escape deselects. // The references panel: it closes, the selection stays, a second Escape deselects.
await openReferences(page, dict) await openReferences(page, dict)
await page.keyboard.press('Escape') await page.keyboard.press('Escape')
await expect(place(page, 'references')).toHaveCount(0) await expect(place(page, 'citations')).toHaveCount(0)
await expectKept(page, POINT) await expectKept(page, POINT)
await box(page).focus() await box(page).focus()
await page.keyboard.press('Escape') await page.keyboard.press('Escape')
@@ -10,6 +10,7 @@ import {
editorActor, editorActor,
geometryField, geometryField,
historyButton, historyButton,
libraryRoot,
openEditor, openEditor,
openReferences, openReferences,
openSection, openSection,
@@ -201,8 +202,8 @@ test.describe('editor shell, width crossing (H)', () => {
dict['editor.reference.add'], dict['editor.reference.add'],
'annotations', 'annotations',
) )
await expect(place(page, 'references')).toBeVisible() await expect(place(page, 'citations')).toBeVisible()
await expect(place(page, 'references').getByRole('searchbox')).toBeVisible() await expect(libraryRoot(page).getByRole('searchbox')).toBeVisible()
}) })
test('the annotation edit body keeps its tool and its pending creation', async ({ test('the annotation edit body keeps its tool and its pending creation', async ({
@@ -268,7 +269,7 @@ test.describe('editor shell, width crossing (H)', () => {
await page.locator('#reference-new-citation').fill('Smith 1999') await page.locator('#reference-new-citation').fill('Smith 1999')
await cross(page, NARROW) await cross(page, NARROW)
await expectReadOnly(page) await expectReadOnly(page)
await expect(place(page, 'references')).toBeVisible() await expect(place(page, 'citations')).toBeVisible()
await expect(saveLine(page)).toHaveText(UNSAVED_LINE) await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
await cross(page, WIDE) await cross(page, WIDE)
await expect(page.locator('#reference-new-citation')).toHaveValue( await expect(page.locator('#reference-new-citation')).toHaveValue(
@@ -244,7 +244,7 @@ test.describe('editor shell journeys (H)', () => {
await selectTab(page, dict, 'verification') await selectTab(page, dict, 'verification')
await goTo('Barone, Ostéologie') await goTo('Barone, Ostéologie')
await expect(place(page, 'references')).toBeVisible() await expect(place(page, 'citations')).toBeVisible()
await focusKey('ref-a') await focusKey('ref-a')
await closeReferences(page, dict) await closeReferences(page, dict)
}) })
@@ -231,7 +231,7 @@ function focusKind(page: Page): Promise<Kind> {
return page.evaluate((undoName) => { return page.evaluate((undoName) => {
const el = document.activeElement const el = document.activeElement
if (!el) return 'other' if (!el) return 'other'
if (el.closest('[data-place="references"]')) return 'panel' if (el.closest('[data-place="citations"]')) return 'panel'
if (el.getAttribute('role') === 'tab') return 'tab' if (el.getAttribute('role') === 'tab') return 'tab'
if (el.closest('[data-testid="history-buttons"]')) { if (el.closest('[data-testid="history-buttons"]')) {
return el.getAttribute('aria-label') === undoName ? 'undo' : 'redo' return el.getAttribute('aria-label') === undoName ? 'undo' : 'redo'
@@ -302,7 +302,7 @@ test.describe('editor shell keyboard order (H)', () => {
}) })
expect(order).toEqual(['header', 'tab', 'undo', 'redo', 'panel']) expect(order).toEqual(['header', 'tab', 'undo', 'redo', 'panel'])
await page.keyboard.press('Escape') await page.keyboard.press('Escape')
await expect(page.locator('[data-place="references"]:visible')).toHaveCount( await expect(page.locator('[data-place="citations"]:visible')).toHaveCount(
0, 0,
) )
const after = await walk(page, 'side') const after = await walk(page, 'side')
+1 -1
View File
@@ -132,7 +132,7 @@ test.describe('editor shell, kept places (B2a)', () => {
.click() .click()
const header = page.locator('main header').first() const header = page.locator('main header').first()
const tabs = page.getByRole('tablist') const tabs = page.getByRole('tablist')
const panel = place(page, 'references') const panel = place(page, 'citations')
const targets = [ const targets = [
page.getByRole('button', { name: dict['common.save'], exact: true }), page.getByRole('button', { name: dict['common.save'], exact: true }),
page.getByRole('button', { page.getByRole('button', {
+2 -2
View File
@@ -6,11 +6,11 @@ import {
bareShape, bareShape,
closeReferences, closeReferences,
editorActor, editorActor,
libraryRoot,
openEditor, openEditor,
openReferences, openReferences,
openSection, openSection,
pickAnnotation, pickAnnotation,
place,
pointOf, pointOf,
revisionText, revisionText,
saveDraft, saveDraft,
@@ -92,7 +92,7 @@ test.describe('editor structures (A4)', () => {
) )
await expect(citations).toHaveCount(2) await expect(citations).toHaveCount(2)
await expect( await expect(
place(page, 'references').getByText('citée 0 fois'), libraryRoot(page).getByText('citée 0 fois'),
).toHaveCount(2) ).toHaveCount(2)
await page await page
.getByRole('searchbox', { name: dict['editor.references.search'] }) .getByRole('searchbox', { name: dict['editor.references.search'] })
+7 -2
View File
@@ -373,6 +373,11 @@ export async function openSection(
await expect(place(page, `annotations.${section}`)).toBeVisible() await expect(place(page, `annotations.${section}`)).toBeVisible()
} }
/** Where the references library shows: today the citations panel (R2.1 moves it to its tab). */
export function libraryRoot(page: Page): Locator {
return place(page, 'citations')
}
/** Opens the references panel from the header button. */ /** Opens the references panel from the header button. */
export async function openReferences(page: Page, dict: Dict) { export async function openReferences(page: Page, dict: Dict) {
const toggle = page.getByRole('button', { const toggle = page.getByRole('button', {
@@ -381,14 +386,14 @@ export async function openReferences(page: Page, dict: Dict) {
}) })
if ((await toggle.getAttribute('aria-expanded')) !== 'true') if ((await toggle.getAttribute('aria-expanded')) !== 'true')
await toggle.click() await toggle.click()
await expect(place(page, 'references')).toBeVisible() await expect(place(page, 'citations')).toBeVisible()
} }
export async function closeReferences(page: Page, dict: Dict) { export async function closeReferences(page: Page, dict: Dict) {
await page await page
.getByRole('button', { name: dict['editor.references.close'] }) .getByRole('button', { name: dict['editor.references.close'] })
.click() .click()
await expect(place(page, 'references')).toHaveCount(0) await expect(place(page, 'citations')).toHaveCount(0)
} }
/** The revision the server holds for the draft. */ /** The revision the server holds for the draft. */
@@ -89,13 +89,13 @@ function Places({ nav, readOnly, reloadSheet }: PlacesProps) {
<div className={`relative ${open ? 'min-h-[calc(100dvh-3.5rem)]' : ''}`}> <div className={`relative ${open ? 'min-h-[calc(100dvh-3.5rem)]' : ''}`}>
{state.referencesMounted && ( {state.referencesMounted && (
<KeptPlace <KeptPlace
name="references" name="citations"
visible={open} visible={open}
className="absolute bottom-0 right-0 top-0 z-20 w-[min(27rem,100%)]" className="absolute bottom-0 right-0 top-0 z-20 w-[min(27rem,100%)]"
> >
<ReferencesPanel <ReferencesPanel
readOnly={readOnly} readOnly={readOnly}
focus={ownedBy(state.focus, 'references')} focus={ownedBy(state.focus, 'citations')}
onClose={nav.closeReferences} onClose={nav.closeReferences}
citedBy={state.references.citedBy} citedBy={state.references.citedBy}
onShowAll={nav.showAllReferences} onShowAll={nav.showAllReferences}
@@ -41,7 +41,7 @@ export default function HeaderActions(props: Props) {
type="button" type="button"
variant="secondary" variant="secondary"
aria-expanded={props.referencesOpen} aria-expanded={props.referencesOpen}
aria-controls="editor-references-panel" aria-controls="editor-citations-panel"
onClick={(event) => props.onToggleReferences(event.currentTarget)} onClick={(event) => props.onToggleReferences(event.currentTarget)}
> >
<Icon name="book" size={16} className="mr-2" /> <Icon name="book" size={16} className="mr-2" />
@@ -69,7 +69,7 @@ function PanelHeader({ onClose }: { onClose: () => void }) {
return ( return (
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-2">
<h2 <h2
id="editor-references-title" id="editor-citations-title"
tabIndex={-1} tabIndex={-1}
data-place-heading data-place-heading
className="flex items-center gap-2 outline-none font-serif text-xl" className="flex items-center gap-2 outline-none font-serif text-xl"
@@ -237,9 +237,9 @@ export default function ReferencesPanel(props: Props) {
} }
return ( return (
<section <section
id="editor-references-panel" id="editor-citations-panel"
data-testid="editor-references-panel" data-testid="editor-citations-panel"
aria-labelledby="editor-references-title" aria-labelledby="editor-citations-title"
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
className="sticky top-14 h-[calc(100dvh-3.5rem)] space-y-3 overflow-y-auto border-l border-[var(--color-border)] bg-[var(--color-surface)] p-4 shadow-xl" className="sticky top-14 h-[calc(100dvh-3.5rem)] space-y-3 overflow-y-auto border-l border-[var(--color-border)] bg-[var(--color-surface)] p-4 shadow-xl"
> >
+2 -2
View File
@@ -19,10 +19,10 @@ export type FocusOutcome = 'found' | 'kept' | 'none'
export type PlaceName = export type PlaceName =
| EditorTabId | EditorTabId
| `annotations.${AnnotationSection}` | `annotations.${AnnotationSection}`
| 'references' | 'citations'
export function placeOf(target: EditorTarget): PlaceName { export function placeOf(target: EditorTarget): PlaceName {
if (target.place === 'references') return 'references' if (target.place === 'references') return 'citations'
if (target.tab !== 'annotations') return target.tab if (target.tab !== 'annotations') return target.tab
return `annotations.${target.section ?? 'drawing'}` return `annotations.${target.section ?? 'drawing'}`
} }
+1 -1
View File
@@ -198,7 +198,7 @@ function referencesBack(opener: HTMLElement | null): HTMLElement | null {
/** Where the focus lands after a programmatic move; never `body`. */ /** Where the focus lands after a programmatic move; never `body`. */
function landingOf(move: Move, state: NavigationState): HTMLElement | null { function landingOf(move: Move, state: NavigationState): HTMLElement | null {
if (move.kind === 'references') return headingOf('references') if (move.kind === 'references') return headingOf('citations')
const place = state.focus ? placeOf(state.focus.target) : shownPlace(state) const place = state.focus ? placeOf(state.focus.target) : shownPlace(state)
return headingOf(place) ?? tabButton(state.tab) return headingOf(place) ?? tabButton(state.tab)
} }
@@ -223,7 +223,7 @@ describe('ownedBy', () => {
expect(ownedBy(view, 'annotations.drawing')).toBeUndefined() expect(ownedBy(view, 'annotations.drawing')).toBeUndefined()
expect(ownedBy(view, 'general')).toBeUndefined() expect(ownedBy(view, 'general')).toBeUndefined()
const ref = request({ kind: 'reference', id: 'ref-a' }) const ref = request({ kind: 'reference', id: 'ref-a' })
expect(ownedBy(ref, 'references')).toBe(ref) expect(ownedBy(ref, 'citations')).toBe(ref)
expect(ownedBy(ref, 'findings')).toBeUndefined() expect(ownedBy(ref, 'findings')).toBeUndefined()
expect(ownedBy(undefined, 'general')).toBeUndefined() expect(ownedBy(undefined, 'general')).toBeUndefined()
}) })
@@ -178,12 +178,12 @@ describe('text typed in a place that is left', () => {
it('the reference add form survives closing and reopening the panel', async () => { it('the reference add form survives closing and reopening the panel', async () => {
const user = await mount() const user = await mount()
await user.click(referencesButton()) await user.click(referencesButton())
const field = inPlace('references').getByLabelText('Citation', { const field = inPlace('citations').getByLabelText('Citation', {
selector: '#reference-new-citation', selector: '#reference-new-citation',
}) })
await user.type(field, 'Smith 1999') await user.type(field, 'Smith 1999')
await user.click(referencesButton()) await user.click(referencesButton())
expect(place('references')).not.toBeVisible() expect(place('citations')).not.toBeVisible()
await user.click(referencesButton()) await user.click(referencesButton())
expect(field).toHaveValue('Smith 1999') expect(field).toHaveValue('Smith 1999')
expect(store.getState().unsaved).toBe(false) expect(store.getState().unsaved).toBe(false)
@@ -311,7 +311,7 @@ describe('a field still focused while a place is left', () => {
const before = store.getState().documentText const before = store.getState().documentText
await user.click(tab(/Vérification/)) await user.click(tab(/Vérification/))
await user.click(referencesButton()) await user.click(referencesButton())
const field = inPlace('references').getByLabelText('Citation', { const field = inPlace('citations').getByLabelText('Citation', {
selector: '#reference-ref-1-citation', selector: '#reference-ref-1-citation',
}) })
await user.click(field) await user.click(field)
@@ -325,7 +325,7 @@ describe('a field still focused while a place is left', () => {
JSON.parse(store.getState().documentText).references[0].citation, JSON.parse(store.getState().documentText).references[0].citation,
).toBe('Doe 2023') ).toBe('Doe 2023')
expect(store.getState().unsaved).toBe(true) expect(store.getState().unsaved).toBe(true)
expect(place('references')).not.toBeVisible() expect(place('citations')).not.toBeVisible()
act(() => void store.getState().undoStep()) act(() => void store.getState().undoStep())
expect(store.getState().documentText).toBe(before) expect(store.getState().documentText).toBe(before)
}) })
@@ -333,13 +333,13 @@ describe('a field still focused while a place is left', () => {
it('Escape in a reference field commits the text before the panel hides', async () => { it('Escape in a reference field commits the text before the panel hides', async () => {
const user = await mount(referenceText()) const user = await mount(referenceText())
await user.click(referencesButton()) await user.click(referencesButton())
const field = inPlace('references').getByLabelText('Citation', { const field = inPlace('citations').getByLabelText('Citation', {
selector: '#reference-ref-1-citation', selector: '#reference-ref-1-citation',
}) })
await user.click(field) await user.click(field)
fireEvent.change(field, { target: { value: 'Doe 2021' } }) fireEvent.change(field, { target: { value: 'Doe 2021' } })
await user.keyboard('{Escape}') await user.keyboard('{Escape}')
expect(place('references')).not.toBeVisible() expect(place('citations')).not.toBeVisible()
const doc: AnatomicalSheetDocument = JSON.parse( const doc: AnatomicalSheetDocument = JSON.parse(
store.getState().documentText, store.getState().documentText,
) )
@@ -350,13 +350,13 @@ describe('a field still focused while a place is left', () => {
it('the header toggle (no focus move) closes the panel after committing', async () => { it('the header toggle (no focus move) closes the panel after committing', async () => {
const user = await mount(referenceText()) const user = await mount(referenceText())
await user.click(referencesButton()) await user.click(referencesButton())
const field = inPlace('references').getByLabelText('Citation', { const field = inPlace('citations').getByLabelText('Citation', {
selector: '#reference-ref-1-citation', selector: '#reference-ref-1-citation',
}) })
await user.click(field) await user.click(field)
fireEvent.change(field, { target: { value: 'Doe 2022' } }) fireEvent.change(field, { target: { value: 'Doe 2022' } })
fireEvent.click(referencesButton()) fireEvent.click(referencesButton())
expect(place('references')).not.toBeVisible() expect(place('citations')).not.toBeVisible()
expect( expect(
JSON.parse(store.getState().documentText).references[0].citation, JSON.parse(store.getState().documentText).references[0].citation,
).toBe('Doe 2022') ).toBe('Doe 2022')
+1 -1
View File
@@ -293,7 +293,7 @@ describe('the guards of a width change', () => {
it('the references search, shown in both modes, keeps its focus and its text', async () => { it('the references search, shown in both modes, keeps its focus and its text', async () => {
const user = await mount() const user = await mount()
await user.click(button('Références')) await user.click(button('Références'))
const panel = screen.getByTestId('editor-references-panel') const panel = screen.getByTestId('editor-citations-panel')
const search = within(panel).getByRole('searchbox', { const search = within(panel).getByRole('searchbox', {
name: 'Rechercher une référence', name: 'Rechercher une référence',
}) })
@@ -83,7 +83,7 @@ function sheetText(): string {
const ready = () => const ready = () =>
screen.findByRole('heading', { level: 1, name: 'Brouillon, version 4' }) screen.findByRole('heading', { level: 1, name: 'Brouillon, version 4' })
const header = () => screen.getByRole('button', { name: 'Références' }) const header = () => screen.getByRole('button', { name: 'Références' })
const panel = () => screen.getByTestId('editor-references-panel') const panel = () => screen.getByTestId('editor-citations-panel')
const cards = () => within(panel()).getAllByRole('listitem') const cards = () => within(panel()).getAllByRole('listitem')
const search = () => const search = () =>
within(panel()).getByRole('searchbox', { name: 'Rechercher une référence' }) within(panel()).getByRole('searchbox', { name: 'Rechercher une référence' })
@@ -91,9 +91,9 @@ describe('the blocking offer', () => {
expect(useLeaveGuardStore.getState().armed).toBe(true) expect(useLeaveGuardStore.getState().armed).toBe(true)
// consultation: tabs still switch // consultation: tabs still switch
await user.click(screen.getByRole('button', { name: 'Références' })) await user.click(screen.getByRole('button', { name: 'Références' }))
expect(screen.getByTestId('editor-references-panel')).toHaveAttribute( expect(screen.getByTestId('editor-citations-panel')).toHaveAttribute(
'aria-labelledby', 'aria-labelledby',
'editor-references-title', 'editor-citations-title',
) )
// editing: refused by the store, no save offered // editing: refused by the store, no save offered
expect(commitMove(40)).toMatchObject({ expect(commitMove(40)).toMatchObject({
+5 -5
View File
@@ -173,9 +173,9 @@ describe('references panel', () => {
mountDraft() mountDraft()
await ready() await ready()
expect(button()).toHaveAttribute('aria-expanded', 'false') expect(button()).toHaveAttribute('aria-expanded', 'false')
expect(screen.queryByTestId('editor-references-panel')).toBeNull() expect(screen.queryByTestId('editor-citations-panel')).toBeNull()
await user.click(button()) await user.click(button())
const panel = screen.getByTestId('editor-references-panel') const panel = screen.getByTestId('editor-citations-panel')
expect(panel).toBeVisible() expect(panel).toBeVisible()
expect(button()).toHaveAttribute('aria-expanded', 'true') expect(button()).toHaveAttribute('aria-expanded', 'true')
expect(document.activeElement).toBe( expect(document.activeElement).toBe(
@@ -197,11 +197,11 @@ describe('references panel', () => {
mountDraft() mountDraft()
await ready() await ready()
await user.click(button()) await user.click(button())
const panel = screen.getByTestId('editor-references-panel') const panel = screen.getByTestId('editor-citations-panel')
await user.keyboard('{Escape}') await user.keyboard('{Escape}')
expect(panel).not.toBeVisible() expect(panel).not.toBeVisible()
await user.click(button()) await user.click(button())
expect(screen.getByTestId('editor-references-panel')).toBe(panel) expect(screen.getByTestId('editor-citations-panel')).toBe(panel)
expect(panel).toBeVisible() expect(panel).toBeVisible()
}) })
@@ -210,7 +210,7 @@ describe('references panel', () => {
mountDraft({ width: 800 }) mountDraft({ width: 800 })
await ready() await ready()
await user.click(button()) await user.click(button())
const panel = screen.getByTestId('editor-references-panel') const panel = screen.getByTestId('editor-citations-panel')
expect(within(panel).queryByRole('textbox')).toBeNull() expect(within(panel).queryByRole('textbox')).toBeNull()
expect( expect(
within(panel).queryByRole('button', { name: 'Ajouter la référence' }), within(panel).queryByRole('button', { name: 'Ajouter la référence' }),