import type { Locator } from '@playwright/test'

/** Node divs carry no `data-testid` (no production-code changes for
 * testability — Baustein 1's hard-abort-gate rule, honored throughout this
 * suite). `cursor: move` is an EXISTING, stable inline style every node div
 * already carries (vsm-editor.tsx's node `<div style={{ ..., cursor: 'move'
 * }}>`), regardless of flag state or node type — a safe, non-invasive
 * selector base. Filtered by name text (`node.name` always renders inside,
 * via the node-header `<span>`) to pick the one node a spec cares about. */
export function nodeByName(root: Locator, name: string): Locator {
  return root.locator('div[style*="cursor: move"]', { hasText: name })
}

/** The pannable/zoomable canvas surface (`vsm-canvas-surface` — an existing
 * class, not added for this suite; see globals.css's touch-action wildcard
 * rule this class also drives). Its `getBoundingClientRect()` is what
 * vsm-editor.tsx itself reads (`canvasRef.current?.getBoundingClientRect()`)
 * to convert a screen-space drop point to world coordinates — the exact
 * geometry jsdom could never give a value for (P8.2b jsdom-Lückenliste:
 * "getBoundingClientRect() liefert in jsdom (0,0,0,0)"). */
export function canvasSurface(root: Locator): Locator {
  return root.locator('.vsm-canvas-surface')
}
