// @vitest-environment node import { describe, expect, it, vi } from 'vitest'; import { JSDOM } from 'jsdom'; import { buildSrcdoc } from '../../src/runtime/srcdoc'; // Behavioral coverage for nexu-io/open-design#890. The Examples / Tweaks // preview iframe runs the bridge script generated by `buildSrcdoc`. When // the agent emits an artifact without `data-od-id` / `data-screen-label` // (e.g. a freeform PRD → HTML pass through a Claude-Code-compatible CLI // without a skill), the bridge must: // // 1. Still post `od:comment-targets` with `targets: []` so the host // can detect the empty-annotation state and surface a clearer // hint than "Click any element with `data-od-id` …" — without // this, FileViewer's `liveCommentTargets` map never updates and // the hint banner sticks at its instructive-default state even // though there's nothing to click. // 2. In Comment picker mode, fall back to meaningful DOM selectors // for unannotated surfaces so imported or partially annotated HTML // can still be reviewed. Inspect mode still needs a real annotated // selector for live style persistence. // // The host-side hint switch lives in `apps/web/src/components/FileViewer.tsx` // (search for `inspect-empty-hint-no-targets`); these tests pin the // signal it depends on. function extractBridgeScript(srcdoc: string): string { // The bridge is wrapped in ``. const match = srcdoc.match( /