Files
DeepTutor/web/tests/chat-launch-intent.test.ts
2026-08-29 22:29:53 +08:00

48 lines
1.4 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
newMasteryPathChatUrl,
readChatLaunchIntent,
} from "../lib/chat-launch-intent";
test("continuing a mastery path opens its dedicated topic surface", () => {
assert.equal(
newMasteryPathChatUrl("calculus/path 1"),
"/mastery/calculus%2Fpath%201",
);
});
test("legacy mastery chat links still parse for forwarding", () => {
const intent = readChatLaunchIntent(
"?capability=mastery_path&mastery_path_id=calculus%2Fpath+1",
);
assert.equal(intent.capability, "mastery_path");
assert.equal(intent.masteryPathId, "calculus/path 1");
assert.deepEqual(intent.tools, []);
});
test("an absent capability stays unspecified, an empty one means plain chat", () => {
assert.equal(readChatLaunchIntent("?tool=web_search").capability, null);
assert.equal(readChatLaunchIntent("?capability=").capability, "");
});
test("tools are collected verbatim for the caller to validate", () => {
assert.deepEqual(
readChatLaunchIntent("?tool=web_search&tool=+reason+").tools,
["web_search", "reason"],
);
});
test("a blank mastery path id is dropped rather than bound", () => {
assert.equal(
readChatLaunchIntent("?mastery_path_id=%20%20").masteryPathId,
null,
);
assert.deepEqual(readChatLaunchIntent(""), {
capability: null,
tools: [],
masteryPathId: null,
});
});