feat(editor): search, sort, count and add in the Références tab
Search (citation, DOI, URL) with « Effacer la recherche » and Escape;
« Trier par » sheet order, citation (locale collator), citation count,
type (business order); every sort stable on stored order, display only:
document, stored order, ids and history unchanged (unit + e2e). Count
« {n} références » / « {n} sur {total} » counts matching references
only. « Monter » / « Descendre » only in sheet order without search
(A1). « Ajouter une référence » resets search and sort and appends a
draft tile in edit; a tile in edit stays pinned while sorted or
searched; tile state pruned of absent ids. Reset path ready for « Tout
afficher » (R2.4).
Gates: typecheck, lint, test:run (app 1452), build, e2e:ui 251;
e2e:shell 16 specs on db:sandbox (editor-equine never listed): 115
passed / 102 skipped / 2 failed: editor-structures (test-side, fixed,
rerun with editor-references 12 passed / 11 skipped) and admin.spec A0
« Target crashed » during axe on the rights screen (not R2: that
screen renders every grant, 1 282 accumulated e2e fixtures; reported as
an open risk); full-row guard: no pre-existing row changed in any table.
## R-24 (removed or rewritten assertions)
| file | old | new |
|---|---|---|
| editor-references-tab.test.tsx | `#tab-reference-new-citation` present on load | null until « Ajouter une référence » |
| same | no match text « Aucune référence ne correspond. » | notice « Aucune référence ne contient « zzz ». » |
| same | add: form always visible, add clears the search, `getByText('Nouvelle source')` | click « Ajouter une référence » first; new tile header open, focused, search empty, 4 tiles |
| same | « a refused add keeps the search » | REMOVED (P24: add resets the search at once); replaced by « draft opens with citation focused, refused add keeps the draft, no write » |
| editor-tabs-lists.test.tsx | add form directly | click « Ajouter une référence » before the form assertions (same assertions after) |
| editor-keep-alive.test.tsx | form survives tab round trip | same, after opening the draft |
| editor-no-loss.test.tsx | reference form keeps typed text | same, after opening the draft |
| e2e editor-shell.spec (2), editor-shell-crossing.spec, editor-structures.spec | fill `#tab-reference-new-*` directly; `getByText(citation)` visible | open the draft first; structures asserts the new header is focused |
| e2e editor-references.spec keyboard walk | focus search, Tab reaches header 0 | focus « Ajouter une référence » (search, sort, add precede the headers) |
Other readers of `editor.reference.add`/new ids: grep of src, tests, e2e incl. editor-equine found none left unlisted. editor-equine is not affected ("updated, not run": nothing to update).
## i18n (fr / en)
Added: `editor.references.add` Ajouter une référence / Add a reference; `add_help` Type et citation obligatoires. / Type and citation required.; `clear_search` Effacer la recherche / Clear the search; `sort_by` Trier par / Sort by; `sort.sheet|citation|count|type` Ordre de la fiche, Citation (A → Z), Nombre de citations, Type / Sheet order, Citation (A → Z), Number of citations, Type; `count_one|other` {count} référence(s) / reference(s); `count_of_one|other` {count} référence(s) sur {total} / {count} reference(s) of {total}; `reorder_hint` Pour réorganiser, affichez l'ordre de la fiche sans recherche. / To reorder, show the sheet order without a search.; `no_result` Aucune référence ne contient « {q} ». / No reference contains “{q}”.; `no_result_scope` La recherche porte sur la citation, le DOI et l'URL. / The search covers the citation, the DOI and the URL. (REVUE sentence split in two keys so the first half is bold).
Changed: none. Removed: none (`editor.references.no_match` kept, the panel's EmptyLine still uses it).
This commit is contained in:
1 parent
c21995b3fb
commit
3baac4dbb5
26 files changed
+1544
-219
No files matched your search
@@ -155,9 +155,7 @@ describe('the Références tab', () => {
|
||||
expect(
|
||||
tabPanel().querySelector('#tab-reference-0-ref-a-header'),
|
||||
).not.toBeNull()
|
||||
expect(
|
||||
tabPanel().querySelector('#tab-reference-new-citation'),
|
||||
).not.toBeNull()
|
||||
expect(tabPanel().querySelector('#tab-reference-new-citation')).toBeNull()
|
||||
})
|
||||
|
||||
it('matches the citation, the DOI and the URL, ignoring case and accents', async () => {
|
||||
@@ -173,7 +171,7 @@ describe('the Références tab', () => {
|
||||
await user.clear(search())
|
||||
await user.type(search(), 'zzz')
|
||||
expect(
|
||||
within(tabPanel()).getByText('Aucune référence ne correspond.'),
|
||||
within(tabPanel()).getByText('Aucune référence ne contient « zzz ».'),
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -281,7 +279,10 @@ describe('the reset signal', () => {
|
||||
})
|
||||
|
||||
describe('adding a reference', () => {
|
||||
const addButton = () =>
|
||||
within(tabPanel()).getByRole('button', { name: 'Ajouter une référence' })
|
||||
async function add(user: User) {
|
||||
await user.click(addButton())
|
||||
const byId = (id: string) => tabPanel().querySelector<HTMLElement>(id)!
|
||||
await user.selectOptions(byId('#tab-reference-new-type'), 'book')
|
||||
await user.type(byId('#tab-reference-new-citation'), 'Nouvelle source')
|
||||
@@ -290,23 +291,33 @@ describe('adding a reference', () => {
|
||||
)
|
||||
}
|
||||
|
||||
it('clears the search so the new reference shows', async () => {
|
||||
it('resets the search, shows the new tile open and focuses its button', async () => {
|
||||
const user = await mount()
|
||||
await user.type(search(), 'Barone')
|
||||
expect(cards()).toHaveLength(1)
|
||||
await add(user)
|
||||
expect(search()).toHaveValue('')
|
||||
expect(cards()).toHaveLength(4)
|
||||
expect(header('Nouvelle source')).toBeInTheDocument()
|
||||
expect(header('Nouvelle source')).toHaveAttribute('aria-expanded', 'true')
|
||||
expect(document.activeElement).toBe(header('Nouvelle source'))
|
||||
expect(within(tabPanel()).queryByLabelText('Citation')).toBeNull()
|
||||
})
|
||||
|
||||
it('a refused add keeps the search', async () => {
|
||||
it('opens a draft tile with the citation focused, and a refused add keeps it', async () => {
|
||||
const user = await mount()
|
||||
await user.type(search(), 'Barone')
|
||||
await user.click(addButton())
|
||||
expect(search()).toHaveValue('')
|
||||
expect(document.activeElement).toBe(
|
||||
tabPanel().querySelector('#tab-reference-new-citation'),
|
||||
)
|
||||
await user.click(
|
||||
within(tabPanel()).getByRole('button', { name: 'Ajouter la référence' }),
|
||||
)
|
||||
expect(search()).toHaveValue('Barone')
|
||||
expect(within(tabPanel()).getByRole('alert')).toHaveTextContent(
|
||||
'Choisissez un type',
|
||||
)
|
||||
expect(doc().references).toHaveLength(3)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user