Files
KrisHD_AI/test/conversation.test.js
T
2026-10-05 23:21:42 +02:00

23 lines
1.1 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
test("conversation navigation", async t => {
const original = Object.fromEntries(["document", "window", "history", "location"].map(key => [key, globalThis[key]]));
const elements = new Map();
globalThis.document = {
getElementById(id) {
if (!elements.has(id)) elements.set(id, {value: "", textContent: "", querySelectorAll: () => []});
return elements.get(id);
},
querySelectorAll: () => [], querySelector: () => null
};
globalThis.location = {pathname: "/app/chats/1", search: ""};
globalThis.window = {location: globalThis.location};
globalThis.history = {replaceState(_data, _unused, path) { globalThis.location.pathname = path; }};
t.after(() => { for (const [key, value] of Object.entries(original)) globalThis[key] = value; });
const {registerConversationTests} = await import("../browser-tests/conversationCases.js");
const cases = [];
registerConversationTests((name, run) => cases.push({name, run}), assert);
for (const {name, run} of cases) await t.test(name, run);
});