const assert = require("assert");
const fs = require("fs");
const path = require("path");
const { pathToFileURL } = require("url");
const { chromium } = require("playwright");
const root = path.resolve(__dirname, "..");
(async () => {
const cohostSource = fs.readFileSync(path.join(root, "cohost.html"), "utf8");
const popupSource = fs.readFileSync(path.join(root, "popup.html"), "utf8");
const guidePaths = [
path.join(root, "docs", "ai-cohost-guide.html"),
path.join(root, "docs", "ai-modes-guide.html")
];
assert(cohostSource.includes('selectionElem.setAttribute("role", "dialog")'));
assert(cohostSource.includes('selectionElem.setAttribute("aria-modal", "true")'));
assert(cohostSource.includes('selectionElem.setAttribute("aria-labelledby", "desktopCaptureTitle")'));
assert(cohostSource.includes('alt=""'));
assert(cohostSource.includes('id="customModelSelectLabel"'));
assert(cohostSource.includes('aria-live="off" aria-label="Co-host conversation"'));
assert(cohostSource.includes('responseTypeValue === "text" || cohostOutputMuted'));
for (const id of ["cohostSpotifyControl", "cohostObsControl", "cohostFeaturedChatControl", "aiOverlayFromChatBot", "aiOverlayTts"]) {
const input = popupSource.match(new RegExp(`]+id="${id}"[^>]*>`));
assert(input, `${id} should exist`);
assert(/aria-labelledby=/.test(input[0]), `${id} should have an accessible name`);
}
for (const guidePath of guidePaths) {
const guide = fs.readFileSync(guidePath, "utf8");
assert(guide.includes('class="skip-link" href="#main-content"'));
assert(guide.includes('id="main-content"'));
assert(guide.includes('