feat(editor): sheet landings, history and e2e for the finding layers
« Tout afficher » clears the search and keeps the sort. A landing waits for the dialogs a move closed and for their focus restore. Helpers and shell specs move to the dialog and sheet flow; new finding dialog spec (entries, guards, flip, gone rule, Back and Forward over the layers).
This commit is contained in:
1 parent
18085cecf8
commit
4731a3376a
21 files changed
+782
-474
No files matched your search
@@ -421,11 +421,62 @@ export async function openTab(page: Page, dict: Dict, tab: string) {
|
||||
).toBeVisible()
|
||||
}
|
||||
|
||||
/** The open finding dialog: the layer dialog that is not the citations sheet. */
|
||||
export const findingDialog = (page: Page): Locator =>
|
||||
page
|
||||
.locator('dialog[open][data-layer]')
|
||||
.filter({ hasNot: page.locator('[data-place="citations"]') })
|
||||
|
||||
/** Waits until no modal dialog is open: nothing is typed or pressed before (LRN-111/116). */
|
||||
export const expectNoDialog = (page: Page) =>
|
||||
expect(page.locator('dialog[open]')).toHaveCount(0)
|
||||
|
||||
/**
|
||||
* Opens the citations panel of the finding named `element`: the Constats tab, the tree
|
||||
* expanded down to it, the element selected, its « n références » trigger pressed, the
|
||||
* slide over (the heading holds the focus). Expansion goes depth-first from the first
|
||||
* zone, one node per step, at most `expansions` steps (4 is enough for a small fixture).
|
||||
* The tree expanded down to the row named `element`, from the keyboard (a click on a row
|
||||
* opens its dialog): depth-first from the first zone, one node per step, at most
|
||||
* `expansions` steps (4 is enough for a small fixture).
|
||||
*/
|
||||
export async function revealFinding(
|
||||
page: Page,
|
||||
element: string,
|
||||
expansions = 4,
|
||||
): Promise<Locator> {
|
||||
const item = page.getByRole('treeitem', { name: element })
|
||||
for (let step = 0; step < expansions && (await item.count()) === 0; step++) {
|
||||
const closed = page.getByRole('treeitem', { expanded: false }).first()
|
||||
await closed.focus()
|
||||
await closed.press('ArrowRight')
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the dialog of the finding named `element`: the Constats tab, the tree expanded
|
||||
* down to it, its row activated (a click), the dialog open.
|
||||
*/
|
||||
export async function openFinding(
|
||||
page: Page,
|
||||
dict: Dict,
|
||||
element: string,
|
||||
expansions = 4,
|
||||
) {
|
||||
await openTab(page, dict, 'findings')
|
||||
const item = await revealFinding(page, element, expansions)
|
||||
await item.click()
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
}
|
||||
|
||||
/** Closes the finding dialog with its ✕ and waits until no dialog is left. */
|
||||
export async function closeFinding(page: Page, dict: Dict) {
|
||||
await findingDialog(page)
|
||||
.getByRole('button', { name: dict['common.close'], exact: true })
|
||||
.click()
|
||||
await expectNoDialog(page)
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the citations sheet of the finding named `element`: its dialog, then its
|
||||
* « n références » trigger. The sheet lies over the dialog and holds the focus.
|
||||
*/
|
||||
export async function openCitations(
|
||||
page: Page,
|
||||
@@ -433,26 +484,24 @@ export async function openCitations(
|
||||
element: string,
|
||||
expansions = 4,
|
||||
) {
|
||||
await openTab(page, dict, 'findings')
|
||||
const item = page.getByRole('treeitem', { name: element })
|
||||
for (let step = 0; step < expansions && (await item.count()) === 0; step++) {
|
||||
const closed = page.getByRole('treeitem', { expanded: false }).first()
|
||||
await closed.focus()
|
||||
await closed.press('ArrowRight')
|
||||
}
|
||||
await item.click()
|
||||
await page.locator('[data-citations-trigger]:visible').click()
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
// The slide is over when the panel's heading takes the focus (P9).
|
||||
await expect(page.locator('#editor-citations-title')).toBeFocused()
|
||||
await openFinding(page, dict, element, expansions)
|
||||
await showCitations(page)
|
||||
}
|
||||
|
||||
/** Closes the citations panel with its ✕ button. */
|
||||
/** From the open finding dialog: « n références » opens the sheet over it. */
|
||||
export async function showCitations(page: Page) {
|
||||
await page.locator('[data-citations-trigger]:visible').click()
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||||
}
|
||||
|
||||
/** Closes the citations sheet with its ✕: the finding dialog under it stays open. */
|
||||
export async function closeCitations(page: Page, dict: Dict) {
|
||||
await page
|
||||
.getByRole('button', { name: dict['editor.references.close'] })
|
||||
.click()
|
||||
await expect(place(page, 'citations')).toHaveCount(0)
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(1)
|
||||
}
|
||||
|
||||
/** The revision the server holds for the draft. */
|
||||
|
||||
@@ -11,6 +11,7 @@ import { stepUpAdmin } from './admin'
|
||||
import {
|
||||
TABS,
|
||||
closeCitations,
|
||||
closeFinding,
|
||||
draftPath,
|
||||
editorActor,
|
||||
openCitations,
|
||||
@@ -49,6 +50,7 @@ export default async function warmUp(config: FullConfig): Promise<void> {
|
||||
}
|
||||
await openCitations(page, fr, 'Constat A')
|
||||
await closeCitations(page, fr)
|
||||
await closeFinding(page, fr)
|
||||
await page.goto('/app/admin/sheets/new')
|
||||
await page.waitForLoadState('networkidle')
|
||||
await browser.close()
|
||||
|
||||
Reference in new issue
Block a user