test(editor): e2e on the references dialog instead of the sheet
Helpers citationsDialog, closeCitations by the dialog's ✕. Owner journey with tap at 375, keyboard and axe; geometry checks now dialog in viewport with focus inside; refused « Tout afficher » over a dirty form.
This commit is contained in:
1 parent
abc781df52
commit
2c4c771269
10 files changed
+260
-323
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { fr } from '@/i18n/fr'
|
||||
import type { Page, TestInfo } from '@playwright/test'
|
||||
import { expect, test } from '../support/browser'
|
||||
import { expect, expectAccessible, test } from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
editorActor,
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
|
||||
// R2 UX finish, task 3 (R2F-5, R2F-6): the reference dialog, the reading tiles, the
|
||||
// references filtered by a finding, and the owner's journey through the browser history:
|
||||
// finding A, its sheet, « Tout afficher », the filtered tab, a reference edited, Back,
|
||||
// finding A, its references dialog, « Tout afficher », the filtered tab, a reference edited, Back,
|
||||
// Forward, « Revenir au constat », then every Back down to the first entry. The top
|
||||
// layer, the focus and the history rules are the browser's, so they are proved here.
|
||||
|
||||
@@ -34,7 +34,7 @@ const chip = (page: Page) =>
|
||||
libraryRoot(page).getByTestId('editor-references-filter')
|
||||
const headers = (page: Page) =>
|
||||
libraryRoot(page).locator('button[aria-controls][id$="-header"]')
|
||||
const sheetHeaders = (page: Page) =>
|
||||
const citedHeaders = (page: Page) =>
|
||||
panel(page).locator('button[aria-controls][id$="-header"]')
|
||||
const undo = (page: Page) => historyButton(page, dict, 'undo')
|
||||
const dialogs = (page: Page) => page.locator('dialog[open]')
|
||||
@@ -105,14 +105,14 @@ async function expectScrollNear(page: Page, y: number) {
|
||||
.toBeLessThanOrEqual(SCROLL_SLACK)
|
||||
}
|
||||
|
||||
/** Whether the sheet is the dialog on top at the right edge of the viewport. */
|
||||
const sheetOnTop = (page: Page) =>
|
||||
/** Whether the references dialog is on top at the right edge of the viewport. */
|
||||
const citationsOnTop = (page: Page) =>
|
||||
page.evaluate(() => {
|
||||
const top = document.elementFromPoint(window.innerWidth - 40, 100)
|
||||
return !!top?.closest('dialog')?.querySelector('[data-place="citations"]')
|
||||
})
|
||||
|
||||
/** Finding A, its sheet, then « Tout afficher »: the References tab filtered by Constat A. */
|
||||
/** Finding A, its references dialog, then « Tout afficher »: the References tab filtered by Constat A. */
|
||||
async function filteredTab(page: Page) {
|
||||
await openFinding(page, dict, 'Constat A')
|
||||
await entryHolds(page, 'view.finding !== null')
|
||||
@@ -135,9 +135,9 @@ test.describe('the owner journey through the history', () => {
|
||||
await dropLateReplays(context)
|
||||
})
|
||||
|
||||
test("the owner's eight steps, nothing in between: Back returns to finding A with its sheet open", async ({
|
||||
test("the owner's eight steps, nothing in between: Back returns to finding A with its dialog open", async ({
|
||||
page,
|
||||
}) => {
|
||||
}, info) => {
|
||||
test.setTimeout(240_000)
|
||||
await open(page)
|
||||
// 1. the Constats tab; 2. finding A opens.
|
||||
@@ -145,12 +145,13 @@ test.describe('the owner journey through the history', () => {
|
||||
await (await revealFinding(page, 'Constat A')).click()
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await entryHolds(page, 'view.finding !== null')
|
||||
// 3. « 2 références »; 4. the sheet opens and lists the two references.
|
||||
// 3. « 2 références » (a tap at 375 px); 4. the references dialog lists the two.
|
||||
const trigger = page.locator('[data-citations-trigger]:visible')
|
||||
await expect(trigger).toContainText('2 références')
|
||||
await trigger.click()
|
||||
await (isPhone(info) ? trigger.tap() : trigger.click())
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
await expect(sheetHeaders(page)).toHaveCount(2)
|
||||
await expect(citedHeaders(page)).toHaveCount(2)
|
||||
await expectAccessible(page, 'the references dialog over finding A')
|
||||
await entryHolds(page, 'view.finding && view.finding.citations')
|
||||
// The tree behind the dialogs sits at an offset of its own (the page is padded so it
|
||||
// can scroll whatever the viewport): Back must return to it.
|
||||
@@ -170,28 +171,50 @@ test.describe('the owner journey through the history', () => {
|
||||
libraryRoot(page).getByText('2 références', { exact: true }),
|
||||
).toBeVisible()
|
||||
expect(Math.abs((await scrollY(page)) - left)).toBeGreaterThan(SCROLL_SLACK)
|
||||
// 7. browser Back; 8. finding A with its sheet on top, as left.
|
||||
// 7. browser Back; 8. finding A with its references dialog on top, as left.
|
||||
await page.goBack()
|
||||
await expect(dialogs(page)).toHaveCount(2)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await expect(findingDialog(page)).toContainText('Constat A')
|
||||
expect(await sheetOnTop(page)).toBe(true)
|
||||
await expect(sheetHeaders(page)).toHaveCount(2)
|
||||
expect(await citationsOnTop(page)).toBe(true)
|
||||
await expect(citedHeaders(page)).toHaveCount(2)
|
||||
await expectScrollNear(page, left)
|
||||
// Closed by Escape (sheet, then dialog): the tree stays where it was left.
|
||||
// Keyboard: from its ✕, Tab reaches « Tout afficher » and both tiles inside the
|
||||
// references dialog; Escape closes it only, « 2 références » takes the focus back; then
|
||||
// the finding dialog. The tree stays where it was left.
|
||||
const reached = new Set<string>()
|
||||
for (let step = 0; step < 3; step++) {
|
||||
await page.keyboard.press('Tab')
|
||||
const inside = await page.evaluate(
|
||||
() =>
|
||||
!!document.activeElement
|
||||
?.closest('dialog')
|
||||
?.querySelector('[data-place="citations"]'),
|
||||
)
|
||||
expect(inside).toBe(true)
|
||||
reached.add(
|
||||
await page.evaluate(() => document.activeElement?.textContent ?? ''),
|
||||
)
|
||||
}
|
||||
expect([...reached].join('|')).toContain(
|
||||
dict['editor.references.panel_show_all'],
|
||||
)
|
||||
expect([...reached].join('|')).toContain('Référence A')
|
||||
expect([...reached].join('|')).toContain('Référence B')
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(dialogs(page)).toHaveCount(1)
|
||||
await expect(trigger).toBeFocused()
|
||||
await page.keyboard.press('Escape')
|
||||
await expectNoDialog(page)
|
||||
await expectScrollNear(page, left)
|
||||
})
|
||||
|
||||
test('eight steps: finding, sheet, filter, edit, Back, Forward, Revenir au constat, every Back', async ({
|
||||
test('eight steps: finding, references, filter, edit, Back, Forward, Revenir au constat, every Back', async ({
|
||||
page,
|
||||
}, info) => {
|
||||
test.setTimeout(240_000)
|
||||
await open(page)
|
||||
// 1 to 3: the finding dialog, its sheet, « Tout afficher »; 4: the filtered tab.
|
||||
// 1 to 3: the finding dialog, its references, « Tout afficher »; 4: the filtered tab.
|
||||
await filteredTab(page)
|
||||
await expect(headers(page)).toHaveCount(2)
|
||||
await expect(
|
||||
@@ -221,23 +244,23 @@ test.describe('the owner journey through the history', () => {
|
||||
expect(await entryId(page)).toBe(filteredId)
|
||||
await expect(chip(page)).toBeVisible()
|
||||
}
|
||||
// 6: Back lands on finding A with its sheet open and on top; Forward, on the filter.
|
||||
// 6: Back lands on finding A with its references dialog on top; Forward, on the filter.
|
||||
await page.goBack()
|
||||
await expect(dialogs(page)).toHaveCount(2)
|
||||
expect(await sheetOnTop(page)).toBe(true)
|
||||
expect(await citationsOnTop(page)).toBe(true)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await page.goForward()
|
||||
await expectNoDialog(page)
|
||||
await expect(chip(page)).toBeVisible()
|
||||
await expect(headers(page)).toHaveCount(2)
|
||||
// 7: « Revenir au constat » pops to the dialog with its sheet (the entry below shows it).
|
||||
// 7: « Revenir au constat » pops to the dialogs (the entry below shows them).
|
||||
await page
|
||||
.getByRole('button', { name: dict['editor.references.filter_back'] })
|
||||
.click()
|
||||
await expect(dialogs(page)).toHaveCount(2)
|
||||
expect(await sheetOnTop(page)).toBe(true)
|
||||
expect(await citationsOnTop(page)).toBe(true)
|
||||
await entryHolds(page, 'view.finding && view.finding.citations')
|
||||
// 8: every Back down to the first entry: sheet, dialog, tab, drawing, then it leaves.
|
||||
// 8: every Back down to the first entry: references, finding, tab, drawing, then out.
|
||||
await page.goBack()
|
||||
await expect(dialogs(page)).toHaveCount(1)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
@@ -253,7 +276,7 @@ test.describe('the owner journey through the history', () => {
|
||||
await expect.poll(() => page.url()).not.toBe(here)
|
||||
})
|
||||
|
||||
test('a reload keeps the filtered tab and the chip, never a form; Back then returns to the sheet', async ({
|
||||
test('a reload keeps the filtered tab and the chip, never a form; Back then returns to the dialog', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -265,7 +288,7 @@ test.describe('the owner journey through the history', () => {
|
||||
await expect(headers(page)).toHaveCount(2)
|
||||
await page.goBack()
|
||||
await expect(dialogs(page)).toHaveCount(2)
|
||||
expect(await sheetOnTop(page)).toBe(true)
|
||||
expect(await citationsOnTop(page)).toBe(true)
|
||||
})
|
||||
|
||||
test('the × removes the filter by replace; the search text is not in the history', async ({
|
||||
|
||||
Reference in new issue
Block a user