fix(editor): announce a draft dropped with its tile
An undo or redo that removes a reference unmounted its tile with the edit view, so the tile's announce effect never ran. The drop now speaks from onDrop itself; the citations panel, unmounting after a forced close that already named the fields, stays quiet.
This commit is contained in:
1 parent
58228ab522
commit
cb1ad47cb0
3 files changed
+170
-16
No files matched your search
@@ -345,6 +345,59 @@ describe('a read-only flip without a refused draft', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('an undo that removes a tile holding a refused draft (V1)', () => {
|
||||
const added = (name: string) =>
|
||||
document.querySelector<HTMLInputElement>(`#tab-reference-3-ref-d-${name}`)!
|
||||
|
||||
/** ref-d inserted by one history entry, then its tile in edit. */
|
||||
async function editInserted() {
|
||||
const user = await mount()
|
||||
act(() => {
|
||||
store
|
||||
.getState()
|
||||
.commit({ op: 'insert', element: ref('ref-d', 'Nouvelle') })
|
||||
})
|
||||
expect(history()).toEqual({ undo: 1, redo: 0 })
|
||||
await editTile(user, 'ref-d', /^Nouvelle/)
|
||||
return user
|
||||
}
|
||||
|
||||
/** From a valid place: « Défaire » pressed from a refused field only refocuses it. */
|
||||
async function undoInsertion(user: User) {
|
||||
await user.tab()
|
||||
expect(document.activeElement).not.toHaveAttribute('aria-invalid', 'true')
|
||||
const watch = watchNotes()
|
||||
await user.click(screen.getByRole('button', { name: /Défaire/ }))
|
||||
await flush()
|
||||
expect(header('ref-d')).toBeNull()
|
||||
expect(doc().references.map((r: { id: string }) => r.id)).toEqual([
|
||||
'ref-a',
|
||||
'ref-b',
|
||||
'ref-c',
|
||||
])
|
||||
expect(history()).toEqual({ undo: 0, redo: 1 })
|
||||
return watch
|
||||
}
|
||||
|
||||
it('says the dropped Citation once', async () => {
|
||||
const user = await editInserted()
|
||||
await user.clear(added('citation'))
|
||||
const watch = await undoInsertion(user)
|
||||
expect(watch.seen).toEqual([`${NOTE} : Citation`])
|
||||
watch.stop()
|
||||
})
|
||||
|
||||
it('names both refused fields, once', async () => {
|
||||
const user = await editInserted()
|
||||
await user.clear(added('citation'))
|
||||
await user.click(added('url'))
|
||||
await user.type(added('url'), 'exemple.org')
|
||||
const watch = await undoInsertion(user)
|
||||
expect(watch.seen).toEqual([`${NOTE} : Citation, Adresse web (URL)`])
|
||||
watch.stop()
|
||||
})
|
||||
})
|
||||
|
||||
/** The citations panel of Node A, its Denoix tile in edit. */
|
||||
async function openPanel(user: User) {
|
||||
await user.click(screen.getByRole('tab', { name: 'Constats' }))
|
||||
@@ -416,6 +469,53 @@ describe('a read-only flip in the citations panel', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('an undo that takes a tile holding a refused draft out of the panel (V1)', () => {
|
||||
it('says the dropped Citation once, the panel stays', async () => {
|
||||
const user = await mount()
|
||||
act(() => {
|
||||
store.getState().commit({
|
||||
op: 'update',
|
||||
key: {
|
||||
kind: 'finding',
|
||||
zone_id: 'zone-a',
|
||||
path: ['fcat-a', 'fnode-a'],
|
||||
},
|
||||
element: {
|
||||
kind: 'finding_node',
|
||||
value: {
|
||||
...doc().finding_zones[0].categories[0].children[0],
|
||||
reference_ids: ['ref-a', 'ref-b', 'ref-c'],
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
expect(history()).toEqual({ undo: 1, redo: 0 })
|
||||
await user.click(screen.getByRole('tab', { name: 'Constats' }))
|
||||
await user.click(screen.getByRole('treeitem', { name: /Cat A/ }))
|
||||
await user.keyboard('{ArrowRight}')
|
||||
await user.click(screen.getByRole('treeitem', { name: /Node A/ }))
|
||||
await user.click(
|
||||
within(screen.getByRole('tabpanel', { name: 'Constats' })).getByRole(
|
||||
'button',
|
||||
{ name: '3 références' },
|
||||
),
|
||||
)
|
||||
const panel = await screen.findByTestId('editor-citations-panel')
|
||||
await user.click(within(panel).getByRole('button', { name: /^Code rural/ }))
|
||||
await user.click(within(panel).getByRole('button', { name: 'Modifier' }))
|
||||
await user.clear(field('ref-c', 'citation', 'panel'))
|
||||
await user.tab()
|
||||
const watch = watchNotes()
|
||||
await user.click(screen.getByRole('button', { name: /Défaire/ }))
|
||||
await flush()
|
||||
expect(header('ref-c', 'panel')).toBeNull()
|
||||
expect(screen.getByTestId('editor-citations-panel')).toBe(panel)
|
||||
expect(history()).toEqual({ undo: 0, redo: 1 })
|
||||
expect(watch.seen).toEqual([`${NOTE} : Citation`])
|
||||
watch.stop()
|
||||
})
|
||||
})
|
||||
|
||||
async function typeBadUrlIn(user: User) {
|
||||
const url = field('ref-b', 'url', 'panel')
|
||||
await user.clear(url)
|
||||
|
||||
Reference in new issue
Block a user