Files
faunosteo/apps/app/e2e/harness/canvas.tsx
T
bchanot 4f52f5e1c4 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.
2026-11-01 00:39:57 +01:00

74 lines
2.5 KiB
TypeScript

/**
* Test page for the editor canvas in a real browser (e2e/ui/canvas-clicks.spec.ts): the
* bundled equine sheet in AnatomyCanvas, its drawing's root given the attributes of the
* chosen `?drawing=` case, every click recorded. Served by the Vite dev server only
* (`/e2e/harness/canvas.html`); the build has a single entry, index.html, so this page
* never ships.
*/
import { StrictMode, useState } from 'react'
import { createRoot } from 'react-dom/client'
import '@/styles/index.css'
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
import { bundledSheetProvider } from '@/sheets/provider'
import { setSheetProvider, useSheet } from '@/sheets/useSheet'
/**
* Root attributes of the drawing per case (V1-2.2 owner brief 2026-10-30, defect 2): the
* reported giant stroke, the same width with no stroke paint (an invisible enlarged
* surface), and the hiding stroke properties.
*/
const DRAWINGS: Record<string, string> = {
plain: '',
'giant-stroke': 'stroke="#ff00ff" stroke-width="2000"',
'invisible-stroke': 'stroke-width="2000"',
'hidden-stroke': 'stroke="#ff00ff" stroke-width="2000" stroke-opacity="0"',
}
const params = new URLSearchParams(location.search)
const rootAttrs = DRAWINGS[params.get('drawing') ?? 'plain'] ?? ''
const viewId = params.get('view') ?? 'main'
setSheetProvider({
async getReferenceSheet(speciesId) {
const sheet = await bundledSheetProvider.getReferenceSheet(speciesId)
if (!sheet || rootAttrs === '') return sheet
const assets = Object.fromEntries(
Object.entries(sheet.assets).map(([id, text]) => [
id,
text.replace('<svg ', `<svg ${rootAttrs} `),
]),
)
return { ...sheet, assets }
},
})
function Harness() {
const sheet = useSheet('equine')
const [clicks, setClicks] = useState<string[]>([])
return (
<main className="p-4">
<h1 className="text-xl font-semibold">Canvas harness</h1>
{/* A fixed height: the canvas never moves when the first click is listed. */}
<output data-testid="clicks" className="block h-6 overflow-hidden">
{clicks.join(' ')}
</output>
<div style={{ width: 'min(1000px, 100%)', aspectRatio: '2073.4 / 1629.4' }}>
{sheet.status === 'ready' && (
<AnatomyCanvas
index={sheet.index}
viewId={viewId}
states={new Map()}
onZoneClick={(id) => setClicks((all) => [...all, id])}
/>
)}
</div>
</main>
)
}
createRoot(document.getElementById('root') as HTMLElement).render(
<StrictMode>
<Harness />
</StrictMode>,
)