import assert from "node:assert/strict"; import fs from "node:fs"; import test from "node:test"; const preview = fs.readFileSync(new URL("../web/static/js/preview.js", import.meta.url), "utf8"); const chat = fs.readFileSync(new URL("../web/static/js/chat.js", import.meta.url), "utf8"); const html = fs.readFileSync(new URL("../web/static/dev.html", import.meta.url), "utf8"); test("web preview tool results render persistent interactive cards", () => { assert.match(preview, /export function parseWebPreviewResult/); assert.match(preview, /export function renderWebPreviewCardHtml/); assert.match(chat, /toolName === "publish_web_preview"/); assert.match(chat, /parseWebPreviewResult\(txtStr\)/); assert.match(chat, /openWebPreview\(previewId\)/); assert.match(chat, /stopWebPreview\(previewId\)/); assert.match(html, /\.web-preview-card/); }); test("project iframe remains opaque and launch URL is fetched with auth", () => { assert.match(preview, /api\("POST", `\/v1\/web-previews\/\$\{encodeURIComponent\(previewId\)\}\/launch`\)/); assert.match(preview, /allow-scripts allow-forms allow-modals allow-downloads/); assert.doesNotMatch(preview, /allow-same-origin/); assert.match(preview, /frame\.referrerPolicy = "no-referrer"/); });