/** * @license * Copyright 2026 Qwen Team * SPDX-License-Identifier: Apache-2.0 */ import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; const root = join(dirname(fileURLToPath(import.meta.url)), '../..'); const template = readFileSync( join( root, 'packages', 'web-templates', 'src', 'export-html', 'src', 'document-index.html', ), 'utf8', ); const STYLESHEET_ID = 'id="transcript-stylesheet"'; /** * The id the `` actually carries, read back out of the template rather * than hard-coded. The same literal is spelled in three places — declared on * the ``, compared by the `
` latch, compared by the body listener * — so deriving it here is what lets one test pin all three against each other. */ const STYLESHEET_LINK_ID = /]*\bid="([^"]+)"/.exec(template)?.[1]; /** The script that records a stylesheet failure before the . */ function latchScript() { const latch = template.indexOf('window.__transcriptStyleFailed = true'); expect(latch).toBeGreaterThan(-1); const start = template.lastIndexOf('