test(tests): measure the line's « Défaire » hit box whole
Final review M-5: the hit test now probes 1 px inside each edge of the 44 px (36 px from xl) box and reads the ::before height, so the check proves the full height, not 42 px. Tests: no assertion removed.
This commit is contained in:
1 parent
f2bf442ecd
commit
a5af9bdd4f
1 file changed
+16
-15
@@ -427,24 +427,25 @@ test.describe('editor annotations (A3)', () => {
|
|||||||
button.scrollIntoView({ block: 'center' }),
|
button.scrollIntoView({ block: 'center' }),
|
||||||
)
|
)
|
||||||
const reach = width < 1280 ? 44 : 36
|
const reach = width < 1280 ? 44 : 36
|
||||||
const hit = await undoOnLine.evaluate(
|
// Hit-tested 1 px inside each edge, and the hit box measured whole.
|
||||||
(button, half) => {
|
const hit = await undoOnLine.evaluate((button, tall) => {
|
||||||
const box = button.getBoundingClientRect()
|
const box = button.getBoundingClientRect()
|
||||||
const x = box.left + box.width / 2
|
const x = box.left + box.width / 2
|
||||||
const mid = box.top + box.height / 2
|
const mid = box.top + box.height / 2
|
||||||
const at = (dy: number) => document.elementFromPoint(x, mid + dy)
|
const at = (dy: number) => document.elementFromPoint(x, mid + dy)
|
||||||
const pill = button.closest('[data-testid="gesture-message"]')!
|
const pill = button.closest('[data-testid="gesture-message"]')!
|
||||||
return {
|
const area = getComputedStyle(button, '::before').height
|
||||||
top: at(-half) === button,
|
return {
|
||||||
bottom: at(half) === button,
|
top: at(1 - tall / 2) === button,
|
||||||
pill: pill.getBoundingClientRect().height,
|
bottom: at(tall / 2 - 1) === button,
|
||||||
}
|
tall: parseFloat(area) >= tall,
|
||||||
},
|
pill: pill.getBoundingClientRect().height,
|
||||||
reach / 2 - 1,
|
}
|
||||||
)
|
}, reach)
|
||||||
expect(hit, `a ${reach} px hit area at ${width} px`).toEqual({
|
expect(hit, `a ${reach} px hit area at ${width} px`).toEqual({
|
||||||
top: true,
|
top: true,
|
||||||
bottom: true,
|
bottom: true,
|
||||||
|
tall: true,
|
||||||
pill: 36,
|
pill: 36,
|
||||||
})
|
})
|
||||||
// M-4: the line's « Défaire »: the drawing takes the focus, nothing moves or scrolls.
|
// M-4: the line's « Défaire »: the drawing takes the focus, nothing moves or scrolls.
|
||||||
|
|||||||
Reference in new issue
Block a user