fix(editor): ask only the top refusing layer, safe retry notes
This commit is contained in:
1 parent
f8be0ad01a
commit
ee86a3a659
5 files changed
+92
-15
No files matched your search
@@ -1066,7 +1066,7 @@ describe('the citations sheet over a dirty edit form (final review rev 4, item 1
|
||||
draftKept()
|
||||
})
|
||||
|
||||
it('after the cascade keeps the form, one Back reopens the sheet (docs, limit 6)', async () => {
|
||||
it('after the cascade keeps the form, one Back reopens the sheet (docs, limit 5)', async () => {
|
||||
const user = await sheetOverDirtyForm()
|
||||
const sheet = within(panelOpen()!)
|
||||
const head = sheet.getByRole('button', { name: /^Alpha/ })
|
||||
@@ -1099,6 +1099,68 @@ describe('the citations sheet over a dirty edit form (final review rev 4, item 1
|
||||
draftKept()
|
||||
})
|
||||
|
||||
/** The reference Alpha's edit dialog opened from the sheet; `dirty` types in it. */
|
||||
async function referenceOverSheet(user: User, dirty: boolean) {
|
||||
const sheet = within(panelOpen()!)
|
||||
const head = sheet.getByRole('button', { name: /^Alpha/ })
|
||||
if (head.getAttribute('aria-expanded') === 'false') await user.click(head)
|
||||
const tile = within(head.closest('li')!)
|
||||
await user.click(tile.getByRole('button', { name: 'Modifier' }))
|
||||
await waitFor(() => expect(refForm()).toBeDefined())
|
||||
if (dirty)
|
||||
await user.type(within(refForm()!).getByLabelText('Citation'), ' x')
|
||||
}
|
||||
|
||||
it('a jump of three entries asks the dirty reference only, nothing stays pending under it', async () => {
|
||||
const user = await sheetOverDirtyForm()
|
||||
await referenceOverSheet(user, true)
|
||||
await act(async () => navigate(-3))
|
||||
await waitFor(() => expect(screen.queryAllByText(question)).toHaveLength(1))
|
||||
expect(refForm()!.contains(screen.getByText(question))).toBe(true)
|
||||
await user.click(
|
||||
within(refForm()!).getByRole('button', { name: 'Abandonner' }),
|
||||
)
|
||||
await waitFor(() => expect(refForm()).toBeUndefined())
|
||||
// The refused jump is dropped: the sheet stays, and no question comes up unasked.
|
||||
expect(panelOpen()).not.toBeNull()
|
||||
expect(screen.queryByText(question)).toBeNull()
|
||||
draftKept()
|
||||
})
|
||||
|
||||
it('a clean reference over the sheet over a dirty form: a Back asks the form in view', async () => {
|
||||
const user = await sheetOverDirtyForm()
|
||||
await referenceOverSheet(user, false)
|
||||
await act(async () => navigate(-3))
|
||||
await waitFor(() => expect(panelOpen()).toBeNull())
|
||||
await waitFor(() => expect(refForm()).toBeUndefined())
|
||||
expect(inDialog().getByText(question)).toBeVisible()
|
||||
await waitFor(() =>
|
||||
expect(findingDialog()!.contains(document.activeElement)).toBe(true),
|
||||
)
|
||||
draftKept()
|
||||
})
|
||||
|
||||
it('a clean reference over the sheet over a dirty form: a leave out asks the form in view', async () => {
|
||||
const user = await sheetOverDirtyForm()
|
||||
await referenceOverSheet(user, false)
|
||||
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)
|
||||
})
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
await waitFor(() => expect(panelOpen()).toBeNull())
|
||||
await waitFor(() => expect(refForm()).toBeUndefined())
|
||||
expect(inDialog().getByText(question)).toBeVisible()
|
||||
await waitFor(() =>
|
||||
expect(findingDialog()!.contains(document.activeElement)).toBe(true),
|
||||
)
|
||||
draftKept()
|
||||
})
|
||||
|
||||
it('a jump out of the editor closes the sheet, then the form asks in view', async () => {
|
||||
await sheetOverDirtyForm()
|
||||
const url = new URL('/app/admin/sheets', window.location.origin).href
|
||||
|
||||
Reference in new issue
Block a user