feat(editor): references dialog over the finding, view mode
A modal Dialog replaces the citations side sheet; families open it too (isCitable). The finding dialog shows only « Références citées » and « X références », also at zero; its edit form no longer carries reference_ids. A dirty form refusing « Aller à » or « Tout afficher » closes the clean references dialog first.
This commit is contained in:
1 parent
ff21b0315e
commit
abc781df52
29 files changed
+432
-858
No files matched your search
@@ -559,96 +559,3 @@ describe('final review: the creation dialog fades out as a creation (M-9)', () =
|
||||
expect(titles).not.toContain('Modifier la référence')
|
||||
})
|
||||
})
|
||||
|
||||
/** The Navigation API as the leave guard reads it: `navigate` events and `traverseTo`. */
|
||||
class NavigationStub extends EventTarget {
|
||||
traverseTo = vi.fn((key: string) => {
|
||||
void key
|
||||
return { committed: Promise.resolve(), finished: Promise.resolve() }
|
||||
})
|
||||
}
|
||||
|
||||
describe('a jump with the reference over the sheet of a dirty finding (criterion 23)', () => {
|
||||
let api: NavigationStub
|
||||
beforeEach(() => {
|
||||
api = new NavigationStub()
|
||||
Object.defineProperty(window, 'navigation', {
|
||||
value: api,
|
||||
configurable: true,
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
Reflect.deleteProperty(window, 'navigation')
|
||||
})
|
||||
|
||||
const sheet = () =>
|
||||
[...dialogs()].find((d) => d.querySelector('[data-place="citations"]'))
|
||||
const question = 'Abandonner les modifications ?'
|
||||
/** The reference dialog: the finding's edit form is a draft form too. */
|
||||
const refForm = () =>
|
||||
[...dialogs()].find((d) => d.querySelector('#reference-form-citation')) as
|
||||
| HTMLElement
|
||||
| undefined
|
||||
const inForm = () => within(refForm()!)
|
||||
|
||||
function jump() {
|
||||
const url = new URL('/app/admin/sheets', window.location.origin).href
|
||||
const event = Object.assign(new Event('navigate', { cancelable: true }), {
|
||||
navigationType: 'traverse',
|
||||
destination: { url, key: 'list', sameDocument: true },
|
||||
})
|
||||
act(() => {
|
||||
api.dispatchEvent(event)
|
||||
})
|
||||
return event
|
||||
}
|
||||
|
||||
/** Node A in edit with a typed name, its sheet open, Barone in edit with a typed citation. */
|
||||
async function stacked(user: User) {
|
||||
await user.click(screen.getByRole('tab', { name: 'Constats' }))
|
||||
await openFinding(user, /Node A/)
|
||||
const finding = within(findingDialog()!)
|
||||
await user.click(finding.getByRole('button', { name: 'Modifier' }))
|
||||
await user.type(finding.getByLabelText('Nom (FR)'), ' bis')
|
||||
await user.click(finding.getByRole('button', { name: '2 références' }))
|
||||
await waitFor(() => expect(sheet()).toBeDefined())
|
||||
const inSheet = within(sheet() as HTMLElement)
|
||||
const head = inSheet.getByRole('button', { name: /^Barone/ })
|
||||
if (head.getAttribute('aria-expanded') === 'false') await user.click(head)
|
||||
const tile = head.closest('li')!
|
||||
await user.click(within(tile).getByRole('button', { name: 'Modifier' }))
|
||||
await waitFor(() => expect(refForm()).toBeDefined())
|
||||
await user.type(inForm().getByLabelText('Citation'), ' x')
|
||||
}
|
||||
|
||||
it('the finding asks next with the sheet closed, focused; the jump goes after it', async () => {
|
||||
const user = await mount()
|
||||
await stacked(user)
|
||||
expect(jump().defaultPrevented).toBe(true)
|
||||
expect(inForm().getByText(question)).toBeVisible()
|
||||
await user.click(inForm().getByRole('button', { name: 'Abandonner' }))
|
||||
await waitFor(() => expect(refForm()).toBeUndefined())
|
||||
await waitFor(() => expect(sheet()).toBeUndefined())
|
||||
const finding = within(findingDialog()!)
|
||||
expect(finding.getByText(question)).toBeVisible()
|
||||
const keep = finding.getByRole('button', { name: 'Continuer la saisie' })
|
||||
await waitFor(() => expect(keep).toHaveFocus())
|
||||
expect(api.traverseTo).not.toHaveBeenCalled()
|
||||
await user.click(finding.getByRole('button', { name: 'Abandonner' }))
|
||||
expect(api.traverseTo).toHaveBeenCalledWith('list')
|
||||
})
|
||||
|
||||
it('« Continuer la saisie » there keeps the finding draft and drops the jump', async () => {
|
||||
const user = await mount()
|
||||
await stacked(user)
|
||||
jump()
|
||||
await user.click(inForm().getByRole('button', { name: 'Abandonner' }))
|
||||
await waitFor(() => expect(sheet()).toBeUndefined())
|
||||
const finding = within(findingDialog()!)
|
||||
await user.click(
|
||||
finding.getByRole('button', { name: 'Continuer la saisie' }),
|
||||
)
|
||||
expect(finding.getByLabelText('Nom (FR)')).toHaveValue('Node A bis')
|
||||
expect(api.traverseTo).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user