fix(anatomy): V1-2.2 marker layer and halo outside the drawing's group
Owner-approved lot B (brief 2026-11-01). The composition root is the engine's (namespaces and frame); the drawing's root becomes a group and the marker layer and halo are its siblings, so no root property reaches a marker. Point hitboxes declare stroke none and visibleFill. Census over the reader's whole allowlist; R3 references compared under the declared transform; click proofs in three engines.
This commit is contained in:
1 parent
f1bb19b30b
commit
4f52f5e1c4
23 files changed
+933
-112
No files matched your search
@@ -0,0 +1,133 @@
|
||||
import { expect, test } from '../support/browser'
|
||||
import type { Page } from '@playwright/test'
|
||||
|
||||
// V1-2.2 owner brief 2026-10-30, defect 2: a click on the editor canvas records the marker
|
||||
// under the pointer, never another one, whatever stroke the drawing's root sets. Real
|
||||
// clicks (taps on the phone project) on the bundled equine sheet in AnatomyCanvas
|
||||
// (e2e/harness/canvas.tsx); run on Chromium, Firefox and WebKit when installed.
|
||||
|
||||
/**
|
||||
* The points of the equine main view whose visible disc no other marker covers, in document
|
||||
* order. The three vertebral junctions sit on the edge of a zone painted after them: part of
|
||||
* their disc records the zone (pre-existing, owner decision, see the fixme below).
|
||||
*/
|
||||
const POINTS = [
|
||||
'hind-fetlock',
|
||||
'hock',
|
||||
'stifle',
|
||||
'hip',
|
||||
'sacroiliac',
|
||||
'shoulder',
|
||||
'elbow',
|
||||
'carpus',
|
||||
'fore-fetlock',
|
||||
'fore-sesamoids',
|
||||
]
|
||||
const JUNCTIONS = ['l6-s1', 't18-l1', 'c7-t1']
|
||||
const DRAWINGS = ['plain', 'giant-stroke', 'invisible-stroke', 'hidden-stroke']
|
||||
|
||||
type Point = { x: number; y: number }
|
||||
|
||||
async function open(page: Page, drawing: string) {
|
||||
await page.goto(`/e2e/harness/canvas.html?drawing=${drawing}`)
|
||||
await expect(
|
||||
page.locator('[data-testid="anatomy-canvas"] [data-anno-id="hock"]').first(),
|
||||
).toBeAttached()
|
||||
}
|
||||
|
||||
/** The centre of a marker's visible shape on screen (a point's twin shares its hitbox's). */
|
||||
async function centreOf(page: Page, id: string): Promise<Point> {
|
||||
const box = await page
|
||||
.locator(`[data-testid="anatomy-canvas"] [data-anno-id="${id}"]`)
|
||||
.last()
|
||||
.boundingBox()
|
||||
if (!box) throw new Error(`${id} has no box`)
|
||||
return { x: box.x + box.width / 2, y: box.y + box.height / 2 }
|
||||
}
|
||||
|
||||
async function press(page: Page, at: Point, touch: boolean) {
|
||||
if (touch) await page.touchscreen.tap(at.x, at.y)
|
||||
else await page.mouse.click(at.x, at.y)
|
||||
}
|
||||
|
||||
/** The ids recorded by the clicks so far. */
|
||||
async function recorded(page: Page): Promise<string[]> {
|
||||
const text = (await page.getByTestId('clicks').textContent()) ?? ''
|
||||
return text.split(' ').filter(Boolean)
|
||||
}
|
||||
|
||||
async function clickRecords(page: Page, at: Point, touch = false) {
|
||||
const before = (await recorded(page)).length
|
||||
await press(page, at, touch)
|
||||
// A click that records nothing leaves the list as it was; wait out the handler.
|
||||
await page.waitForTimeout(50)
|
||||
return (await recorded(page)).slice(before)
|
||||
}
|
||||
|
||||
test.describe('canvas clicks', () => {
|
||||
for (const drawing of DRAWINGS) {
|
||||
test(`a click on the hock records the hock (${drawing})`, async ({ page }, info) => {
|
||||
await open(page, drawing)
|
||||
const touch = info.project.use.hasTouch === true
|
||||
expect(await clickRecords(page, await centreOf(page, 'hock'), touch)).toEqual(['hock'])
|
||||
})
|
||||
|
||||
test(`every point clear of the zones records itself (${drawing})`, async ({ page }) => {
|
||||
await open(page, drawing)
|
||||
for (const id of POINTS) {
|
||||
expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([id])
|
||||
}
|
||||
})
|
||||
|
||||
test(`a click on the drawing away from the markers records nothing (${drawing})`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await open(page, drawing)
|
||||
const box = await page.getByTestId('anatomy-canvas').boundingBox()
|
||||
if (!box) throw new Error('no canvas')
|
||||
// The top left corner and the middle of the belly hold no marker.
|
||||
for (const [fx, fy] of [
|
||||
[0.03, 0.05],
|
||||
[0.5, 0.55],
|
||||
] as const) {
|
||||
const at = { x: box.x + box.width * fx, y: box.y + box.height * fy }
|
||||
expect(await clickRecords(page, at), `${fx},${fy}`).toEqual([])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
test('two close points each record themselves, their shared edge goes to the later one', async ({
|
||||
page,
|
||||
}) => {
|
||||
await open(page, 'giant-stroke')
|
||||
const fetlock = await centreOf(page, 'fore-fetlock')
|
||||
const sesamoids = await centreOf(page, 'fore-sesamoids')
|
||||
expect(await clickRecords(page, fetlock)).toEqual(['fore-fetlock'])
|
||||
expect(await clickRecords(page, sesamoids)).toEqual(['fore-sesamoids'])
|
||||
// Halfway, outside both visible discs and inside both hitboxes: document order, the
|
||||
// later marker is on top. One id, never two.
|
||||
const half = { x: (fetlock.x + sesamoids.x) / 2, y: (fetlock.y + sesamoids.y) / 2 }
|
||||
expect(await clickRecords(page, half)).toEqual(['fore-sesamoids'])
|
||||
})
|
||||
|
||||
test('a click on a vertebral junction records the junction', async ({ page }) => {
|
||||
test.fixme(
|
||||
true,
|
||||
'V1-2.2 finding: the zones are painted and hit after the points; c7-t1 records « thoracic » at its centre in Firefox and WebKit, and up to half of each junction disc records a zone in every engine (owner decision on the capture order)',
|
||||
)
|
||||
await open(page, 'plain')
|
||||
for (const id of JUNCTIONS) {
|
||||
expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([id])
|
||||
}
|
||||
})
|
||||
|
||||
// @phone: the desktop projects leave it out (grepInvert), the touch projects run it.
|
||||
test('a tap on the hock records the hock @phone', async ({ page }) => {
|
||||
for (const drawing of DRAWINGS) {
|
||||
await open(page, drawing)
|
||||
expect(await clickRecords(page, await centreOf(page, 'hock'), true), drawing).toEqual([
|
||||
'hock',
|
||||
])
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user