test(editor): reference dialog, filter and the owner journey, specs follow the dialog
This commit is contained in:
1 parent
7a64daf251
commit
8b42816270
20 files changed
+1546
-1171
No files matched your search
@@ -222,7 +222,7 @@ describe('opening', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('has no search, no add control; field ids carry the panel prefix', async () => {
|
||||
it('has no search, no add control; « Modifier » opens the reference dialog over the sheet', async () => {
|
||||
const user = await mount()
|
||||
await openFromFinding(user)
|
||||
expect(within(panel()).queryByRole('searchbox')).toBeNull()
|
||||
@@ -231,24 +231,23 @@ describe('opening', () => {
|
||||
).toBeNull()
|
||||
await user.click(within(panel()).getByRole('button', { name: /^Barone/ }))
|
||||
await user.click(within(panel()).getByRole('button', { name: 'Modifier' }))
|
||||
expect(document.querySelectorAll('dialog[open]')).toHaveLength(3)
|
||||
expect(
|
||||
panel().querySelector('#panel-reference-0-ref-a-citation'),
|
||||
).not.toBeNull()
|
||||
expect(document.querySelector('[id^="tab-reference-"]')).toBeNull()
|
||||
screen.getByRole('dialog', { name: 'Modifier la référence' }),
|
||||
).toBeVisible()
|
||||
expect(panel().querySelector('[id$="-citation"]')).toBeNull()
|
||||
})
|
||||
|
||||
it('ids stay unique with the Références tab mounted and the panel open (P14)', async () => {
|
||||
const user = await mount()
|
||||
await user.click(screen.getByRole('tab', { name: 'Références' }))
|
||||
await user.click(screen.getByRole('button', { name: /^Barone/ }))
|
||||
await user.click(screen.getByRole('button', { name: 'Modifier' }))
|
||||
await openFromFinding(user)
|
||||
await user.click(within(panel()).getByRole('button', { name: /^Barone/ }))
|
||||
await user.click(within(panel()).getByRole('button', { name: 'Modifier' }))
|
||||
const ids = [...document.querySelectorAll('[id]')].map((e) => e.id)
|
||||
expect(ids.filter((id, i) => ids.indexOf(id) !== i)).toEqual([])
|
||||
expect(ids).toContain('tab-reference-0-ref-a-citation')
|
||||
expect(ids).toContain('panel-reference-0-ref-a-citation')
|
||||
expect(ids).toContain('tab-reference-0-ref-a-header')
|
||||
expect(ids).toContain('panel-reference-0-ref-a-header')
|
||||
})
|
||||
|
||||
it('read-only: the tiles show, no Modifier, no Retirer, no field', async () => {
|
||||
@@ -348,7 +347,11 @@ describe.each(MODES)('closing, %s', (_label, reduced) => {
|
||||
await focusIs(() =>
|
||||
within(tabPanel).getByRole('heading', { name: 'Références' }),
|
||||
)
|
||||
expect(within(tabPanel).getAllByRole('listitem')).toHaveLength(3)
|
||||
// Filtered by the finding the sheet belonged to: its two citations (R2F-6).
|
||||
expect(within(tabPanel).getAllByRole('listitem')).toHaveLength(2)
|
||||
expect(
|
||||
within(tabPanel).getByText('Références du constat : Node A'),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
it('« Aller à » a citer from a panel tile closes the sheet and opens that finding in its dialog', async () => {
|
||||
@@ -581,90 +584,7 @@ describe('« Retirer de ce constat »', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("a tile in edit when the panel closes (P22'')", () => {
|
||||
async function edit(user: User) {
|
||||
await openFromFinding(user)
|
||||
await user.click(within(panel()).getByRole('button', { name: /^Barone/ }))
|
||||
await user.click(within(panel()).getByRole('button', { name: 'Modifier' }))
|
||||
return panel().querySelector(
|
||||
'#panel-reference-0-ref-a-citation',
|
||||
) as HTMLTextAreaElement
|
||||
}
|
||||
|
||||
it('a valid draft is committed before the close, then the panel closes', async () => {
|
||||
const user = await mount()
|
||||
const field = await edit(user)
|
||||
await user.clear(field)
|
||||
await user.type(field, 'Neuf')
|
||||
await user.click(closeButton())
|
||||
expect(doc().references[0].citation).toBe('Neuf')
|
||||
await closed()
|
||||
await focusIs(() => trigger())
|
||||
})
|
||||
|
||||
it('a refused draft cancels a user close: panel open, field focused, message shown', async () => {
|
||||
const user = await mount()
|
||||
const field = await edit(user)
|
||||
await user.clear(field)
|
||||
await user.click(closeButton())
|
||||
expect(hasPanel()).toBe(true)
|
||||
expect(layer()).not.toHaveAttribute('inert')
|
||||
expect(document.activeElement).toBe(field)
|
||||
expect(within(panel()).getByRole('alert')).toBeVisible()
|
||||
expect(doc().references[0].citation).toBe('Barone, Ostéologie')
|
||||
})
|
||||
|
||||
it('a refused draft cancels « Tout afficher »', async () => {
|
||||
const user = await mount()
|
||||
const field = await edit(user)
|
||||
await user.clear(field)
|
||||
await user.click(
|
||||
within(panel()).getByRole('button', {
|
||||
name: "Tout afficher dans l'onglet Références",
|
||||
}),
|
||||
)
|
||||
expect(hasPanel()).toBe(true)
|
||||
})
|
||||
|
||||
it('a forced close (finding vanished) drops a refused draft and says so', async () => {
|
||||
const user = await mount()
|
||||
const field = await edit(user)
|
||||
await user.clear(field)
|
||||
removeNodeA()
|
||||
await closed()
|
||||
await waitFor(() => expect(findingDialog()).toBeNull())
|
||||
await waitFor(() =>
|
||||
expect(live()).toHaveTextContent(/Saisie non appliquée : Citation/),
|
||||
)
|
||||
expect(doc().references[0].citation).toBe('Barone, Ostéologie')
|
||||
})
|
||||
|
||||
it('Escape in a field of the tile neither closes nor commits', async () => {
|
||||
const user = await mount()
|
||||
const field = await edit(user)
|
||||
await user.clear(field)
|
||||
await user.type(field, 'Neuf')
|
||||
await user.keyboard('{Escape}')
|
||||
expect(hasPanel()).toBe(true)
|
||||
expect(doc().references[0].citation).toBe('Barone, Ostéologie')
|
||||
})
|
||||
|
||||
it('a committed tile edit is one entry, reverted by Défaire once the sheet is closed', async () => {
|
||||
const user = await mount()
|
||||
const field = await edit(user)
|
||||
await user.clear(field)
|
||||
await user.type(field, 'Neuf')
|
||||
fireEvent.blur(field)
|
||||
expect(doc().references[0].citation).toBe('Neuf')
|
||||
await user.click(closeButton())
|
||||
await closed()
|
||||
act(() => void store.getState().undoStep())
|
||||
expect(doc().references[0].citation).toBe('Barone, Ostéologie')
|
||||
})
|
||||
})
|
||||
|
||||
const live = () => document.querySelector('p.sr-only[aria-live="polite"]')
|
||||
const entries = () => store.getState().undo.length
|
||||
const undo = () => act(() => store.getState().undoStep())
|
||||
const nodeKey: ElementKey = {
|
||||
kind: 'finding',
|
||||
@@ -689,44 +609,6 @@ function cite(ids: string[]) {
|
||||
})
|
||||
}
|
||||
|
||||
describe('one user edit, one history entry in the panel (C1)', () => {
|
||||
/** Opens Barone, enters edit and types a URL; the field keeps the focus. */
|
||||
async function typeUrl(user: User) {
|
||||
await openFromFinding(user)
|
||||
await user.click(within(panel()).getByRole('button', { name: /^Barone/ }))
|
||||
await user.click(within(panel()).getByRole('button', { name: 'Modifier' }))
|
||||
const url = panel().querySelector<HTMLInputElement>(
|
||||
'#panel-reference-0-ref-a-url',
|
||||
)!
|
||||
await user.type(url, 'https://a.org/')
|
||||
expect(document.activeElement).toBe(url)
|
||||
return entries()
|
||||
}
|
||||
|
||||
it('✕ pressed with the field still focused (iPadOS) adds one entry', async () => {
|
||||
const user = await mount()
|
||||
const before = await typeUrl(user)
|
||||
fireEvent.click(closeButton())
|
||||
await closed()
|
||||
expect(entries() - before).toBe(1)
|
||||
expect(doc().references[0].url).toBe('https://a.org/')
|
||||
undo()
|
||||
expect(doc().references[0].url).toBeNull()
|
||||
})
|
||||
|
||||
it('a forced close (finding vanished) adds the edit once, besides the removal', async () => {
|
||||
const user = await mount()
|
||||
const before = await typeUrl(user)
|
||||
act(() => {
|
||||
store.getState().commit({ op: 'remove', key: nodeKey })
|
||||
})
|
||||
await closed()
|
||||
expect(entries() - before).toBe(2)
|
||||
await waitFor(() => expect(findingDialog()).toBeNull())
|
||||
expect(doc().references[0].url).toBe('https://a.org/')
|
||||
})
|
||||
})
|
||||
|
||||
describe('the panel review fixes', () => {
|
||||
it('the sheet is a modal dialog named by its title (M4: no announcement needed)', async () => {
|
||||
const user = await mount()
|
||||
|
||||
Reference in new issue
Block a user