644 lines
24 KiB
TypeScript
644 lines
24 KiB
TypeScript
import { fr } from '@/i18n/fr'
|
||
import type { Locator, Page, TestInfo } from '@playwright/test'
|
||
import {
|
||
expect,
|
||
expectAccessible,
|
||
expectNoHorizontalOverflow,
|
||
test,
|
||
} from '../support/browser'
|
||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||
import {
|
||
closeCitations,
|
||
closeFinding,
|
||
editorActor,
|
||
expectNoDialog,
|
||
findingDialog,
|
||
libraryRoot,
|
||
openCitations,
|
||
openEditor,
|
||
openFinding,
|
||
openTab,
|
||
place,
|
||
referenceDialog,
|
||
referenceSettled,
|
||
saveDraft,
|
||
seedDraft,
|
||
serverDocument,
|
||
showCitations,
|
||
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.
|
||
|
||
const dict = fr
|
||
|
||
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
||
|
||
/** « Constat A » cites twelve references: its panel list outgrows the screen. */
|
||
function longShape(document: Record<string, unknown>) {
|
||
shape(document)
|
||
const refs = Array.from({ length: 12 }, (_, index) => ({
|
||
id: `ref-${index}`,
|
||
type: 'book',
|
||
citation: `Ouvrage numéro ${index + 1}`,
|
||
url: null,
|
||
doi: null,
|
||
}))
|
||
document.references = refs
|
||
const zone = (document.finding_zones as { categories: unknown[] }[])[0]
|
||
const family = zone.categories[0] as {
|
||
reference_ids: string[]
|
||
children: { reference_ids: string[] }[]
|
||
}
|
||
family.reference_ids = []
|
||
family.children[0].reference_ids = refs.map((ref) => ref.id)
|
||
}
|
||
|
||
/** « Constat A » cites A, B and C; the family cites B; D is cited by nobody. */
|
||
function shape(document: Record<string, unknown>) {
|
||
standardShape(document)
|
||
const reference = (id: string, citation: string, type = 'book') => ({
|
||
id,
|
||
type,
|
||
citation,
|
||
url: null,
|
||
doi: null,
|
||
})
|
||
document.references = [
|
||
reference('ref-a', 'Référence A'),
|
||
reference('ref-b', 'Source B', 'web'),
|
||
reference('ref-c', 'Source C', 'journal'),
|
||
reference('ref-d', 'Source libre', 'manual'),
|
||
]
|
||
const zone = (document.finding_zones as { categories: unknown[] }[])[0]
|
||
const family = zone.categories[0] as {
|
||
reference_ids: string[]
|
||
children: { reference_ids: string[] }[]
|
||
}
|
||
family.reference_ids = ['ref-b']
|
||
family.children[0].reference_ids = ['ref-a', 'ref-b', 'ref-c']
|
||
}
|
||
|
||
async function open(page: Page, seedShape = shape) {
|
||
const actor = await editorActor('fr')
|
||
const seed = await seedDraft(actor, { shape: seedShape })
|
||
await openEditor(page, dict, actor, seed.sheetId)
|
||
return { actor, seed }
|
||
}
|
||
|
||
const panel = (page: Page) => page.getByTestId('editor-citations-panel')
|
||
const heads = (page: Page) =>
|
||
panel(page).locator('button[aria-controls][id$="-header"]')
|
||
const trigger = (page: Page) => page.locator('[data-citations-trigger]')
|
||
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'],
|
||
})
|
||
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>) =>
|
||
(
|
||
document.finding_zones as {
|
||
categories: { children: Node[] }[]
|
||
}[]
|
||
)[0].categories[0].children[0]
|
||
|
||
test.describe('citations sheet, editing', () => {
|
||
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
||
test.beforeEach(async ({ context }, info) => {
|
||
test.skip(
|
||
isPhone(info),
|
||
'editing needs >= 1 024 px; the read-only twin at 375 px is below',
|
||
) // floor-guard: allow C16 editing needs >= 1024 px; read-only twin in this file
|
||
await routeToSandbox(context)
|
||
})
|
||
test.afterEach(async ({ context }) => {
|
||
await dropLateReplays(context)
|
||
})
|
||
|
||
test('opens over its finding dialog, read-only; the edit form removes, one « Défaire », saved status', async ({
|
||
page,
|
||
requests,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
const { actor, seed } = await open(page)
|
||
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(panel(page)).toContainText(
|
||
'Zone A › Dysfonction A › Constat A',
|
||
)
|
||
await expect(panel(page)).toContainText(
|
||
dict['editor.references.panel_count_other'].replace('{count}', '3'),
|
||
)
|
||
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 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.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')
|
||
|
||
// 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 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)
|
||
expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-c'])
|
||
expect(nodeOf(saved).review_status).toBe('to_confirm')
|
||
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 ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page, longShape)
|
||
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')
|
||
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')
|
||
})
|
||
|
||
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 ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openTab(page, dict, 'references')
|
||
const root = libraryRoot(page)
|
||
await root.getByRole('searchbox').fill('Source')
|
||
await root
|
||
.getByLabel(dict['editor.references.sort_by'])
|
||
.selectOption('citation')
|
||
await root.getByRole('button', { name: /Source B/ }).click()
|
||
await openCitations(page, dict, 'Constat A')
|
||
await link(page).click()
|
||
await expectNoDialog(page)
|
||
await expect(page.locator('#editor-references-title')).toBeFocused()
|
||
await expect(root.getByRole('searchbox')).toHaveValue('')
|
||
await expect(
|
||
root.getByLabel(dict['editor.references.sort_by']),
|
||
).toHaveValue('citation')
|
||
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).
|
||
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.
|
||
await page.goBack()
|
||
await expect(place(page, 'citations')).toBeVisible()
|
||
await expect(findingDialog(page)).toBeVisible()
|
||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||
await page.goForward()
|
||
await expectNoDialog(page)
|
||
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 ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openCitations(page, dict, 'Constat A')
|
||
await page.evaluate(() => {
|
||
const samples: boolean[] = []
|
||
Object.assign(window, { samples })
|
||
const tick = () => {
|
||
const layer = document.querySelector('[data-place="citations"]')
|
||
if (layer === null) return
|
||
samples.push(layer.closest('dialog')?.hasAttribute('inert') ?? false)
|
||
requestAnimationFrame(tick)
|
||
}
|
||
tick()
|
||
})
|
||
const closeButton = panel(page).getByRole('button', {
|
||
name: dict['editor.references.close'],
|
||
})
|
||
await closeButton.dispatchEvent('click')
|
||
await closeButton.dispatchEvent('click').catch(() => undefined)
|
||
await expect(panel(page)).toHaveCount(0)
|
||
const samples = await page.evaluate(
|
||
() => (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.
|
||
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 ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openFinding(page, dict, 'Constat A')
|
||
await trigger(page).focus()
|
||
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.
|
||
const count = await panel(page).evaluate((root) => {
|
||
const sheet = root.closest('dialog')!
|
||
const tabbable = [
|
||
...sheet.querySelectorAll<HTMLElement>(
|
||
'button:not([disabled]), [href], input:not([disabled]), select, textarea',
|
||
),
|
||
]
|
||
tabbable.forEach((el, index) => el.setAttribute('data-kb', String(index)))
|
||
return tabbable.length
|
||
})
|
||
expect(count).toBeGreaterThanOrEqual(5)
|
||
const at = () =>
|
||
page.evaluate(() => document.activeElement?.getAttribute('data-kb'))
|
||
// On open the first control (✕) holds the focus; Tab then walks the rest.
|
||
expect(await at()).toBe('0')
|
||
for (let index = 1; index < count; index++) {
|
||
await page.keyboard.press('Tab')
|
||
expect(await at(), `Tab to control ${index}`).toBe(String(index))
|
||
}
|
||
await page.keyboard.press('Escape')
|
||
await expect(panel(page)).toHaveCount(0)
|
||
await expect(findingDialog(page)).toBeVisible()
|
||
await expect(trigger(page)).toBeFocused()
|
||
})
|
||
})
|
||
|
||
/** Every way out of the sheet, 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.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
|
||
await routeToSandbox(context)
|
||
await page.emulateMedia({
|
||
reducedMotion: reduced ? 'reduce' : 'no-preference',
|
||
})
|
||
})
|
||
test.afterEach(async ({ context }) => {
|
||
await dropLateReplays(context)
|
||
})
|
||
|
||
test('✕, Escape, the scrim and Back give the focus back to the trigger', async ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openCitations(page, dict, 'Constat A')
|
||
await closeCitations(page, dict)
|
||
await expect(trigger(page)).toBeFocused()
|
||
await expect(trigger(page)).toHaveAttribute('aria-expanded', 'false')
|
||
await showCitations(page)
|
||
await page.keyboard.press('Escape')
|
||
await expect(panel(page)).toHaveCount(0)
|
||
await expect(trigger(page)).toBeFocused()
|
||
await showCitations(page)
|
||
await page
|
||
.getByTestId('references-scrim')
|
||
.click({ position: { x: 12, y: 40 } })
|
||
await expect(panel(page)).toHaveCount(0)
|
||
await expect(trigger(page)).toBeFocused()
|
||
await showCitations(page)
|
||
await page.goBack()
|
||
await expect(panel(page)).toHaveCount(0)
|
||
await expect(findingDialog(page)).toBeVisible()
|
||
await expect(trigger(page)).toBeFocused()
|
||
await page.goForward()
|
||
await expect(panel(page)).toBeVisible()
|
||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||
})
|
||
|
||
test('« Tout afficher » and « Aller à » land where the move says', async ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openCitations(page, dict, 'Constat A')
|
||
await link(page).click()
|
||
await expectNoDialog(page)
|
||
await expect(page.locator('#editor-references-title')).toBeFocused()
|
||
|
||
await openCitations(page, dict, 'Constat A')
|
||
await heads(page).nth(1).click()
|
||
await panel(page)
|
||
.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.
|
||
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.
|
||
await page.goBack()
|
||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||
await expect(place(page, 'citations')).toBeVisible()
|
||
await expect(
|
||
findingDialog(page).getByRole('heading', { name: 'Constat A' }),
|
||
).toBeVisible()
|
||
await page.goForward()
|
||
await expect(place(page, 'citations')).toHaveCount(0)
|
||
await expect(family).toBeVisible()
|
||
await closeFinding(page, dict)
|
||
await expect(
|
||
page.getByRole('treeitem', { name: /Dysfonction A/ }),
|
||
).toBeFocused()
|
||
})
|
||
|
||
test('the sheet slides only when motion is allowed', async ({ page }) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openFinding(page, dict, 'Constat A')
|
||
await page.evaluate(() => {
|
||
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)
|
||
}).observe(document.body, {
|
||
subtree: true,
|
||
childList: true,
|
||
attributes: true,
|
||
attributeFilter: ['style'],
|
||
})
|
||
})
|
||
await trigger(page).click()
|
||
await expect(place(page, 'citations')).toBeVisible()
|
||
await expect(page.locator('dialog[open]')).toHaveCount(2)
|
||
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)
|
||
})
|
||
})
|
||
}
|
||
|
||
test.describe('citations sheet, 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')
|
||
await routeToSandbox(context)
|
||
})
|
||
test.afterEach(async ({ context }) => {
|
||
await dropLateReplays(context)
|
||
})
|
||
|
||
test('full width 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()
|
||
expect(box?.width ?? 0).toBeLessThanOrEqual(375)
|
||
expect(Math.abs((box?.width ?? 0) - 375)).toBeLessThan(1)
|
||
await expect(heads(page)).toHaveCount(3)
|
||
await expectNoHorizontalOverflow(page, 'the sheet 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(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 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 ({
|
||
page,
|
||
}) => {
|
||
test.setTimeout(150_000)
|
||
await open(page)
|
||
await openFinding(page, dict, 'Constat A')
|
||
const center = async (target: Locator) => {
|
||
const box = await target.boundingBox()
|
||
return { x: box!.x + box!.width / 2, y: box!.y + box!.height / 2 }
|
||
}
|
||
const tap = async (target: Locator) => {
|
||
const at = await center(target)
|
||
await page.touchscreen.tap(at.x, at.y)
|
||
}
|
||
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.
|
||
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.
|
||
await tap(
|
||
panel(page).getByRole('button', {
|
||
name: dict['editor.references.close'],
|
||
}),
|
||
)
|
||
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'] }),
|
||
)
|
||
await expectNoDialog(page)
|
||
})
|
||
})
|