// @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#1530. The deck bridge in // `buildSrcdoc({ deck: true })` counts slides via a DOM selector to drive // the host preview toolbar's `slideState.count`. Generated HTML decks // commonly nest `.slide` elements under an extra wrapper rather than // placing them as direct children of the structured containers the bridge // recognised (`.deck`, `.deck-stage`, `.deck-shell`, `body`). When that // happened the bridge reported `count: 0` and the toolbar showed `1 / 0` // even though the deck visibly contained slides and its own keyboard // handler navigated them — the host counter did not match what the user // saw. The fix keeps the structured selector first (so decorative // `.slide` markup in non-deck pages is not accidentally counted) and // falls back to all `.slide` only when the structured count is zero. function extractDeckBridgeScript(srcdoc: string): string { const match = srcdoc.match(/