fix(editor): an explicit discard of the citations draft says nothing
This commit is contained in:
1 parent
82bdf8de71
commit
7a5684aace
4 files changed
+69
-9
No files matched your search
@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { act, cleanup, screen, waitFor, within } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import type { Location, NavigateFunction } from 'react-router-dom'
|
||||
import { flushAfterModals } from '@/components/ui/afterModalsClosed'
|
||||
import { ENTRY_KEY, type HistoryEntry } from '@/editor/history/entry'
|
||||
import {
|
||||
forgetSessionTag,
|
||||
@@ -286,7 +287,34 @@ describe('the draft', () => {
|
||||
})
|
||||
})
|
||||
|
||||
const live = () =>
|
||||
document.querySelector('p.sr-only[aria-live="polite"]')!.textContent ?? ''
|
||||
|
||||
describe('leaving the edit mode with changes', () => {
|
||||
it('an explicit « Abandonner » after ✕ closes the dialog without a word', async () => {
|
||||
const user = await mount()
|
||||
await editCitations(user)
|
||||
await removeRow(user, /Barone/)
|
||||
await user.click(button('Fermer'))
|
||||
await user.click(button('Abandonner'))
|
||||
await waitFor(() => expect(citations()).toBeUndefined())
|
||||
await user.click(inFindingDialog().getByRole('button', { name: 'Fermer' }))
|
||||
await waitFor(() => expect(findingDialog()).toBeNull())
|
||||
await act(async () => undefined)
|
||||
expect(live()).not.toContain('Saisie abandonnée')
|
||||
})
|
||||
|
||||
it('a system close of the draft (the finding vanished) says it was dropped', async () => {
|
||||
const user = await mount()
|
||||
await editCitations(user)
|
||||
await removeRow(user, /Barone/)
|
||||
act(() => {
|
||||
store.getState().commit({ op: 'remove', key: nodeKey })
|
||||
})
|
||||
await waitFor(() => expect(citations()).toBeUndefined())
|
||||
await waitFor(() => expect(live()).toContain('Saisie abandonnée'))
|
||||
})
|
||||
|
||||
it('« Annuler » asks; « Abandonner » goes back to the view, nothing written', async () => {
|
||||
const user = await mount()
|
||||
await editCitations(user)
|
||||
@@ -545,6 +573,33 @@ describe('a reference over the references dialog of a dirty finding (criterion 2
|
||||
expect(api.traverseTo).toHaveBeenCalledWith('list')
|
||||
})
|
||||
|
||||
it('the cascade after the user answered « Abandonner » says nothing', async () => {
|
||||
const user = await mount()
|
||||
await openFinding(user, /Node A/)
|
||||
await user.click(
|
||||
inFindingDialog().getByRole('button', { name: 'Modifier' }),
|
||||
)
|
||||
await user.type(inFindingDialog().getByLabelText('Nom (FR)'), ' bis')
|
||||
await user.click(
|
||||
inFindingDialog().getByRole('button', { name: '2 références' }),
|
||||
)
|
||||
await waitFor(() => expect(citations()).toBeDefined())
|
||||
await user.click(button('Modifier'))
|
||||
await removeRow(user, /Barone/)
|
||||
expect(jump().defaultPrevented).toBe(true)
|
||||
await user.click(button('Abandonner'))
|
||||
await waitFor(() => expect(citations()).toBeUndefined())
|
||||
const finding = within(findingDialog()!)
|
||||
await user.click(finding.getByRole('button', { name: 'Abandonner' }))
|
||||
expect(api.traverseTo).toHaveBeenCalledWith('list')
|
||||
// The jump is a stub: the page stays. Its dialogs go, so what waited is said.
|
||||
await act(async () => {
|
||||
document.querySelectorAll('dialog[open]').forEach((d) => d.remove())
|
||||
flushAfterModals()
|
||||
})
|
||||
expect(live()).not.toContain('Saisie abandonnée')
|
||||
})
|
||||
|
||||
it('« Continuer la saisie » there keeps the finding draft and drops the jump', async () => {
|
||||
const user = await mount()
|
||||
await stacked(user)
|
||||
|
||||
Reference in new issue
Block a user