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
@@ -8,6 +8,7 @@ import {
|
||||
} from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
citationsDialog,
|
||||
closeCitations,
|
||||
closeFinding,
|
||||
editorActor,
|
||||
@@ -19,8 +20,6 @@ import {
|
||||
openFinding,
|
||||
openTab,
|
||||
place,
|
||||
referenceDialog,
|
||||
referenceSettled,
|
||||
saveDraft,
|
||||
seedDraft,
|
||||
serverDocument,
|
||||
@@ -28,18 +27,19 @@ import {
|
||||
standardShape,
|
||||
} 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 (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
|
||||
// sheet and never touches another.
|
||||
// V1-2.6 R2 finish, Rev 5: the citations of a family or a finding node as a modal
|
||||
// references dialog over the finding dialog. View mode: its contents (no edit control),
|
||||
// the finding's edit form that cites nothing and keeps the citations, « Tout afficher »,
|
||||
// every close path with the focus checked after the exit (motion and reduced motion), the
|
||||
// exiting dialog inert, the keyboard and touch proofs, axe open (desktop, read-only at
|
||||
// 375 px), Back and Forward over the layers. The spec seeds its own sheet and never
|
||||
// touches another.
|
||||
|
||||
const dict = fr
|
||||
|
||||
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
||||
|
||||
/** « Constat A » cites twelve references: its panel list outgrows the screen. */
|
||||
/** « Constat A » cites twelve references (its list outgrows the screen), the family none. */
|
||||
function longShape(document: Record<string, unknown>) {
|
||||
shape(document)
|
||||
const refs = Array.from({ length: 12 }, (_, index) => ({
|
||||
@@ -99,12 +99,6 @@ const link = (page: Page) =>
|
||||
panel(page).getByRole('button', {
|
||||
name: dict['editor.references.panel_show_all'],
|
||||
})
|
||||
const undo = (page: Page) => page.getByRole('button', { name: /Défaire/ })
|
||||
/** 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'],
|
||||
@@ -114,7 +108,11 @@ const saveForm = (page: Page) =>
|
||||
name: dict['editor.findings.save'],
|
||||
})
|
||||
|
||||
type Node = { reference_ids: string[]; review_status: string }
|
||||
type Node = {
|
||||
reference_ids: string[]
|
||||
review_status: string
|
||||
description: { fr?: string }
|
||||
}
|
||||
const nodeOf = (document: Record<string, unknown>) =>
|
||||
(
|
||||
document.finding_zones as {
|
||||
@@ -122,7 +120,7 @@ const nodeOf = (document: Record<string, unknown>) =>
|
||||
}[]
|
||||
)[0].categories[0].children[0]
|
||||
|
||||
test.describe('citations sheet, editing', () => {
|
||||
test.describe('references dialog, view mode', () => {
|
||||
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
||||
test.beforeEach(async ({ context }, info) => {
|
||||
test.skip(
|
||||
@@ -135,7 +133,7 @@ test.describe('citations sheet, editing', () => {
|
||||
await dropLateReplays(context)
|
||||
})
|
||||
|
||||
test('opens over its finding dialog, read-only; the edit form removes, one « Défaire », saved status', async ({
|
||||
test('opens over its finding dialog, read only; the finding form cites nothing and its save keeps them', async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
@@ -144,9 +142,9 @@ test.describe('citations sheet, editing', () => {
|
||||
requests.forbid(actor.account.email, actor.account.password)
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
await expect(trigger(page)).toHaveAttribute('aria-expanded', 'true')
|
||||
await expect(panel(page).getByRole('heading')).toHaveText(
|
||||
dict['editor.references.panel_title'],
|
||||
)
|
||||
await expect(
|
||||
citationsDialog(page).getByRole('heading', { level: 2 }),
|
||||
).toHaveText(dict['editor.references.dialog_title'])
|
||||
await expect(panel(page)).toContainText(
|
||||
'Zone A › Dysfonction A › Constat A',
|
||||
)
|
||||
@@ -156,55 +154,70 @@ test.describe('citations sheet, editing', () => {
|
||||
await expect(heads(page)).toHaveCount(3)
|
||||
await expect(panel(page).getByText('Source libre')).toHaveCount(0)
|
||||
await expect(panel(page).getByRole('searchbox')).toHaveCount(0)
|
||||
await expectAccessible(page, 'the citations sheet, closed tiles')
|
||||
await expectAccessible(page, 'the references dialog, closed tiles')
|
||||
|
||||
await heads(page).nth(1).click()
|
||||
const tile = heads(page).nth(1).locator('xpath=ancestor::li[1]')
|
||||
await expect(
|
||||
tile.getByText(dict['editor.references.this_finding'], { exact: true }),
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
tile.getByRole('button', { name: dict['editor.references.edit'] }),
|
||||
).toBeVisible()
|
||||
for (const name of [
|
||||
dict['editor.references.edit'],
|
||||
dict['editor.action.delete'],
|
||||
dict['editor.action.move_up'],
|
||||
dict['editor.action.remove'],
|
||||
]) {
|
||||
await expect(panel(page).getByRole('button', { name })).toHaveCount(0)
|
||||
await expect(
|
||||
citationsDialog(page).getByRole('button', { name, exact: true }),
|
||||
).toHaveCount(0)
|
||||
}
|
||||
await expectAccessible(page, 'the citations sheet, an open tile')
|
||||
await expectAccessible(page, 'the references dialog, an open tile')
|
||||
|
||||
// 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.
|
||||
// The finding's « Modifier » edits its properties only: no citation control, and its
|
||||
// save keeps the citations the document holds.
|
||||
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 expect(
|
||||
findingDialog(page).getByText(dict['editor.findings.references'], {
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible()
|
||||
await expect(trigger(page)).toContainText('3')
|
||||
await expect(
|
||||
findingDialog(page).getByLabel(dict['editor.findings.reference_add']),
|
||||
).toHaveCount(0)
|
||||
await expect(
|
||||
findingDialog(page).getByRole('button', {
|
||||
name: new RegExp(`^${dict['editor.action.remove']}`),
|
||||
}),
|
||||
).toHaveCount(0)
|
||||
await findingDialog(page)
|
||||
.getByLabel(dict['editor.findings.description_fr'])
|
||||
.fill('Texte')
|
||||
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 closeCitations(page, dict)
|
||||
await modify(page).click()
|
||||
await retire(page, 'Source B').click()
|
||||
await saveForm(page).click()
|
||||
await expect(trigger(page)).toContainText('2')
|
||||
await expect(trigger(page)).toContainText('3')
|
||||
await closeFinding(page, dict)
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
const saved = await serverDocument<Record<string, unknown>>(seed.draftId)
|
||||
expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-c'])
|
||||
expect(nodeOf(saved).review_status).toBe('to_confirm')
|
||||
expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-b', 'ref-c'])
|
||||
expect(nodeOf(saved).description.fr).toBe('Texte')
|
||||
expect((saved.references as unknown[]).length).toBe(4)
|
||||
})
|
||||
|
||||
test('a long list scrolls inside the sheet: the last tile is reachable from scroll 0, the page never moves', async ({
|
||||
test('a family opens the same dialog with its own citations', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await openCitations(page, dict, 'Dysfonction A')
|
||||
await expect(panel(page)).toContainText('Zone A › Dysfonction A')
|
||||
await expect(heads(page)).toHaveCount(1)
|
||||
await expect(heads(page).first()).toContainText('Source B')
|
||||
await closeCitations(page, dict)
|
||||
await expect(trigger(page)).toBeFocused()
|
||||
})
|
||||
|
||||
test('a long list scrolls inside the dialog; « 0 référence » opens the empty one', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -212,40 +225,30 @@ test.describe('citations sheet, editing', () => {
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
await expect(heads(page)).toHaveCount(12)
|
||||
expect(await page.evaluate(() => window.scrollY)).toBe(0)
|
||||
const list = panel(page).locator('div.overflow-y-auto')
|
||||
const list = citationsDialog(page).locator('div.overflow-y-auto')
|
||||
await list.evaluate((node) => {
|
||||
node.scrollTop = node.scrollHeight
|
||||
})
|
||||
const last = heads(page).last()
|
||||
await expect(last).toBeInViewport({ ratio: 1 })
|
||||
const view = await page.evaluate(() => window.innerHeight)
|
||||
const box = await last.boundingBox()
|
||||
expect(box!.y + box!.height).toBeLessThanOrEqual(view + 1)
|
||||
expect(await page.evaluate(() => window.scrollY)).toBe(0)
|
||||
await last.click()
|
||||
await expect(last).toHaveAttribute('aria-expanded', 'true')
|
||||
await closeCitations(page, dict)
|
||||
await closeFinding(page, dict)
|
||||
|
||||
await openFinding(page, dict, 'Dysfonction A')
|
||||
await expect(trigger(page)).toHaveText(
|
||||
dict['editor.findings.references_open_one'].replace('{count}', '0'),
|
||||
)
|
||||
await showCitations(page)
|
||||
await expect(heads(page)).toHaveCount(0)
|
||||
await expect(panel(page)).toContainText(
|
||||
dict['editor.references.panel_empty'],
|
||||
)
|
||||
})
|
||||
|
||||
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 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(
|
||||
findingDialog(page).getByText(dict['editor.findings.references_none']),
|
||||
).toBeVisible()
|
||||
await saveForm(page).click()
|
||||
await expect(trigger(page)).toHaveCount(0)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
})
|
||||
|
||||
test('« Tout afficher » closes both layers, clears the search, keeps the sort and the open tiles; Back returns to the sheet', async ({
|
||||
test('« Tout afficher » closes both layers, clears the search, keeps the sort and the open tiles; Back returns to the dialog', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -268,14 +271,14 @@ test.describe('citations sheet, editing', () => {
|
||||
await expect(
|
||||
root.getByRole('button', { name: /Source B/ }),
|
||||
).toHaveAttribute('aria-expanded', 'true')
|
||||
// Filtered by the finding the sheet belonged to: its three citations (R2F-6).
|
||||
// Filtered by the finding the dialog belonged to: its three citations (R2F-6).
|
||||
await expect(
|
||||
root.locator('button[aria-controls][id$="-header"]'),
|
||||
).toHaveCount(3)
|
||||
await expect(root.getByTestId('editor-references-filter')).toContainText(
|
||||
'Constat A',
|
||||
)
|
||||
// The move is an entry of its own: Back returns to the finding with its sheet on top.
|
||||
// The move is an entry of its own: Back returns to the finding, its dialog on top.
|
||||
await page.goBack()
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
@@ -285,96 +288,7 @@ test.describe('citations sheet, editing', () => {
|
||||
await expect(place(page, 'references')).toBeVisible()
|
||||
})
|
||||
|
||||
test('« Modifier » opens the reference dialog over the sheet; « Enregistrer » closes it only, one undo', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
const { seed } = await open(page)
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
await heads(page).first().click()
|
||||
const modify = panel(page).getByRole('button', {
|
||||
name: dict['editor.references.edit'],
|
||||
})
|
||||
await modify.click()
|
||||
await expect(referenceDialog(page)).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(3)
|
||||
const field = referenceDialog(page).getByLabel(
|
||||
dict['editor.reference.citation'],
|
||||
)
|
||||
await field.fill('Référence A, révisée')
|
||||
// Escape asks (the draft is kept), it neither closes the sheet nor writes.
|
||||
await field.press('Escape')
|
||||
await expect(
|
||||
referenceDialog(page).getByText(dict['editor.findings.discard_ask']),
|
||||
).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(3)
|
||||
await referenceDialog(page)
|
||||
.getByRole('button', { name: dict['editor.findings.keep_typing'] })
|
||||
.click()
|
||||
await expect(field).toHaveValue('Référence A, révisée')
|
||||
await referenceDialog(page)
|
||||
.getByRole('button', { name: dict['editor.findings.save'] })
|
||||
.click()
|
||||
await expect(referenceDialog(page)).toHaveCount(0)
|
||||
await referenceSettled(page)
|
||||
await expect(panel(page)).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||||
await expect(modify).toBeFocused()
|
||||
await closeCitations(page, dict)
|
||||
await closeFinding(page, dict)
|
||||
await expect(undo(page)).toBeEnabled()
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
const saved = await serverDocument<{ references: { citation: string }[] }>(
|
||||
seed.draftId,
|
||||
)
|
||||
expect(saved.references[0].citation).toBe('Référence A, révisée')
|
||||
})
|
||||
|
||||
test('a dirty reference dialog keeps its draft on ✕ and on Back; « Abandonner » leaves the sheet open', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
await heads(page).first().click()
|
||||
await panel(page)
|
||||
.getByRole('button', { name: dict['editor.references.edit'] })
|
||||
.click()
|
||||
const form = referenceDialog(page)
|
||||
const field = form.getByLabel(dict['editor.reference.citation'])
|
||||
await field.fill('Brouillon')
|
||||
await form
|
||||
.getByRole('button', { name: dict['common.close'], exact: true })
|
||||
.click()
|
||||
await expect(
|
||||
form.getByText(dict['editor.findings.discard_ask']),
|
||||
).toBeVisible()
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.keep_typing'] })
|
||||
.click()
|
||||
// Back: the dialog stays, the view is pushed again, the confirmation shows.
|
||||
await page.goBack()
|
||||
await expect(form).toBeVisible()
|
||||
await expect(
|
||||
form.getByText(dict['editor.findings.discard_ask']),
|
||||
).toBeVisible()
|
||||
await expect(field).toHaveValue('Brouillon')
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.keep_typing'] })
|
||||
.click()
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.cancel'] })
|
||||
.click()
|
||||
await form
|
||||
.getByRole('button', { name: dict['editor.findings.discard'] })
|
||||
.click()
|
||||
await expect(referenceDialog(page)).toHaveCount(0)
|
||||
await expect(panel(page)).toBeVisible()
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await expect(undo(page)).toHaveAttribute('aria-disabled', 'true')
|
||||
})
|
||||
|
||||
test('the exiting sheet is inert, and a second close finds nothing to close', async ({
|
||||
test('the exiting dialog is inert, and a second close finds nothing to close', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -391,8 +305,8 @@ test.describe('citations sheet, editing', () => {
|
||||
}
|
||||
tick()
|
||||
})
|
||||
const closeButton = panel(page).getByRole('button', {
|
||||
name: dict['editor.references.close'],
|
||||
const closeButton = citationsDialog(page).getByRole('button', {
|
||||
name: dict['common.close'],
|
||||
})
|
||||
await closeButton.dispatchEvent('click')
|
||||
await closeButton.dispatchEvent('click').catch(() => undefined)
|
||||
@@ -401,12 +315,12 @@ test.describe('citations sheet, editing', () => {
|
||||
() => (window as unknown as { samples: boolean[] }).samples,
|
||||
)
|
||||
expect(samples.some((inert) => inert)).toBe(true)
|
||||
// The dialog under the sheet is still open: the second click closed nothing more.
|
||||
// The finding dialog under it is still open: the second click closed nothing more.
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(1)
|
||||
})
|
||||
|
||||
test('keyboard: Enter opens the sheet, Tab reaches each control in order, Escape from one closes only the sheet', async ({
|
||||
test('keyboard: Enter opens the dialog, Tab reaches each control in order, Escape closes only it', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -416,11 +330,11 @@ test.describe('citations sheet, editing', () => {
|
||||
await page.keyboard.press('Enter')
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||||
// The tab order of the sheet, in the document's order, each control tagged.
|
||||
// The tab order of the dialog, in the document's order, each control tagged.
|
||||
const count = await panel(page).evaluate((root) => {
|
||||
const sheet = root.closest('dialog')!
|
||||
const dialog = root.closest('dialog')!
|
||||
const tabbable = [
|
||||
...sheet.querySelectorAll<HTMLElement>(
|
||||
...dialog.querySelectorAll<HTMLElement>(
|
||||
'button:not([disabled]), [href], input:not([disabled]), select, textarea',
|
||||
),
|
||||
]
|
||||
@@ -443,9 +357,9 @@ test.describe('citations sheet, editing', () => {
|
||||
})
|
||||
})
|
||||
|
||||
/** Every way out of the sheet, the focus read from the document after the exit. */
|
||||
/** Every way out of the dialog, the focus read from the document after the exit. */
|
||||
for (const reduced of [false, true]) {
|
||||
test.describe(`citations sheet closes, ${reduced ? 'reduced motion' : 'motion'}`, () => {
|
||||
test.describe(`references dialog closes, ${reduced ? 'reduced motion' : 'motion'}`, () => {
|
||||
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
||||
test.beforeEach(async ({ context, page }, info) => {
|
||||
test.skip(isPhone(info), 'the paths are walked on desktop') // floor-guard: allow C16 editing needs >= 1 024 px
|
||||
@@ -458,7 +372,7 @@ for (const reduced of [false, true]) {
|
||||
await dropLateReplays(context)
|
||||
})
|
||||
|
||||
test('✕, Escape, the scrim and Back give the focus back to the trigger', async ({
|
||||
test('✕, Escape, the backdrop and Back give the focus back to the trigger', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -472,8 +386,8 @@ for (const reduced of [false, true]) {
|
||||
await expect(panel(page)).toHaveCount(0)
|
||||
await expect(trigger(page)).toBeFocused()
|
||||
await showCitations(page)
|
||||
await page
|
||||
.getByTestId('references-scrim')
|
||||
await citationsDialog(page)
|
||||
.getByTestId('dialog-backdrop')
|
||||
.click({ position: { x: 12, y: 40 } })
|
||||
await expect(panel(page)).toHaveCount(0)
|
||||
await expect(trigger(page)).toBeFocused()
|
||||
@@ -503,14 +417,14 @@ for (const reduced of [false, true]) {
|
||||
.getByRole('button', { name: dict['editor.references.go_to'] })
|
||||
.first()
|
||||
.click()
|
||||
// The sheet closes and the family opens in the dialog (view mode); closed, the
|
||||
// row holds the focus.
|
||||
// The dialog closes and the family opens in the finding dialog (view mode);
|
||||
// closed, the row holds the focus.
|
||||
await expect(place(page, 'citations')).toHaveCount(0)
|
||||
const family = findingDialog(page).getByRole('heading', {
|
||||
name: 'Dysfonction A',
|
||||
})
|
||||
await expect(family).toBeVisible()
|
||||
// Back returns to the place « Aller à » left: Constat A with its sheet open.
|
||||
// Back returns to the place « Aller à » left: Constat A with its dialog open.
|
||||
await page.goBack()
|
||||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
@@ -526,7 +440,9 @@ for (const reduced of [false, true]) {
|
||||
).toBeFocused()
|
||||
})
|
||||
|
||||
test('the sheet slides only when motion is allowed', async ({ page }) => {
|
||||
test('the dialog scales in only when motion is allowed', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await openFinding(page, dict, 'Constat A')
|
||||
@@ -534,10 +450,9 @@ for (const reduced of [false, true]) {
|
||||
const seen: string[] = []
|
||||
Object.assign(window, { seen })
|
||||
new MutationObserver(() => {
|
||||
const slider = document.querySelector(
|
||||
'[data-place="citations"]',
|
||||
) as HTMLElement | null
|
||||
if (slider) seen.push(slider.style.transform)
|
||||
const panel = document.querySelector('[data-place="citations"]')
|
||||
const surface = panel?.closest('dialog > div:last-child')
|
||||
if (surface instanceof HTMLElement) seen.push(surface.style.transform)
|
||||
}).observe(document.body, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
@@ -551,13 +466,13 @@ for (const reduced of [false, true]) {
|
||||
const seen = await page.evaluate(
|
||||
() => (window as unknown as { seen: string[] }).seen,
|
||||
)
|
||||
const slid = seen.some((value) => /translateX\((?!0)[1-9]/.test(value))
|
||||
expect(slid).toBe(!reduced)
|
||||
const scaled = seen.some((value) => /scale\(0\.9/.test(value))
|
||||
expect(scaled).toBe(!reduced)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
test.describe('citations sheet, read-only at 375 px', () => {
|
||||
test.describe('references dialog, read-only at 375 px', () => {
|
||||
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
||||
test.beforeEach(async ({ context }, info) => {
|
||||
test.skip(!isPhone(info), 'the read-only twin runs at 375 px only')
|
||||
@@ -567,41 +482,40 @@ test.describe('citations sheet, read-only at 375 px', () => {
|
||||
await dropLateReplays(context)
|
||||
})
|
||||
|
||||
test('full width through « Plus » then Constats, no edit control, axe open @phone', async ({
|
||||
test('inside the viewport through « Plus » then Constats, no edit control, axe open @phone', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
await open(page)
|
||||
await openCitations(page, dict, 'Constat A')
|
||||
// Full width: the sheet is min(34 rem, 100 vw), so the whole phone screen.
|
||||
const layer = page.locator('[data-place="citations"]')
|
||||
const box = await layer.boundingBox()
|
||||
const box = await citationsDialog(page)
|
||||
.locator('div.overflow-y-auto')
|
||||
.boundingBox()
|
||||
expect(box!.x).toBeGreaterThanOrEqual(0)
|
||||
// Sub-pixel layout rounding (375.00001…): the tolerance of editor-shell-layout (3a7ffa2).
|
||||
expect(box?.width ?? 0).toBeLessThanOrEqual(375 + 0.5)
|
||||
expect(Math.abs((box?.width ?? 0) - 375)).toBeLessThan(1)
|
||||
expect(box!.x + box!.width).toBeLessThanOrEqual(375 + 0.5)
|
||||
expect(box!.y).toBeGreaterThanOrEqual(0)
|
||||
expect(box!.y + box!.height).toBeLessThanOrEqual(667 + 0.5)
|
||||
await expect(heads(page)).toHaveCount(3)
|
||||
await expectNoHorizontalOverflow(page, 'the sheet at 375 px')
|
||||
await expectNoHorizontalOverflow(page, 'the references dialog at 375 px')
|
||||
await heads(page).first().click()
|
||||
for (const name of [
|
||||
dict['editor.references.edit'],
|
||||
dict['editor.action.remove'],
|
||||
]) {
|
||||
await expect(panel(page).getByRole('button', { name })).toHaveCount(0)
|
||||
await expect(
|
||||
citationsDialog(page).getByRole('button', { name, exact: true }),
|
||||
).toHaveCount(0)
|
||||
}
|
||||
await expect(panel(page).getByRole('textbox')).toHaveCount(0)
|
||||
const close = await panel(page)
|
||||
.getByRole('button', { name: dict['editor.references.close'] })
|
||||
.boundingBox()
|
||||
expect(close?.width ?? 0).toBeGreaterThanOrEqual(44)
|
||||
expect(close?.height ?? 0).toBeGreaterThanOrEqual(44)
|
||||
await expectAccessible(page, 'the citations sheet, read-only at 375 px')
|
||||
await expectAccessible(page, 'the references dialog, read-only at 375 px')
|
||||
await closeCitations(page, dict)
|
||||
await expect(trigger(page)).toBeFocused()
|
||||
await closeFinding(page, dict)
|
||||
await expect(place(page, 'findings')).toBeVisible()
|
||||
})
|
||||
|
||||
test('by touch: taps act on the sheet only, the dialog under it is never activated @phone', async ({
|
||||
test('by touch: taps act on the references dialog only, the finding dialog under it stays @phone', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(150_000)
|
||||
@@ -617,25 +531,24 @@ test.describe('citations sheet, read-only at 375 px', () => {
|
||||
}
|
||||
await tap(trigger(page))
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
// A tile opens by a tap; the dialog's own controls underneath stay as they were.
|
||||
// A tile opens by a tap; the finding dialog's controls underneath stay as they were.
|
||||
await tap(heads(page).first())
|
||||
await expect(heads(page).first()).toHaveAttribute('aria-expanded', 'true')
|
||||
await expect(trigger(page)).toHaveAttribute('aria-expanded', 'true')
|
||||
// A tap where the dialog's close button lies (it is under the sheet) hits the sheet.
|
||||
const under = await center(
|
||||
findingDialog(page).getByRole('button', { name: dict['common.close'] }),
|
||||
)
|
||||
await page.touchscreen.tap(under.x, under.y)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
// The sheet's ✕ closes the sheet only; the trigger holds the focus.
|
||||
// Its ✕ closes it only; the trigger holds the focus.
|
||||
await tap(
|
||||
panel(page).getByRole('button', {
|
||||
name: dict['editor.references.close'],
|
||||
}),
|
||||
citationsDialog(page).getByRole('button', { name: dict['common.close'] }),
|
||||
)
|
||||
await expect(panel(page)).toHaveCount(0)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await expect(trigger(page)).toBeFocused()
|
||||
// A tap on its backdrop, outside its panel, closes it only as well.
|
||||
await tap(trigger(page))
|
||||
await expect(place(page, 'citations')).toBeVisible()
|
||||
await page.touchscreen.tap(4, 4)
|
||||
await expect(panel(page)).toHaveCount(0)
|
||||
await expect(findingDialog(page)).toBeVisible()
|
||||
await expect(trigger(page)).toBeFocused()
|
||||
await tap(
|
||||
findingDialog(page).getByRole('button', { name: dict['common.close'] }),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user