Files
pi-agent-integrated/pi-web/lib/rpc-manager.test.mjs
T

35 lines
1.5 KiB
JavaScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
test("RPC session startup preloads extension-registered providers before restoring models", async () => {
const source = await readFile(new URL("./rpc-manager.ts", import.meta.url), "utf8");
const startupSource = source.slice(source.indexOf("export async function startRpcSession"));
assert.match(startupSource, /createAgentSessionServices\(/);
assert.match(startupSource, /createAgentSessionFromServices\(/);
assert.doesNotMatch(startupSource, /await createAgentSession\(/);
});
test("custom extension UI receives the fixed headless terminal facade", async () => {
const source = await readFile(new URL("./rpc-manager.ts", import.meta.url), "utf8");
const customUiSource = source.slice(
source.indexOf("private requestExtensionCustomUi"),
source.indexOf("private requestExtensionUi"),
);
assert.match(customUiSource, /createHeadlessCustomUiTui\(/);
assert.match(customUiSource, /width,/);
});
test("reloading a session invalidates the models cache", async () => {
const source = await readFile(new URL("./rpc-manager.ts", import.meta.url), "utf8");
const reloadSource = source.slice(
source.indexOf('case "reload"'),
source.indexOf('case "abort_compaction"'),
);
assert.match(reloadSource, /await this\.inner\.reload\(\)/);
assert.match(reloadSource, /this\.applyForcedEmptySystemPrompt\(\);\s*invalidateModelsCache\(\)/);
});