Files
bot/test/scripts/check-no-raw-window-open.test.ts
zeekayandHanzo Dev 06e4edb152 the CLI's docs links open docs.hanzo.bot, where the bot docs are published
docs.bot.ai does not resolve, so every Docs: line the CLI printed, and the doctor and migrate guide links, went nowhere. DOCS_ROOT and the literal links now point at https://docs.hanzo.bot/docs, which hanzo-docs/docs publishes from this repo's docs/. The docs search command still names the old Mintlify MCP tool; nothing serves an equivalent yet.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-24 21:12:08 -07:00

40 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { findRawWindowOpenLines } from "../../scripts/check-no-raw-window-open.mjs";
describe("check-no-raw-window-open", () => {
it("finds direct window.open calls", () => {
const source = `
function openDocs() {
window.open("https://docs.hanzo.bot/docs");
}
`;
expect(findRawWindowOpenLines(source)).toEqual([3]);
});
it("finds globalThis.open calls", () => {
const source = `
function openDocs() {
globalThis.open("https://docs.hanzo.bot/docs");
}
`;
expect(findRawWindowOpenLines(source)).toEqual([3]);
});
it("ignores mentions in strings and comments", () => {
const source = `
// window.open("https://example.com")
const text = "window.open('https://example.com')";
`;
expect(findRawWindowOpenLines(source)).toEqual([]);
});
it("handles parenthesized and asserted window references", () => {
const source = `
const openRef = (window as Window).open;
openRef("https://example.com");
(window as Window).open("https://example.com");
`;
expect(findRawWindowOpenLines(source)).toEqual([4]);
});
});