feat(editor): cite references from the finding edit form only
This commit is contained in:
1 parent
afc1051313
commit
f0e49fd447
16 files changed
+519
-395
No files matched your search
@@ -29,7 +29,7 @@ import {
|
||||
} from '../support/editor'
|
||||
|
||||
// V1-2.6 R2 finish: the citations of one finding as a modal side sheet over its dialog
|
||||
// (R2F-4): its contents, « Retirer de ce constat » and « Défaire », « Tout afficher »,
|
||||
// (R2F-4): its contents (no removal: that is the edit form's), « Défaire », « Tout afficher »,
|
||||
// every close path with the focus checked after the exit (motion and reduced motion),
|
||||
// Escape in a tile field, the exiting sheet inert, the keyboard and touch proofs, axe open
|
||||
// (edit, read-only at 375 px), Back and Forward over the layers. The spec seeds its own
|
||||
@@ -100,8 +100,19 @@ const link = (page: Page) =>
|
||||
name: dict['editor.references.panel_show_all'],
|
||||
})
|
||||
const undo = (page: Page) => page.getByRole('button', { name: /Défaire/ })
|
||||
const retire = (tile: Locator) =>
|
||||
tile.getByRole('button', { name: dict['editor.references.remove_citation'] })
|
||||
/** The edit form's « Retirer » of a cited reference, by its citation. */
|
||||
const retire = (page: Page, citation: string) =>
|
||||
findingDialog(page).getByRole('button', {
|
||||
name: `${dict['editor.action.remove']} ${citation}`,
|
||||
})
|
||||
const modify = (page: Page) =>
|
||||
findingDialog(page).getByRole('button', {
|
||||
name: dict['editor.findings.edit'],
|
||||
})
|
||||
const saveForm = (page: Page) =>
|
||||
findingDialog(page).getByRole('button', {
|
||||
name: dict['editor.findings.save'],
|
||||
})
|
||||
|
||||
type Node = { reference_ids: string[]; review_status: string }
|
||||
const nodeOf = (document: Record<string, unknown>) =>
|
||||
@@ -124,7 +135,7 @@ test.describe('citations sheet, editing', () => {
|
||||
await dropLateReplays(context)
|
||||
})
|
||||
|
||||
test('opens over its finding dialog, « Retirer » then one « Défaire », saved status', async ({
|
||||
test('opens over its finding dialog, read-only; the edit form removes, one « Défaire », saved status', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
@@ -152,31 +163,39 @@ test.describe('citations sheet, editing', () => {
|
||||
await expect(
|
||||
tile.getByText(dict['editor.references.this_finding'], { exact: true }),
|
||||
).toBeVisible()
|
||||
await expect(retire(tile)).toBeVisible()
|
||||
await expect(
|
||||
tile.getByRole('button', { name: dict['editor.references.edit'] }),
|
||||
).toBeVisible()
|
||||
for (const name of [
|
||||
dict['editor.action.delete'],
|
||||
dict['editor.action.move_up'],
|
||||
dict['editor.action.remove'],
|
||||
]) {
|
||||
await expect(panel(page).getByRole('button', { name })).toHaveCount(0)
|
||||
}
|
||||
await expectAccessible(page, 'the citations sheet, an open tile')
|
||||
|
||||
// « Retirer » takes the citation out at once; the next tile takes the focus (P20).
|
||||
await retire(tile).click()
|
||||
await expect(heads(page)).toHaveCount(2)
|
||||
await expect(heads(page).nth(1)).toBeFocused()
|
||||
await expect(heads(page).nth(1)).toContainText('Source C')
|
||||
// « Défaire » is out of reach under the dialogs: close them, then one undo restores
|
||||
// the citation and the status together.
|
||||
// The sheet removes nothing: « Modifier » on the dialog stages the removal, the sheet
|
||||
// opened from the form lists the draft, and « Enregistrer » writes it as one entry.
|
||||
await closeCitations(page, dict)
|
||||
await modify(page).click()
|
||||
await retire(page, 'Source B').click()
|
||||
await expect(trigger(page)).toContainText('2')
|
||||
await showCitations(page)
|
||||
await expect(heads(page)).toHaveCount(2)
|
||||
await closeCitations(page, dict)
|
||||
await saveForm(page).click()
|
||||
await expect(trigger(page)).toContainText('2')
|
||||
await closeFinding(page, dict)
|
||||
// one « Défaire » restores the citation and the status together
|
||||
await undo(page).click()
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
await expect(heads(page)).toHaveCount(3)
|
||||
await heads(page).nth(1).click()
|
||||
await retire(tile).click()
|
||||
await expect(heads(page)).toHaveCount(2)
|
||||
await closeCitations(page, dict)
|
||||
await modify(page).click()
|
||||
await retire(page, 'Source B').click()
|
||||
await saveForm(page).click()
|
||||
await expect(trigger(page)).toContainText('2')
|
||||
await closeFinding(page, dict)
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
const saved = await serverDocument<Record<string, unknown>>(seed.draftId)
|
||||
@@ -207,27 +226,23 @@ test.describe('citations sheet, editing', () => {
|
||||
await expect(last).toHaveAttribute('aria-expanded', 'true')
|
||||
})
|
||||
|
||||
test('the last citations gone: the sheet stays with its line, Escape closes it, the dialog stays', async ({
|
||||
test('the form drops every citation: the trigger goes with the count, nothing is written before « Enregistrer »', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
for (const remaining of [2, 1, 0]) {
|
||||
await heads(page).first().click()
|
||||
await retire(heads(page).first().locator('xpath=ancestor::li[1]')).click()
|
||||
await expect(heads(page)).toHaveCount(remaining)
|
||||
await openFinding(page, dict, 'Constat A')
|
||||
await modify(page).click()
|
||||
for (const citation of ['Référence A', 'Source B', 'Source C']) {
|
||||
await retire(page, citation).click()
|
||||
}
|
||||
await expect(trigger(page)).toHaveCount(0)
|
||||
await expect(
|
||||
panel(page).getByText(dict['editor.references.panel_empty']),
|
||||
findingDialog(page).getByText(dict['editor.findings.references_none']),
|
||||
).toBeVisible()
|
||||
await expect(link(page)).toBeVisible()
|
||||
await expect(page.locator('#editor-citations-title')).toBeFocused()
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(panel(page)).toHaveCount(0)
|
||||
// The trigger went with the last citation: the focus stays in the dialog.
|
||||
await saveForm(page).click()
|
||||
await expect(trigger(page)).toHaveCount(0)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await expect(findingDialog(page).locator(':focus')).toHaveCount(1)
|
||||
})
|
||||
|
||||
test('« Tout afficher » closes both layers, clears the search, keeps the sort and the open tiles; Back returns to the sheet', async ({
|
||||
@@ -568,7 +583,7 @@ test.describe('citations sheet, read-only at 375 px', () => {
|
||||
await heads(page).first().click()
|
||||
for (const name of [
|
||||
dict['editor.references.edit'],
|
||||
dict['editor.references.remove_citation'],
|
||||
dict['editor.action.remove'],
|
||||
]) {
|
||||
await expect(panel(page).getByRole('button', { name })).toHaveCount(0)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user