Files
faunosteo/apps/app/e2e/harness/interior.ts
T
bchanot 8dd2d78d38 fix(anatomy): V1-2.2 refuse zones without a usable interior
A polygon or path zone or trigger must fill a disc of 4 CSS px on the
320 x 568 preview under the layer's nonzero rule, stroke left out:
conservative widest-disc search on the flattened outline, caps and a
per-sheet budget, closed codes interior_too_small and
marker_interior_too_small. Browser probe on six projects.
2026-11-01 12:19:08 +01:00

34 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Test page for the interior rule in a real browser (e2e/ui/interior-clicks.spec.ts): the
* canvas the core composes for one probe case (e2e/fixtures/interior-probe.json, generated by
* crates/core/tests/interior_probe.rs) in the phone preview's 286 × 310 box, inserted as the
* editor inserts it (DOMParser, importNode), every click on a marker recorded. Served by the
* Vite dev server only (`/e2e/harness/interior.html?case=`); the build never ships it.
*/
import probe from '../fixtures/interior-probe.json'
const name = new URLSearchParams(location.search).get('case')
const found = probe.cases.find((c) => c.name === name)
if (!found) throw new Error(`no probe case ${String(name)}`)
const root = document.getElementById('root') as HTMLElement
const clicks = document.createElement('output')
clicks.dataset.testid = 'clicks'
clicks.style.cssText = 'display:block;height:24px;overflow:hidden'
const box = document.createElement('div')
box.dataset.testid = 'preview'
box.style.cssText = `width:${probe.frame.width}px;height:${probe.frame.height}px`
const parsed = new DOMParser().parseFromString(found.svg, 'image/svg+xml')
const svg = document.importNode(
parsed.documentElement,
true,
) as unknown as SVGSVGElement
svg.style.cssText = 'display:block;width:100%;height:100%'
box.append(svg)
root.append(clicks, box)
box.addEventListener('click', (event) => {
const marker = (event.target as Element).closest('[data-anno-id]')
const id = marker?.getAttribute('data-anno-id')
if (id) clicks.textContent = `${clicks.textContent ?? ''} ${id}`.trim()
})