feat(editor): cancel adding a reference by button or Escape
Draft tile gets « Annuler l'ajout »; Escape cancels from non-text targets and from a pristine text field, never while composing or already handled. Nothing reaches the document, history untouched, focus back on the add button.
This commit is contained in:
1 parent
1e19479853
commit
d1779928a9
10 files changed
+1138
-524
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
editorActor,
|
||||
historyButton,
|
||||
libraryRoot,
|
||||
openEditor,
|
||||
openTab,
|
||||
@@ -419,6 +420,47 @@ test.describe('reference tiles, search, sort and add', () => {
|
||||
await expect(libraryRoot(page).getByText('Étude')).toHaveCount(0)
|
||||
})
|
||||
|
||||
test("« Annuler l'ajout » and Escape drop the draft and write nothing", async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
const { actor } = await open(page, sortShape)
|
||||
requests.forbid(actor.account.email, actor.account.password)
|
||||
await openTab(page, dict, 'references')
|
||||
const root = libraryRoot(page)
|
||||
const add = root.getByRole('button', {
|
||||
name: dict['editor.references.add'],
|
||||
})
|
||||
const count = await headers(page).count()
|
||||
const states = async () => [
|
||||
await historyButton(page, dict, 'undo').isEnabled(),
|
||||
await historyButton(page, dict, 'redo').isEnabled(),
|
||||
]
|
||||
const before = await states()
|
||||
const draft = root.getByRole('region', {
|
||||
name: dict['editor.reference.new'],
|
||||
})
|
||||
const type = root.getByLabel(dict['editor.reference.type'])
|
||||
await add.click()
|
||||
await type.selectOption('manual')
|
||||
await root.getByLabel(dict['editor.reference.citation']).fill('Brouillon')
|
||||
await root
|
||||
.getByRole('button', { name: dict['editor.references.add_cancel'] })
|
||||
.click()
|
||||
await expect(draft).toHaveCount(0)
|
||||
await expect(headers(page)).toHaveCount(count)
|
||||
await expect(add).toBeFocused()
|
||||
expect(await states()).toEqual(before)
|
||||
await add.click()
|
||||
await type.focus()
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(draft).toHaveCount(0)
|
||||
await expect(headers(page)).toHaveCount(count)
|
||||
await expect(add).toBeFocused()
|
||||
expect(await states()).toEqual(before)
|
||||
})
|
||||
|
||||
test('a tile in edit keeps its place under a sort and under a search', async ({
|
||||
page,
|
||||
requests,
|
||||
|
||||
Reference in new issue
Block a user