fix(editor): one history entry per reference edit, focus kept
Final review fixes. « Terminer » and every panel close re-committed the edited field against a stale value, adding a second identical history entry so the first « Défaire » seemed to do nothing: the tile now reads the latest applied value (tests assert the undo-length delta). A tile leaving the search on « Terminer » stays pinned until the next view change and keeps focus; « Ajouter la référence » resets search and sort and focuses the new tile. Also: refused draft dropped on a read-only flip is announced; arrow keys respect a refused tab switch; pinned index kept across read-only; the panel announces « Références citées »; search text inserted literally; « Aller à » names its citer; the edit header's name starts with « Terminer. »; undo removing the focused panel tile moves focus per P20; no-result announced once; docs corrected. Gates: typecheck, lint, test:run (app 1510), build, e2e:ui 251; e2e:shell 16 specs (admin and editor-equine excluded): 117 passed / 108 skipped / 1 failed (crossing:211 stuck on the MFA step-up screen before the editor), rerun alone 11 passed; full-row guard: no pre-existing row changed in any table.
This commit is contained in:
1 parent
2182307c62
commit
1bf27014b3
21 files changed
+677
-136
No files matched your search
@@ -1,6 +1,7 @@
|
||||
/** R2.1 and R2.2: the Références tab, the library (search, order, counts, add, « Aller à »). */
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
act,
|
||||
cleanup,
|
||||
fireEvent,
|
||||
render,
|
||||
@@ -412,7 +413,7 @@ describe('an open tile', () => {
|
||||
await user.click(header('Barone'))
|
||||
const open = within(tile('Barone'))
|
||||
expect(open.getByText('Citée 2 fois, par :')).toBeInTheDocument()
|
||||
expect(open.getAllByRole('button', { name: 'Aller à' })).toHaveLength(2)
|
||||
expect(open.getAllByRole('button', { name: /^Aller à / })).toHaveLength(2)
|
||||
expect(open.getAllByText('famille')).toHaveLength(1)
|
||||
expect(open.getByText(/Zone A › Cat A ›/)).toBeInTheDocument()
|
||||
})
|
||||
@@ -442,7 +443,7 @@ describe('an open tile', () => {
|
||||
const user = await mount()
|
||||
await user.click(header('Barone'))
|
||||
const [family] = within(tile('Barone')).getAllByRole('button', {
|
||||
name: 'Aller à',
|
||||
name: /^Aller à /,
|
||||
})
|
||||
await user.click(family)
|
||||
expect(screen.getByRole('tab', { name: 'Constats' })).toHaveAttribute(
|
||||
@@ -473,7 +474,7 @@ describe('a tile in edit', () => {
|
||||
expect(view.getByText('Modifier la référence')).toBeInTheDocument()
|
||||
expect(document.activeElement).toBe(view.getByLabelText('Citation'))
|
||||
expect(view.getByText('Citée 2 fois, par :')).toBeInTheDocument()
|
||||
expect(view.getAllByRole('button', { name: 'Aller à' })).toHaveLength(2)
|
||||
expect(view.getAllByRole('button', { name: /^Aller à / })).toHaveLength(2)
|
||||
for (const name of ['Modifier', 'Supprimer', 'Monter', 'Descendre']) {
|
||||
expect(view.queryByRole('button', { name })).toBeNull()
|
||||
}
|
||||
@@ -546,9 +547,11 @@ describe('a tile in edit', () => {
|
||||
const user = await mount()
|
||||
const item = await startEdit(user, 'Barone')
|
||||
const view = within(item)
|
||||
const before = store.getState().undo.length
|
||||
await user.type(view.getByLabelText('DOI'), '10.1000/xyz')
|
||||
await user.type(view.getByLabelText('Adresse web (URL)'), 'https://a.org/')
|
||||
await user.click(view.getByRole('button', { name: 'Terminer' }))
|
||||
expect(store.getState().undo.length - before).toBe(2)
|
||||
expect(doc().references[0]).toMatchObject({
|
||||
doi: '10.1000/xyz',
|
||||
url: 'https://a.org/',
|
||||
@@ -586,13 +589,82 @@ describe('a tile in edit', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('the disclosure button in edit (M7)', () => {
|
||||
it('is named for what it does, and pressing it ends the edit', async () => {
|
||||
const user = await mount()
|
||||
const item = await startEdit(user, 'Barone')
|
||||
const button = within(item).getByRole('button', {
|
||||
name: /^Terminer\. Modifier la référence/,
|
||||
})
|
||||
expect(button).toHaveAttribute('aria-expanded', 'true')
|
||||
await user.click(button)
|
||||
expect(within(item).queryByLabelText('Citation')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('one user edit, one history entry (C1)', () => {
|
||||
const entries = () => store.getState().undo.length
|
||||
const undo = () => act(() => store.getState().undoStep())
|
||||
|
||||
it('« Terminer » after one typed field adds one entry, the first « Défaire » undoes it', async () => {
|
||||
const user = await mount()
|
||||
const view = within(await startEdit(user, 'Barone'))
|
||||
const before = entries()
|
||||
await user.type(view.getByLabelText('Adresse web (URL)'), 'https://a.org/')
|
||||
await user.click(view.getByRole('button', { name: 'Terminer' }))
|
||||
expect(entries() - before).toBe(1)
|
||||
expect(doc().references[0].url).toBe('https://a.org/')
|
||||
undo()
|
||||
expect(doc().references[0].url).toBeNull()
|
||||
})
|
||||
|
||||
it('« Terminer » pressed with the field still focused (no pointer) adds one entry', async () => {
|
||||
const user = await mount()
|
||||
const view = within(await startEdit(user, 'Barone'))
|
||||
const before = entries()
|
||||
const url = view.getByLabelText('Adresse web (URL)')
|
||||
await user.type(url, 'https://a.org/')
|
||||
expect(document.activeElement).toBe(url)
|
||||
fireEvent.click(view.getByRole('button', { name: 'Terminer' }))
|
||||
expect(entries() - before).toBe(1)
|
||||
undo()
|
||||
expect(doc().references[0].url).toBeNull()
|
||||
})
|
||||
|
||||
it('a tab switch with the field still focused adds one entry', async () => {
|
||||
const user = await mount()
|
||||
const view = within(await startEdit(user, 'Barone'))
|
||||
const before = entries()
|
||||
await user.type(view.getByLabelText('Adresse web (URL)'), 'https://a.org/')
|
||||
fireEvent.click(screen.getByRole('tab', { name: 'Constats' }))
|
||||
expect(entries() - before).toBe(1)
|
||||
undo()
|
||||
expect(doc().references[0].url).toBeNull()
|
||||
})
|
||||
|
||||
it('a blur after the field was applied adds nothing; a changed text adds one more', async () => {
|
||||
const user = await mount()
|
||||
const view = within(await startEdit(user, 'Barone'))
|
||||
const before = entries()
|
||||
const url = view.getByLabelText('Adresse web (URL)')
|
||||
await user.type(url, 'https://a.org/')
|
||||
await user.tab()
|
||||
await user.click(url)
|
||||
await user.tab()
|
||||
expect(entries() - before).toBe(1)
|
||||
await user.type(url, 'x')
|
||||
await user.tab()
|
||||
expect(entries() - before).toBe(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('read-only tiles', () => {
|
||||
it('keep DOI, URL and « Aller à », and offer no edit control', async () => {
|
||||
const user = await mount(800)
|
||||
await user.click(header('Barone'))
|
||||
await user.click(header('Denoix'))
|
||||
const cited = within(tile('Barone'))
|
||||
expect(cited.getAllByRole('button', { name: 'Aller à' })).toHaveLength(2)
|
||||
expect(cited.getAllByRole('button', { name: /^Aller à / })).toHaveLength(2)
|
||||
expect(
|
||||
within(tile('Denoix')).getByRole('link', { name: /exemple\.org/ }),
|
||||
).toBeInTheDocument()
|
||||
|
||||
Reference in new issue
Block a user