add generation cancellation middleware and refactor chat/message workflows to support HTTP client disconnections
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user