fix(editor): final review round, history, dialogs, Plus and limits
I1 scroll restored at once on a Back into layers; I2 Aller a opens the target dialog in one push; M1-M9, criteria 8 and 17 (left-draft notice), entry caps, no exhaustive-deps disables, locals within 5.
This commit is contained in:
1 parent
ce171427c0
commit
6bf9290da7
25 files changed
+1002
-202
No files matched your search
@@ -452,3 +452,94 @@ describe('read-only flip and the gone rule', () => {
|
||||
expect(findingDialog()).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
const liveText = () =>
|
||||
document.querySelector('p.sr-only[aria-live="polite"]')!.textContent
|
||||
|
||||
describe('final review: a creation whose parent vanishes (M-1)', () => {
|
||||
it('says the dropped names with the gone text, never silently', async () => {
|
||||
const user = await mount()
|
||||
act(() => treeRow(/Cat A/).focus())
|
||||
await user.keyboard('{ArrowUp}{ArrowDown}')
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un constat' }))
|
||||
await waitFor(() => expect(findingDialog()).not.toBeNull())
|
||||
await user.type(document.getElementById('finding-new-name-fr')!, 'Tête')
|
||||
act(() => {
|
||||
store.getState().commit({
|
||||
op: 'remove',
|
||||
key: { kind: 'finding', zone_id: 'zone-a', path: ['fcat-a'] },
|
||||
})
|
||||
})
|
||||
await closed()
|
||||
await waitFor(() =>
|
||||
expect(liveText()).toBe("Saisie abandonnée. Ce constat n'existe plus"),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('final review: the zone of a new category is part of the draft (criterion 8)', () => {
|
||||
it('a zone changed alone asks before « Annuler » closes', async () => {
|
||||
serverHas(
|
||||
insert(sheetText(), {
|
||||
kind: 'zone',
|
||||
value: { id: 'zone-b', name: name('Zone B'), categories: [] },
|
||||
}),
|
||||
3,
|
||||
)
|
||||
const user = userEvent.setup()
|
||||
mountDraft({ width: 1280, probe })
|
||||
await screen.findByRole('heading', {
|
||||
level: 1,
|
||||
name: 'Brouillon, version 4',
|
||||
})
|
||||
await user.click(screen.getByRole('tab', { name: 'Constats' }))
|
||||
await user.click(
|
||||
screen.getByRole('button', { name: 'Ajouter une catégorie' }),
|
||||
)
|
||||
await waitFor(() => expect(findingDialog()).not.toBeNull())
|
||||
await user.selectOptions(inDialog().getByLabelText('Zone'), 'zone-b')
|
||||
await user.click(inDialog().getByRole('button', { name: 'Annuler' }))
|
||||
expect(inDialog().getByText('Abandonner les modifications ?')).toBeVisible()
|
||||
await user.click(
|
||||
inDialog().getByRole('button', { name: 'Continuer la saisie' }),
|
||||
)
|
||||
act(() => inDialog().getByLabelText('Zone').focus())
|
||||
await user.keyboard('{Escape}')
|
||||
expect(findingDialog()).not.toBeNull()
|
||||
expect(inDialog().getByText('Abandonner les modifications ?')).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
describe('final review: leaving the editor with a dirty dialog (criterion 17)', () => {
|
||||
const flagKey = `faunosteo:editor:left-draft:${SHEET}:${USER}`
|
||||
const notice =
|
||||
"Une saisie non enregistrée a été abandonnée en quittant l'éditeur"
|
||||
|
||||
it('leaves one flag without the text, then a notice once on the next mount', async () => {
|
||||
const user = await mount()
|
||||
await openFinding(user, /Node A/)
|
||||
await modify(user)
|
||||
await user.type(nameField(), ' bis')
|
||||
cleanup()
|
||||
const flag = sessionStorage.getItem(flagKey)
|
||||
expect(flag).not.toBeNull()
|
||||
expect(flag).not.toContain('bis')
|
||||
expect(JSON.parse(flag!)).toEqual({
|
||||
kind: 'finding',
|
||||
key: { kind: 'finding', zone_id: 'zone-a', path: ['fcat-a', 'fnode-a'] },
|
||||
})
|
||||
await mount()
|
||||
expect(screen.getByText(notice)).toBeVisible()
|
||||
expect(sessionStorage.getItem(flagKey)).toBeNull()
|
||||
cleanup()
|
||||
await mount()
|
||||
expect(screen.queryByText(notice)).toBeNull()
|
||||
})
|
||||
|
||||
it('a clean dialog leaves no flag', async () => {
|
||||
const user = await mount()
|
||||
await openFinding(user, /Node A/)
|
||||
cleanup()
|
||||
expect(sessionStorage.getItem(flagKey)).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user