feat(editor): fixed edit strip and message line without layout shift
U2 Task 3 (A6, A14, R-2). A fixed-height strip over the drawing and the right column replaces the tool line, the sr-only selection tag of the edit body and TracingBar: lead (name + status, type + detail), notice (refusal, first geometry issue + n, unmeasured view with its link, no category, no child view), commands (Fermer le trace, Retirer le dernier sommet, Annuler le trace). A fixed-height line under the drawing holds the add buttons and the gesture message: a kept drop says « Point deplace » with « Defaire » (same store undo as the header), a refused drop says « Deplacement refuse : ... » as a red alert. 6 s, held by mouse hover and focus inside, closed by any commit, undo or redo. trace_pop and Backspace remove the last vertex. The busy « Aller a » target is the strip's tracing commands. scrollbar-gutter stable, scoped to the editor. e2e helper expectNoShift (boxes, scroll height, gutter, client width, layout-shift sum). DraftHeader untouched: no shift seen. Rewritten assertions (old -> new): - tab unit « Sélection : point » on annotation-selection-tag -> strip detail « Point » - tab unit tag sr-only, not live -> strip lead outside any live region - tab unit « 1 sommet posé. » -> « 1 sommet posé » (board 04 wording) - tab unit D6b tag present / « zone » -> strip detail « Point » / « Zone · 3 sommets » - keep-alive, sections, escape units: tracing-bar -> tracing-commands - e2e selectionTag helper -> strip title with data-selection; the twin's tag is twinSelectionTag (deselect 375 px describe) - e2e deselect « tag position absolute » (edit) -> strip height 64 px, drawing top unchanged; twin Escape test keeps tag 0, properties 0, overview visible - e2e deselect and journey tracing-bar / annotation-selection-tag -> tracing-commands / selectionTag - e2e historyButton scoped to history-buttons (the message's « Défaire » has the same accessible name)
This commit is contained in:
1 parent
b2d78f9621
commit
1deb037fac
23 files changed
+1228
-181
No files matched your search
@@ -11,13 +11,18 @@ import {
|
||||
pressAtBox,
|
||||
openEditor,
|
||||
pickAnnotation,
|
||||
pointOf,
|
||||
saveDraft,
|
||||
saveLine,
|
||||
seedDraft,
|
||||
selectionTag,
|
||||
selectTab,
|
||||
serverDocument,
|
||||
shapeWith,
|
||||
standardShape,
|
||||
UNSAVED_LINE,
|
||||
} from '../support/editor'
|
||||
import { expectNoShift } from '../support/layout'
|
||||
|
||||
// V1-2.6 A3 (contract C7, C8, C21): points, zones and links by clicks and by keyboard,
|
||||
// move by drag, numeric edits, undo and redo, then the save that carries them.
|
||||
@@ -286,4 +291,120 @@ test.describe('editor annotations (A3)', () => {
|
||||
await selectTab(page, dict, 'verification')
|
||||
await expectAccessible(page, 'the verification tab after a deletion')
|
||||
})
|
||||
|
||||
test.describe('the drawing never moves (A14)', () => {
|
||||
const button = (page: Page, key: string) =>
|
||||
page.getByRole('button', { name: dict[key], exact: true })
|
||||
const line = (page: Page) => page.getByTestId('gesture-line')
|
||||
|
||||
async function openWithPoint(page: Page, width: number) {
|
||||
await page.setViewportSize({ width, height: 800 })
|
||||
// Installed before any timer: the message's 6 s run on this clock (fast-forwarded below).
|
||||
await page.clock.install()
|
||||
const actor = await editorActor('fr')
|
||||
const point = pointOf('p-a', 'main', { cx: 500, cy: 300, r: 40 }, 'Pt A')
|
||||
const seed = await seedDraft(actor, { shape: shapeWith(point) })
|
||||
await openEditor(page, dict, actor, seed.sheetId)
|
||||
await expect(tool(page, 'point')).toBeEnabled()
|
||||
return actor
|
||||
}
|
||||
|
||||
/** A drag of the point from (500, 300) to `to`, in drawing units. */
|
||||
async function dragPoint(page: Page, to: { x: number; y: number }) {
|
||||
const from = await clientOf(page, 500, 300)
|
||||
const end = await clientOf(page, to.x, to.y)
|
||||
await page.mouse.move(from.x, from.y)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(end.x, end.y, { steps: 6 })
|
||||
await page.mouse.up()
|
||||
}
|
||||
|
||||
for (const width of [1024, 1180, 1280]) {
|
||||
test(`at ${width} px: selection, tools, tracing, the first commit, the message`, async ({
|
||||
page,
|
||||
requests,
|
||||
}) => {
|
||||
const actor = await openWithPoint(page, width)
|
||||
requests.forbid(actor.account.email, actor.account.password)
|
||||
// shortcut: the side panel still swaps the overview for the properties or the
|
||||
// creation panel until Tasks 6 and 7 (dialogs); its height is exempt there only.
|
||||
const swaps = ['aside-content'] as const
|
||||
await expectNoShift(
|
||||
page,
|
||||
async () => {
|
||||
await clickDrawing(page, 500, 300)
|
||||
await expect(selectionTag(page)).toContainText('Pt A')
|
||||
},
|
||||
swaps,
|
||||
)
|
||||
// The first commit: the save line changes, the message shows (the properties panel
|
||||
// rewrites its review badge: aside content until Task 6).
|
||||
await expectNoShift(
|
||||
page,
|
||||
async () => {
|
||||
await dragPoint(page, { x: 560, y: 330 })
|
||||
await expect(line(page)).toContainText(
|
||||
dict['editor.annotations.message.moved.point'],
|
||||
)
|
||||
await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
|
||||
},
|
||||
swaps,
|
||||
)
|
||||
// Its expiry, 6 s later.
|
||||
await expectNoShift(page, async () => {
|
||||
await page.clock.fastForward(6_100)
|
||||
await expect(line(page)).not.toContainText(
|
||||
dict['editor.annotations.message.moved.point'],
|
||||
)
|
||||
})
|
||||
await expectNoShift(
|
||||
page,
|
||||
async () => {
|
||||
await clickDrawing(page, 20, 20)
|
||||
await expect(selectionTag(page)).toHaveCount(0)
|
||||
},
|
||||
swaps,
|
||||
)
|
||||
await expectNoShift(page, () => tool(page, 'zone').click())
|
||||
await expectNoShift(page, () => clickDrawing(page, 600, 150))
|
||||
for (const [x, y] of [
|
||||
[800, 150],
|
||||
[700, 400],
|
||||
])
|
||||
await expectNoShift(page, () => clickDrawing(page, x, y))
|
||||
await expectNoShift(page, () =>
|
||||
button(page, 'editor.annotations.trace_pop').click(),
|
||||
)
|
||||
await expectNoShift(page, () => clickDrawing(page, 700, 400))
|
||||
await expectNoShift(
|
||||
page,
|
||||
async () => {
|
||||
await button(page, 'editor.annotations.trace_close').click()
|
||||
await expect(creation(page)).toBeVisible()
|
||||
},
|
||||
swaps,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
test('the editor keeps a stable scrollbar gutter; the dashboard does not', async ({
|
||||
page,
|
||||
requests,
|
||||
}, info) => {
|
||||
test.skip(
|
||||
info.project.name !== 'chromium-desktop',
|
||||
'measured at 1 280 px',
|
||||
)
|
||||
const actor = await openWithPoint(page, 1280)
|
||||
requests.forbid(actor.account.email, actor.account.password)
|
||||
const gutter = () =>
|
||||
page.evaluate(
|
||||
() => getComputedStyle(document.documentElement).scrollbarGutter,
|
||||
)
|
||||
expect(await gutter()).toBe('stable')
|
||||
await page.goto('/app')
|
||||
await expect(page.locator('[data-editor-workspace]')).toHaveCount(0)
|
||||
expect(await gutter()).toBe('auto')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
serverRevision,
|
||||
shapeWith,
|
||||
toolButton,
|
||||
twinSelectionTag,
|
||||
UNSAVED_LINE,
|
||||
} from '../support/editor'
|
||||
|
||||
@@ -247,7 +248,7 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
|
||||
await toolButton(page, dict, 'zone').click()
|
||||
await clickAt(page, { x: 300, y: 500 })
|
||||
await clickAt(page, { x: 400, y: 500 })
|
||||
const bar = page.getByTestId('tracing-bar')
|
||||
const bar = page.getByTestId('tracing-commands')
|
||||
await expect(bar).toBeVisible()
|
||||
await box(page).focus()
|
||||
await page.keyboard.press('Escape')
|
||||
@@ -327,7 +328,8 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
|
||||
] as [string, { x: number; y: number }][]) {
|
||||
await clickAt(page, at)
|
||||
await expectSelected(page, name)
|
||||
await expect(selectionTag(page)).toHaveCSS('position', 'absolute')
|
||||
// The name shows in the fixed-height strip, which never moves the drawing.
|
||||
await expect(page.getByTestId('edit-strip')).toHaveCSS('height', '64px')
|
||||
expect(await top(), `${name} selected`).toBe(before)
|
||||
await clickAt(page, IN_ROOT)
|
||||
await expectDeselected(page)
|
||||
@@ -745,23 +747,23 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => {
|
||||
|
||||
await takeRecord(page)
|
||||
await tap(cdp, await markerAt())
|
||||
await expect(selectionTag(page)).toContainText(POINT)
|
||||
await expect(twinSelectionTag(page)).toContainText(POINT)
|
||||
await shoot(info, 'r1-panel-375', properties(page))
|
||||
await report('twin tap on a marker')
|
||||
|
||||
await takeRecord(page)
|
||||
await tap(cdp, await twinAt(IN_RECT.x, IN_RECT.y))
|
||||
await expect(selectionTag(page)).toHaveCount(0)
|
||||
await expect(twinSelectionTag(page)).toHaveCount(0)
|
||||
await expect(canvas).toBeFocused()
|
||||
await report('twin tap on the rect')
|
||||
|
||||
await tap(cdp, await markerAt())
|
||||
await expect(selectionTag(page)).toContainText(POINT)
|
||||
await expect(twinSelectionTag(page)).toContainText(POINT)
|
||||
await takeRecord(page)
|
||||
const from = await twinAt(IN_CIRCLE.x, IN_CIRCLE.y)
|
||||
await drag(cdp, from, { x: from.x + 30, y: from.y + 10 })
|
||||
await frames(page)
|
||||
await expect(selectionTag(page)).toContainText(POINT)
|
||||
await expect(twinSelectionTag(page)).toContainText(POINT)
|
||||
const drag1 = guards(await report('twin one-finger drag'))
|
||||
expect(drag1.clicks, 'twin drag: no click').toBe(0)
|
||||
expect(
|
||||
@@ -774,7 +776,7 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => {
|
||||
await touch(cdp, 'touchStart', [two, { x: two.x + 30, y: two.y }])
|
||||
await touch(cdp, 'touchEnd', [])
|
||||
await frames(page)
|
||||
await expect(selectionTag(page)).toContainText(POINT)
|
||||
await expect(twinSelectionTag(page)).toContainText(POINT)
|
||||
const pair = guards(await report('twin two-finger tap'))
|
||||
expect(pair.nonPrimary, 'twin: a non-primary pointerdown').toBeGreaterThan(
|
||||
0,
|
||||
@@ -819,12 +821,12 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => {
|
||||
[LINK, { x: 825, y: 575 }],
|
||||
] as [string, { x: number; y: number }][]) {
|
||||
await tap(cdp, await twinAt(at.x, at.y))
|
||||
await expect(selectionTag(page)).toHaveCount(1)
|
||||
await expect(selectionTag(page)).toContainText(name)
|
||||
await expect(selectionTag(page)).toHaveCSS('position', 'absolute')
|
||||
await expect(twinSelectionTag(page)).toHaveCount(1)
|
||||
await expect(twinSelectionTag(page)).toContainText(name)
|
||||
await expect(twinSelectionTag(page)).toHaveCSS('position', 'absolute')
|
||||
expect(await top(), `${name} selected`).toBe(before)
|
||||
await tap(cdp, await twinAt(IN_RECT.x, IN_RECT.y))
|
||||
await expect(selectionTag(page)).toHaveCount(0)
|
||||
await expect(twinSelectionTag(page)).toHaveCount(0)
|
||||
expect(await top(), `${name} deselected`).toBe(before)
|
||||
}
|
||||
})
|
||||
@@ -850,7 +852,7 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => {
|
||||
x: marker!.x + marker!.width / 2,
|
||||
y: marker!.y + marker!.height / 2,
|
||||
})
|
||||
await expect(selectionTag(page)).toContainText(POINT)
|
||||
await expect(twinSelectionTag(page)).toContainText(POINT)
|
||||
|
||||
const more = page.locator('#editor-tabs-more-button')
|
||||
await more.click()
|
||||
@@ -859,10 +861,13 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => {
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(more).toHaveAttribute('aria-expanded', 'false')
|
||||
await expect(more).toBeFocused()
|
||||
await expectKept(page, POINT)
|
||||
await frames(page)
|
||||
await expect(twinSelectionTag(page)).toContainText(POINT)
|
||||
|
||||
await page.keyboard.press('Escape')
|
||||
await expectDeselected(page)
|
||||
await expect(twinSelectionTag(page)).toHaveCount(0)
|
||||
await expect(properties(page)).toHaveCount(0)
|
||||
await expect(overview(page)).toBeVisible()
|
||||
await expect(liveRegion(page)).toHaveCount(1)
|
||||
expect(saves).toEqual([])
|
||||
})
|
||||
|
||||
@@ -388,9 +388,7 @@ test.describe('editor journey (owner trial steps)', () => {
|
||||
),
|
||||
})
|
||||
.click()
|
||||
await expect(page.getByTestId('annotation-selection-tag')).toContainText(
|
||||
'Point de bord',
|
||||
)
|
||||
await expect(selectionTag(page)).toContainText('Point de bord')
|
||||
await selectTab(page, dict, 'verification')
|
||||
await page
|
||||
.getByLabel(dict['editor.verification.note'])
|
||||
|
||||
@@ -629,7 +629,8 @@ export function savedLine(dict: Dict, revision: number): RegExp {
|
||||
|
||||
/** The header « Défaire » / « Refaire » button (enabled ones take a plain click). */
|
||||
export const historyButton = (page: Page, dict: Dict, kind: 'undo' | 'redo') =>
|
||||
page.getByRole('button', {
|
||||
// Scoped: the message under the drawing carries a « Défaire » of the same name (T15).
|
||||
page.getByTestId('history-buttons').getByRole('button', {
|
||||
name: dict[`editor.history.${kind}_title`],
|
||||
exact: true,
|
||||
})
|
||||
@@ -714,8 +715,12 @@ export const creationPanel = (page: Page) =>
|
||||
export const annotationList = (page: Page, dict: Dict) =>
|
||||
page.getByRole('list', { name: dict['editor.annotations.list'] })
|
||||
|
||||
/** The screen-reader-only tag rendered while an annotation is selected. */
|
||||
/** The edit strip's name of the selected annotation (U2 Task 3: the strip replaced the tag). */
|
||||
export const selectionTag = (page: Page) =>
|
||||
page.locator('[data-testid="edit-strip-title"][data-selection]')
|
||||
|
||||
/** The read-only twin's screen-reader-only tag, rendered while an annotation is selected. */
|
||||
export const twinSelectionTag = (page: Page) =>
|
||||
page.getByTestId('annotation-selection-tag')
|
||||
|
||||
/** Selects an annotation from the overview card, leaving a selection first when there is one. */
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* The no-shift probe of U2 (adjustment A14, plan Task 3): a state change of the annotations
|
||||
* tab moves no box. The boxes of the canvas, the strip, the aside and the draft header,
|
||||
* the page's scroll height, its scrollbar gutter and its client width are read before and
|
||||
* after `act`; a layout-shift observer adds up every entry in between, the ones following
|
||||
* an input included (a message appearing after a drop is still a shift).
|
||||
*/
|
||||
import { expect, type Page } from '@playwright/test'
|
||||
|
||||
/**
|
||||
* What may change by design until a later task, named at the call site only: the side
|
||||
* panel's own content (its height, the scroll height, and shifts whose every moved node is
|
||||
* inside it) while it still swaps the overview, the properties and the creation panel.
|
||||
*/
|
||||
export type ShiftExemption = 'aside-content'
|
||||
|
||||
interface Box {
|
||||
x: number
|
||||
y: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
interface Snapshot {
|
||||
boxes: Record<string, Box | null>
|
||||
scrollHeight: number
|
||||
gutter: string
|
||||
clientWidth: number
|
||||
}
|
||||
|
||||
const PARTS = {
|
||||
canvas: '[data-testid="annotation-canvas"]',
|
||||
strip: '[data-testid="edit-strip"]',
|
||||
aside: '[data-testid="editor-tab-annotations"] aside',
|
||||
header: 'header:has(> nav + div > h1)',
|
||||
} as const
|
||||
|
||||
function snapshot(page: Page): Promise<Snapshot> {
|
||||
return page.evaluate((parts) => {
|
||||
const shown = (selector: string) =>
|
||||
[...document.querySelectorAll(selector)].find(
|
||||
(element) => (element as HTMLElement).offsetParent !== null,
|
||||
)
|
||||
const boxes: Record<string, Box | null> = {}
|
||||
for (const [name, selector] of Object.entries(parts)) {
|
||||
const rect = shown(selector)?.getBoundingClientRect()
|
||||
boxes[name] = rect
|
||||
? { x: rect.x, y: rect.y, width: rect.width, height: rect.height }
|
||||
: null
|
||||
}
|
||||
const root = document.documentElement
|
||||
return {
|
||||
boxes,
|
||||
scrollHeight: root.scrollHeight,
|
||||
gutter: getComputedStyle(root).scrollbarGutter,
|
||||
clientWidth: root.clientWidth,
|
||||
}
|
||||
}, PARTS)
|
||||
}
|
||||
|
||||
/** The page side of the probe: the summed shift and what moved, for the failure message. */
|
||||
interface ShiftScope {
|
||||
__shift: { total: number; moved: string[] }
|
||||
__shiftObserver?: PerformanceObserver
|
||||
}
|
||||
|
||||
/** Starts summing layout-shift entries; read back with `shiftTotal`. */
|
||||
function observeShifts(page: Page, asideExempt: boolean): Promise<void> {
|
||||
return page.evaluate(
|
||||
({ exempt, aside }) => {
|
||||
const scope = window as unknown as ShiftScope
|
||||
scope.__shiftObserver?.disconnect()
|
||||
scope.__shift = { total: 0, moved: [] }
|
||||
const observer = new PerformanceObserver((list) => {
|
||||
for (const entry of list.getEntries()) {
|
||||
const shift = entry as unknown as {
|
||||
value: number
|
||||
sources: { node?: Node }[]
|
||||
}
|
||||
const inAside = shift.sources.every((source) =>
|
||||
(source.node as Element | undefined)?.closest?.(aside),
|
||||
)
|
||||
if (exempt && inAside) continue
|
||||
scope.__shift.total += shift.value
|
||||
for (const source of shift.sources) {
|
||||
const node = source.node as Element | undefined
|
||||
scope.__shift.moved.push(
|
||||
node?.outerHTML?.slice(0, 160) ?? String(source.node),
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
observer.observe({ type: 'layout-shift' })
|
||||
scope.__shiftObserver = observer
|
||||
},
|
||||
{ exempt: asideExempt, aside: PARTS.aside },
|
||||
)
|
||||
}
|
||||
|
||||
/** Two frames for layout to settle, then the pending entries and the total. */
|
||||
function shiftTotal(page: Page): Promise<ShiftScope['__shift']> {
|
||||
return page.evaluate(async () => {
|
||||
await new Promise((done) =>
|
||||
requestAnimationFrame(() => requestAnimationFrame(done)),
|
||||
)
|
||||
const scope = window as unknown as ShiftScope
|
||||
const observer = scope.__shiftObserver!
|
||||
const pending = observer.takeRecords()
|
||||
observer.disconnect()
|
||||
for (const entry of pending) {
|
||||
scope.__shift.total += (entry as unknown as { value: number }).value
|
||||
}
|
||||
return scope.__shift
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs `act` and asserts nothing moved. `exempt: ['aside-content']` lets the side panel's
|
||||
* content change (see `ShiftExemption`); the aside's position and width, the canvas, the
|
||||
* strip and the header are still checked, and every shift outside the aside.
|
||||
*/
|
||||
export async function expectNoShift(
|
||||
page: Page,
|
||||
act: () => Promise<void>,
|
||||
exempt: readonly ShiftExemption[] = [],
|
||||
): Promise<void> {
|
||||
const before = await snapshot(page)
|
||||
const loose = exempt.includes('aside-content')
|
||||
await observeShifts(page, loose)
|
||||
await act()
|
||||
const shift = await shiftTotal(page)
|
||||
const after = await snapshot(page)
|
||||
const drop = (shot: Snapshot) => ({
|
||||
...shot,
|
||||
scrollHeight: loose ? 0 : shot.scrollHeight,
|
||||
boxes: {
|
||||
...shot.boxes,
|
||||
aside:
|
||||
loose && shot.boxes.aside
|
||||
? { ...shot.boxes.aside, height: 0 }
|
||||
: shot.boxes.aside,
|
||||
},
|
||||
})
|
||||
expect(drop(after)).toEqual(drop(before))
|
||||
expect(shift.total, `layout shift of ${shift.moved.join(' | ')}`).toBe(0)
|
||||
}
|
||||
Reference in new issue
Block a user