test(tests): the view row in the browser; criterion 32 re-enabled

This commit is contained in:
bchanot committed 2026-11-21 20:33:32 +01:00
1 parent 85cf87695c
commit 068ecd573e
2 files changed
+795 -19

No files matched your search

+782 -17
View File
@@ -1,6 +1,12 @@
import { fr } from '@/i18n/fr'
import type { Locator, Page, TestInfo } from '@playwright/test'
import { expect, expectAccessible, test } from '../support/browser'
import { en } from '@/i18n/en'
import type { BrowserContext, Locator, Page, TestInfo } from '@playwright/test'
import {
expect,
expectAccessible,
expectNoHorizontalOverflow,
test,
} from '../support/browser'
import { expectNoShift } from '../support/layout'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
@@ -8,6 +14,7 @@ import {
clickDrawing,
clientOf,
editorActor,
makeActor,
shownNumber,
shownShape,
openEditor,
@@ -1297,28 +1304,31 @@ for (const viewport of CHIP_WINDOWS) {
await dropLateReplays(context)
})
// owner decision pending (criterion 32, chips on several rows): the budget counts one row
// of chips; measured with eight long names, the stuck column's bottom ends past the
// window bottom (3 to 5 rows of chips). Never made to pass by changing the layout.
test.fixme('the chips take two rows or more; the column keeps below the strip and inside the window', async ({
// The view chips are one scrolling row (U2 criterion 32, owner 2026-11-21): the budget
// counts one row of chips whatever the number of views.
test('the chips share one row that scrolls inside itself; the column keeps below the strip and inside the window', async ({
page,
}) => {
const actor = await editorActor('fr')
const seed = await seedDraft(actor, { shape: chipRowsShape })
await openEditor(page, dict, actor, seed.sheetId)
await expect(tool(page, 'point')).toBeEnabled()
const rows = await page
const row = await page
.getByRole('toolbar', { name: dict['editor.annotations.views'] })
.getByRole('button')
.evaluateAll(
(chips) =>
new Set(chips.map((c) => Math.round(c.getBoundingClientRect().top)))
.size,
)
.evaluate((el) => ({
tops: new Set(
[...el.querySelectorAll('button')].map((c) =>
Math.round(c.getBoundingClientRect().top),
),
).size,
scrollWidth: el.scrollWidth,
clientWidth: el.clientWidth,
}))
expect(row.tops, 'the view chips share one top').toBe(1)
expect(
rows,
'the view chips wrap onto several rows',
).toBeGreaterThanOrEqual(2)
row.scrollWidth,
'the row overflows inside itself',
).toBeGreaterThan(row.clientWidth)
const start = await stripGeometry(page)
const { canvas } = await columnGeometry(page)
@@ -1348,8 +1358,763 @@ for (const viewport of CHIP_WINDOWS) {
}
expect(
overflow,
`column bottom past the window bottom when stuck (${rows} rows)`,
'column bottom past the window bottom when stuck',
).toEqual([])
})
})
}
// U2 criterion 32, the view row itself (owner 2026-11-21, contract criteria 10 to 12): one
// scrolling row of view chips, two hints with chevrons at its edges. The three guarantees
// are named in the tests: « no click lost » (a pointer press on a chip partly under a fade
// activates it at the first click; a chevron press never activates a chip), « reached is
// visible » (a chip reached by Tab, arrows, Home or End lies clear of the fades, except the
// first and the last at the clamp, and can be pressed) and « no vertical move » (the row
// never moves the drawing).
const HINT_CLEAR = 72
/** The row of the shown body: the edit body's twin keeps a hidden one beside it. */
const rowOf = (page: Page) => page.locator('[data-view-row]:visible')
const chipById = (page: Page, id: string) =>
rowOf(page).locator(`[data-view-chip="${id}"]`)
const hintOf = (page: Page, side: 'start' | 'end') =>
page
.locator('[data-view-band]:visible > [aria-hidden="true"]')
.nth(side === 'start' ? 0 : 1)
const chevronOf = (page: Page, side: 'start' | 'end') =>
hintOf(page, side).locator('[title]')
const pressedChip = (page: Page) => rowOf(page).locator('[aria-pressed="true"]')
const LAST_VIEW = 'detail-long-8'
/** The shape of the criterion 32 test plus an annotation on the last view. */
function viewRowShape(document: Record<string, unknown>) {
chipRowsShape(document)
;(document.annotations as unknown[]).push(
pointOf('pt-last', LAST_VIEW, { cx: 200, cy: 200, r: 10 }, 'Pt dernier'),
)
}
async function openRow(page: Page, editing = true) {
const actor = await editorActor('fr')
const seed = await seedDraft(actor, { shape: viewRowShape })
await openEditor(page, dict, actor, seed.sheetId)
if (editing) await expect(tool(page, 'point')).toBeEnabled()
await expect(rowOf(page)).toBeVisible()
return { actor, seed }
}
function rowGeometry(page: Page) {
return rowOf(page).evaluate((row) => {
const box = row.getBoundingClientRect()
return {
scrollLeft: row.scrollLeft,
clientWidth: row.clientWidth,
scrollWidth: row.scrollWidth,
left: box.left,
right: box.right,
}
})
}
/** Instant, so the setup of a case is not itself a smooth scroll to wait for. */
function setRowScroll(page: Page, left: number) {
return rowOf(page).evaluate(
(row, to) => row.scrollTo({ left: to, behavior: 'instant' }),
left,
)
}
/** The `scrollLeft` that puts the chip's left edge `at` px from the row's left edge. */
function scrollLeftFor(page: Page, id: string, at: number) {
return chipById(page, id).evaluate((chip, offset) => {
const row = chip.closest('[data-view-row]') as HTMLElement
const inContent =
chip.getBoundingClientRect().left -
row.getBoundingClientRect().left +
row.scrollLeft
return Math.min(
Math.max(inContent - offset, 0),
row.scrollWidth - row.clientWidth,
)
}, at)
}
/** A smooth scroll settles on its own: poll toward the expected `scrollLeft`. */
async function expectScrollLeft(page: Page, expected: number, tolerance = 4) {
await expect
.poll(
async () => Math.abs((await rowGeometry(page)).scrollLeft - expected),
{
timeout: 2_000,
message: `the row scrolls to ${Math.round(expected)}`,
},
)
.toBeLessThanOrEqual(tolerance)
}
/**
* How far the chip is from « visible and pressable »: its overshoot into a fade (the first and
* the last chip at the clamp excepted) and 100 when what is painted at its centre is not it.
*/
function revealShortfall(page: Page, id: string, pressable: boolean) {
return chipById(page, id).evaluate(
(chip, [clear, pressable]) => {
const row = chip.closest('[data-view-row]') as HTMLElement
const box = chip.getBoundingClientRect()
const rowBox = row.getBoundingClientRect()
const atStart = row.scrollLeft <= 1
const atEnd = row.scrollLeft + row.clientWidth >= row.scrollWidth - 1
const wide = box.width > row.clientWidth - 2 * clear
const left = atStart ? 0 : rowBox.left + clear - box.left
const right = atEnd || wide ? 0 : box.right - (rowBox.right - clear)
const hit = document.elementFromPoint(
box.left + box.width / 2,
box.top + box.height / 2,
)
return Math.max(left, right, !pressable || chip.contains(hit) ? 0 : 100)
},
[HINT_CLEAR, pressable] as const,
)
}
/** `pressable` false under a modal dialog, which covers the chip by design. */
async function expectRevealed(
page: Page,
id: string,
why: string,
pressable = true,
) {
await expect
.poll(() => revealShortfall(page, id, pressable), {
timeout: 2_000,
message: `${id} is clear of the fades and pressable: ${why}`,
})
.toBeLessThanOrEqual(2)
}
/** Focuses the control just before `chip` in the tab order, without scrolling anything. */
function focusBefore(chip: Locator) {
return chip.evaluate((el) => {
const tabbable = [
...document.querySelectorAll<HTMLElement>(
'a[href], button:not(:disabled), input:not(:disabled), select, textarea, [tabindex]',
),
].filter((n) => n.tabIndex >= 0 && n.getClientRects().length > 0)
tabbable[tabbable.indexOf(el as HTMLElement) - 1].focus({
preventScroll: true,
})
})
}
/** The boxes the row must never move, read from the shown elements. */
function columnBoxes(page: Page) {
return page.evaluate(() => {
const parts = {
canvas: '[data-testid="annotation-canvas"]',
strip: '[data-testid="edit-strip"]',
line: '[data-testid="gesture-line"]',
}
return Object.fromEntries(
Object.entries(parts).map(([name, selector]) => {
const box = document.querySelector(selector)?.getBoundingClientRect()
return [name, box && [box.x, box.y, box.width, box.height]]
}),
) as Record<string, number[] | null>
})
}
const scrollY = (page: Page) => page.evaluate(() => window.scrollY)
/** A touch drag by the DevTools protocol, the pattern of the touch path above. */
async function touchDrag(
page: Page,
context: BrowserContext,
from: { x: number; y: number },
to: { x: number; y: number },
) {
const cdp = await context.newCDPSession(page)
const touch = (
type: 'touchStart' | 'touchMove' | 'touchEnd',
at: { x: number; y: number } | null,
) =>
cdp.send('Input.dispatchTouchEvent', {
type,
touchPoints: at ? [{ x: at.x, y: at.y }] : [],
})
await touch('touchStart', from)
for (let step = 1; step <= 8; step++)
await touch('touchMove', {
x: from.x + ((to.x - from.x) * step) / 8,
y: from.y + ((to.y - from.y) * step) / 8,
})
await touch('touchEnd', null)
}
test.describe('the view row (criterion 32)', () => {
test.use({
locale: 'fr-FR',
actionTimeout: 15_000,
viewport: { width: 1024, height: 768 },
})
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'editing needs 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered below
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('the end hint and chevron show, the start ones hide; the end chevron pages by 80 %, never activates a chip, never scrolls the page', async ({
page,
}) => {
await openRow(page)
await expect(hintOf(page, 'end')).toBeVisible()
await expect(chevronOf(page, 'end')).toBeVisible()
await expect(hintOf(page, 'start')).toBeHidden()
const before = await rowGeometry(page)
expect(before.scrollWidth, 'the row overflows').toBeGreaterThan(
before.clientWidth,
)
const under = await chevronOf(page, 'end').evaluate((chevron) => {
const box = chevron.getBoundingClientRect()
return document
.elementsFromPoint(box.x + box.width / 2, box.y + box.height / 2)
.some((el) => el.closest('[data-view-chip]'))
})
expect(under, 'precondition: a chip lies under the chevron').toBe(true)
await chevronOf(page, 'end').click()
const max = before.scrollWidth - before.clientWidth
await expectScrollLeft(page, Math.min(0.8 * before.clientWidth, max))
await expect(hintOf(page, 'start')).toBeVisible()
expect(await page.evaluate(() => window.scrollX)).toBe(0)
// No click lost, the other way round: a chevron press never activates a chip.
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', 'main')
await expect(pressedChip(page)).toHaveCount(1)
})
test('a chip reached by Tab then by the arrows is clear of the fades and pressable; Enter activates, the column does not move', async ({
page,
}) => {
await openRow(page)
await focusBefore(chipById(page, 'main'))
await page.keyboard.press('Tab')
await expect(chipById(page, 'main')).toBeFocused()
const top = await scrollY(page)
for (let n = 0; n < 4; n++) await page.keyboard.press('ArrowRight')
await expect(chipById(page, 'detail-long-3')).toBeFocused()
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', 'main')
await expectRevealed(page, 'detail-long-3', 'ArrowRight x4')
expect(await scrollY(page), 'the page does not scroll').toBe(top)
const before = await columnBoxes(page)
await page.keyboard.press('Enter')
await expect(pressedChip(page)).toHaveAttribute(
'data-view-chip',
'detail-long-3',
)
// Not expectNoShift: the check mark widens the active chip, inside the row.
await page.evaluate(
() =>
new Promise((done) =>
requestAnimationFrame(() => requestAnimationFrame(done)),
),
)
const after = await columnBoxes(page)
for (const part of ['canvas', 'strip', 'line'] as const)
for (let i = 0; i < 4; i++)
expect
.soft(after[part]?.[i], `${part} box [${i}] across the activation`)
.toBeCloseTo(before[part]![i], 0)
expect(await scrollY(page)).toBe(top)
})
test('End and Home reveal the last and the first chip, pressable at the clamp', async ({
page,
}) => {
await openRow(page)
await chipById(page, 'main').focus()
await page.keyboard.press('End')
await expect(chipById(page, LAST_VIEW)).toBeFocused()
await expectRevealed(page, LAST_VIEW, 'End')
await page.keyboard.press('Home')
await expect(chipById(page, 'main')).toBeFocused()
await expectRevealed(page, 'main', 'Home')
await expectScrollLeft(page, 0, 1)
})
test('Tab back into the row after a scroll: (a) the first view active, the row returns to the start', async ({
page,
}) => {
await openRow(page)
await chevronOf(page, 'end').click()
await expect(hintOf(page, 'start')).toBeVisible()
await focusBefore(chipById(page, 'main'))
const top = await scrollY(page)
await page.keyboard.press('Tab')
await expect(chipById(page, 'main')).toBeFocused()
await expectScrollLeft(page, 0, 1)
await expect(hintOf(page, 'start')).toBeHidden()
expect(await scrollY(page)).toBe(top)
})
// The active chip under the end fade, the keyboard user Tabs back in: (b1) the 4th view
// sits partly under the fade at the start of the row, (b2) the 6th is scrolled in so it
// starts inside the fade.
for (const entry of [
{
label: '(b1) the 4th view partly under the end fade',
id: 'detail-long-2',
arrows: 3,
at: 0,
// Measured: Chromium does not scroll a Tab focus onto a chip only partly under the
// fade (scrollLeft stays 0, the chip lies 211 px into it); the row has no focus reveal.
// Reported to the controller, never made to pass by weakening the case.
open: true,
},
{
label: '(b2) the 6th view inside the end fade',
id: 'detail-long-4',
arrows: 5,
at: HINT_CLEAR - 20,
},
]) {
;(entry.open ? test.fixme : test)(
`Tab back into the row after a scroll: ${entry.label} lies clear`,
async ({ page }) => {
await openRow(page)
await chipById(page, 'main').focus()
for (let n = 0; n < entry.arrows; n++)
await page.keyboard.press('ArrowRight')
await page.keyboard.press('Enter')
await expect(pressedChip(page)).toHaveAttribute(
'data-view-chip',
entry.id,
)
const { clientWidth } = await rowGeometry(page)
await setRowScroll(
page,
entry.at === 0
? 0
: await scrollLeftFor(page, entry.id, clientWidth - entry.at),
)
await focusBefore(chipById(page, entry.id))
const top = await scrollY(page)
await page.keyboard.press('Tab')
await expect(chipById(page, entry.id)).toBeFocused()
await expectRevealed(page, entry.id, 'Tab from under the end fade')
expect(await scrollY(page)).toBe(top)
},
)
}
test('no click lost: a pointer press on a chip partly under the end fade activates it at the first click', async ({
page,
}) => {
await openRow(page)
const { clientWidth } = await rowGeometry(page)
await setRowScroll(
page,
await scrollLeftFor(page, 'detail-long-3', clientWidth - 90),
)
const target = chipById(page, 'detail-long-3')
const at = await target.evaluate((chip, clear) => {
const row = chip.closest('[data-view-row]')!.getBoundingClientRect()
const box = chip.getBoundingClientRect()
const x = row.right - clear + 12
return {
x,
y: box.top + box.height / 2,
left: box.left,
right: box.right,
edge: row.right - clear,
}
}, HINT_CLEAR)
expect(
at.left,
'precondition: the chip starts before the fade',
).toBeLessThan(at.edge)
expect(
at.right,
'precondition: the chip runs under the fade',
).toBeGreaterThan(at.x)
await page.mouse.click(at.x, at.y)
await expect(pressedChip(page)).toHaveAttribute(
'data-view-chip',
'detail-long-3',
)
})
test('the dot: the active chip scrolled out of sight shows a dot on the chevron, a click brings it back', async ({
page,
}) => {
await openRow(page)
await chipById(page, 'main').focus()
await page.keyboard.press('End')
await page.keyboard.press('Enter')
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', LAST_VIEW)
await expectRevealed(page, LAST_VIEW, 'activated at the end')
await setRowScroll(page, 0)
const dot = chevronOf(page, 'end').locator('span')
await expect(dot).toBeVisible()
await chevronOf(page, 'end').click()
await expectRevealed(page, LAST_VIEW, 'the dot brings it back')
await expect(chevronOf(page, 'end').locator('span')).toHaveCount(0)
})
test('sizes: chip boxes 44 px, pills 30 px, no overlap, the focus outline inside the band', async ({
page,
}) => {
await openRow(page)
const sizes = await rowOf(page).evaluate((row) => {
const chips = [...row.querySelectorAll<HTMLElement>('[data-view-chip]')]
return chips.map((chip, i) => {
const box = chip.getBoundingClientRect()
const next = chips[i + 1]?.getBoundingClientRect()
const pill = chip.firstElementChild!.getBoundingClientRect()
return {
box: box.height,
pill: pill.height,
gap: next ? next.left - box.right : 0,
}
})
})
for (const size of sizes) {
expect(size.box).toBeCloseTo(44, 0)
expect(Math.abs(size.pill - 30)).toBeLessThanOrEqual(1)
expect(size.gap).toBeGreaterThanOrEqual(-0.5)
}
await chipById(page, 'main').focus()
await page.keyboard.press('ArrowRight')
const outline = await chipById(page, 'detail-a').evaluate((chip) => {
const pill = chip.firstElementChild as HTMLElement
const style = getComputedStyle(pill)
const grow =
parseFloat(style.outlineWidth) + parseFloat(style.outlineOffset)
const box = pill.getBoundingClientRect()
const band = chip.closest('[data-view-band]')!.getBoundingClientRect()
return {
style: style.outlineStyle,
top: box.top - grow - band.top,
bottom: band.bottom - (box.bottom + grow),
}
})
expect(outline.style, 'the focus ring is drawn').not.toBe('none')
expect(outline.top).toBeGreaterThanOrEqual(-0.5)
expect(outline.bottom).toBeGreaterThanOrEqual(-0.5)
})
test('a view changed from the right column brings the active chip into view', async ({
page,
}) => {
await openRow(page)
await page
.getByRole('region', { name: dict['editor.overview.views'], exact: true })
.getByRole('button', { name: /Détail de la région thoracique 8/ })
.click()
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', LAST_VIEW)
await expectRevealed(page, LAST_VIEW, 'view changed beside the drawing')
})
test('shown again: the edit body flipped back to 1 024 px has its active chip in view, placed instantly', async ({
page,
}) => {
await openRow(page)
await chipById(page, 'main').focus()
await page.keyboard.press('End')
await page.keyboard.press('Enter')
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', LAST_VIEW)
await page.setViewportSize({ width: 1023, height: 768 })
await expect(page.getByTestId('edit-strip')).toBeHidden()
await page.evaluate(() => {
const scope = window as unknown as { __scrolls: number }
scope.__scrolls = 0
for (const row of document.querySelectorAll('[data-view-row]'))
row.addEventListener('scroll', () => scope.__scrolls++)
})
await page.setViewportSize({ width: 1024, height: 768 })
await expect(page.getByTestId('edit-strip')).toBeVisible()
await expectRevealed(page, LAST_VIEW, 'the edit body is shown again')
const scrolls = await page.evaluate(
() => (window as unknown as { __scrolls: number }).__scrolls,
)
expect(
scrolls,
'placed instantly: at most 2 scroll events',
).toBeLessThanOrEqual(2)
})
test('shown again: the read-only twin opens on the view of the layer, its active chip in view, placed instantly', async ({
page,
}) => {
await openRow(page)
await chipById(page, 'main').focus()
await page.keyboard.press('End')
await page.keyboard.press('Enter')
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', LAST_VIEW)
await pickAnnotation(page, dict, /Pt dernier/)
await openProperties(page, dict)
await page.evaluate(() => {
const scope = window as unknown as { __scrolls: number }
scope.__scrolls = 0
for (const row of document.querySelectorAll('[data-view-row]'))
row.addEventListener('scroll', () => scope.__scrolls++)
})
await page.setViewportSize({ width: 1023, height: 768 })
await expect(page.getByTestId('edit-strip')).toBeHidden()
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', LAST_VIEW)
await expectRevealed(page, LAST_VIEW, 'the twin is shown', false)
const scrolls = await page.evaluate(
() => (window as unknown as { __scrolls: number }).__scrolls,
)
expect(
scrolls,
'placed instantly: at most 2 scroll events',
).toBeLessThanOrEqual(2)
})
test('language: the row scrolled to the end in English, then French (longer names), shows the end hint', async ({
page,
}) => {
await openRow(page)
await page
.getByRole('button', { name: dict['lang.switch_to_en'], exact: true })
.first()
.click()
await expect(rowOf(page)).toHaveAttribute('aria-label', 'Views')
const { scrollWidth, clientWidth } = await rowGeometry(page)
await setRowScroll(page, scrollWidth - clientWidth)
await expect(hintOf(page, 'end')).toBeHidden()
await page
.getByRole('button', { name: en['lang.switch_to_fr'], exact: true })
.first()
.click()
await expect(rowOf(page)).toHaveAttribute(
'aria-label',
dict['editor.annotations.views'],
)
await expect(hintOf(page, 'end')).toBeVisible()
})
test('no vertical move: the drawing box keeps its top across a view change, a language switch and a resize', async ({
page,
}) => {
await openRow(page)
const canvasTop = async () => (await columnBoxes(page)).canvas![1]
// The draft header's text wraps differently per language and width (it grew 44 px from
// French to English here, the strip with it): below it, the row adds nothing.
const belowHeader = () =>
page.evaluate(
() =>
document
.querySelector('[data-testid="annotation-canvas"]')!
.getBoundingClientRect().top -
document
.querySelector('header:has(> nav + div > h1)')!
.getBoundingClientRect().bottom,
)
const top = await canvasTop()
const gap = await belowHeader()
await chipById(page, 'main').focus()
await page.keyboard.press('End')
await page.keyboard.press('Enter')
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', LAST_VIEW)
await expectRevealed(page, LAST_VIEW, 'the view change')
expect(await canvasTop(), 'after a view change').toBeCloseTo(top, 0)
await page
.getByRole('button', { name: dict['lang.switch_to_en'], exact: true })
.first()
.click()
await expect(rowOf(page)).toHaveAttribute('aria-label', 'Views')
expect(await belowHeader(), 'after a language switch').toBeCloseTo(gap, 0)
await page.setViewportSize({ width: 1100, height: 768 })
await expectRevealed(page, LAST_VIEW, 'the resize')
expect(await belowHeader(), 'after a resize').toBeCloseTo(gap, 0)
})
test('axe on the row at rest, scrolled and focused', async ({ page }) => {
await openRow(page)
await expectAccessible(page, 'the view row at rest')
await chevronOf(page, 'end').click()
await expect(hintOf(page, 'start')).toBeVisible()
await expectScrollLeft(
page,
Math.min(
0.8 * (await rowGeometry(page)).clientWidth,
(await rowGeometry(page)).scrollWidth -
(await rowGeometry(page)).clientWidth,
),
)
await expectAccessible(page, 'the view row scrolled')
await chipById(page, 'main').focus()
await page.keyboard.press('ArrowRight')
await expectAccessible(page, 'the view row with a chip focused')
})
})
test.describe('the view row on a phone (criterion 32)', () => {
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
test.beforeEach(async ({ context }, info) => {
test.skip(!isPhone(info), 'the 375 px project only')
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('375 px read-only: no sideways page scroll, whole names, a tap on the chip peeking at the right activates it, its check lies clear of the start fade', async ({
page,
}) => {
await openRow(page, false)
await selectTab(page, dict, 'annotations')
await expect(rowOf(page)).toBeVisible()
await expectNoHorizontalOverflow(page, 'the read-only draft at 375 px')
const { scrollWidth, clientWidth } = await rowGeometry(page)
expect(scrollWidth, 'the row scrolls').toBeGreaterThan(clientWidth)
const wrapped = await rowOf(page)
.locator('[data-view-chip] > span')
.evaluateAll(
(pills) =>
pills.filter(
(pill) =>
pill.getBoundingClientRect().height > 31 ||
pill.scrollWidth > pill.clientWidth + 1,
).length,
)
expect(wrapped, 'every name is whole').toBe(0)
const peeking = chipById(page, 'detail-long-1')
const at = await peeking.evaluate((chip, clear) => {
const row = chip.closest('[data-view-row]')!.getBoundingClientRect()
const box = chip.getBoundingClientRect()
const right = row.right - 44
return {
x: (box.left + right) / 2,
y: box.top + box.height / 2,
visible: box.left < right - 24 && box.right > row.right - clear,
}
}, HINT_CLEAR)
expect(at.visible, 'precondition: the wide chip peeks at the right').toBe(
true,
)
await page.touchscreen.tap(at.x, at.y)
await expect(pressedChip(page)).toHaveAttribute(
'data-view-chip',
'detail-long-1',
)
await expectRevealed(page, 'detail-long-1', 'activated by a tap')
const check = await peeking.evaluate((chip, clear) => {
const row = chip.closest('[data-view-row]') as HTMLElement
const icon = chip.querySelector('svg')!.getBoundingClientRect()
const box = row.getBoundingClientRect()
return row.scrollLeft <= 1
? icon.left - box.left
: icon.left - (box.left + clear)
}, HINT_CLEAR)
expect(
check,
'the check icon is not under the start fade',
).toBeGreaterThanOrEqual(-2)
})
})
test.describe('the view row under the sticky strip, read-only (criterion 32)', () => {
test.use({
locale: 'fr-FR',
actionTimeout: 15_000,
viewport: { width: 1280, height: 800 },
})
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'the strip needs 1 024 px') // floor-guard: allow C16 read-only strip needs >= 1 024 px
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('the hints do not cover the strip: its command is reached with the row under it', async ({
page,
}) => {
const editor = await editorActor('fr')
const reviewer = await makeActor('fr', null, ['sheet_reviewer'])
const seed = await seedDraft(editor, { shape: viewRowShape })
await openEditor(page, dict, reviewer, seed.sheetId)
await expect(rowOf(page)).toBeVisible()
await pickAnnotation(page, dict, /Pt 0/)
const strip = page.getByTestId('edit-strip')
const command = strip.getByRole('button', {
name: dict['editor.annotations.properties'],
})
await expect(command).toBeVisible()
const overlap = await page.evaluate(() => {
const strip = document.querySelector('[data-testid="edit-strip"]')!
const band = document.querySelector('[data-view-band]')!
window.scrollBy(
0,
band.getBoundingClientRect().top -
strip.getBoundingClientRect().bottom +
22,
)
const s = strip.getBoundingClientRect()
const b = band.getBoundingClientRect()
return Math.min(s.bottom, b.bottom) - Math.max(s.top, b.top)
})
expect(
overlap,
'precondition: the row passes under the strip',
).toBeGreaterThan(10)
await command.click()
await expect(page.getByRole('dialog')).toBeVisible()
})
})
test.describe('the view row under a touch drag (criterion 32)', () => {
test.use({
locale: 'fr-FR',
actionTimeout: 15_000,
hasTouch: true,
viewport: { width: 1180, height: 820 },
})
test.beforeEach(async ({ context }, info) => {
test.skip(isPhone(info), 'touch at 1 180 px runs on desktop') // floor-guard: allow C16 editing needs >= 1024 px
await routeToSandbox(context)
})
test.afterEach(async ({ context }) => {
await dropLateReplays(context)
})
test('a touch drag from a chip scrolls the row, not the page, and activates nothing', async ({
page,
context,
}) => {
await openRow(page)
expect(
await rowOf(page).evaluate((row) => getComputedStyle(row).touchAction),
).toBe('manipulation') // pan-x pan-y pinch-zoom, as Chromium serialises it
const start = await chipById(page, 'detail-a').boundingBox()
const row = await rowGeometry(page)
const from = { x: start!.x + 40, y: start!.y + start!.height / 2 }
expect(from.x, 'precondition: clear of the start of the row').toBeLessThan(
row.right - HINT_CLEAR,
)
await touchDrag(page, context, from, { x: from.x - 200, y: from.y })
// Chromium's touch emulation may not pan an overflow container (LRN-135).
const moved = await expect
.poll(async () => (await rowGeometry(page)).scrollLeft, {
timeout: 2_000,
})
.toBeGreaterThan(100)
.then(
() => true,
() => false,
)
if (!moved)
test.info().annotations.push({
type: 'limit',
description:
'emulated touch did not pan the row (LRN-135): trial on the tablet',
})
expect(await scrollY(page), 'the page did not scroll').toBe(0)
await expect(pressedChip(page)).toHaveAttribute('data-view-chip', 'main')
})
})
+13 -2
View File
@@ -305,6 +305,7 @@ type Kind =
| 'tab'
| 'undo'
| 'redo'
| 'views'
| 'panel'
| 'tools'
| 'canvas'
@@ -323,6 +324,7 @@ function focusKind(page: Page): Promise<Kind> {
return el.getAttribute('aria-label') === undoName ? 'undo' : 'redo'
}
if (el.closest('main header')) return 'header'
if (el.closest('[data-view-row]')) return 'views'
if (el.closest('[role="toolbar"]')) return 'tools'
if (el.closest('[data-testid="annotation-canvas"]')) return 'canvas'
if (el.closest('[data-testid="annotation-overview"]')) return 'side'
@@ -355,7 +357,7 @@ test.describe('editor shell keyboard order (H)', () => {
// The header holds no focusable control after the title while the draft is clean: its
// buttons (« Abandonner », « Enregistrer ») are disabled, and « Références » left it.
test('tab list, Défaire, Refaire, then the tools, the canvas and the side column', async ({
test('tab list, Défaire, Refaire, the views, then the tools, the canvas and the side column', async ({
page,
}) => {
await open(page)
@@ -366,7 +368,15 @@ test.describe('editor shell keyboard order (H)', () => {
type: 'keyboard-order',
description: order.join(' > '),
})
expect(order).toEqual(['tab', 'undo', 'redo', 'tools', 'canvas', 'side'])
expect(order).toEqual([
'tab',
'undo',
'redo',
'views',
'tools',
'canvas',
'side',
])
})
test('with the references dialog open: Tab stays in it; closed, the order is the page again', async ({
@@ -384,6 +394,7 @@ test.describe('editor shell keyboard order (H)', () => {
'tab',
'undo',
'redo',
'views',
'tools',
'canvas',
'side',