// @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. Drop click events on unannotated elements without posting an // `od:comment-target` — the click handler walks up to , // finds nothing tagged, and must bail. Posting a synthetic id // here would change save-to-source semantics for inspect // overrides (the persisted CSS keys off the same elementId), so // this test pins the no-fallback contract. // // 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( /