47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
myProjectConversationTypeFromSearchParams,
|
|
myProjectConversationTypeOfThread,
|
|
myProjectThreadMetadata,
|
|
withMyProjectConversationMarker,
|
|
} from "./project-metadata";
|
|
|
|
test("project conversation type is read from persisted metadata", () => {
|
|
assert.equal(
|
|
myProjectConversationTypeOfThread({
|
|
metadata: myProjectThreadMetadata("strategy"),
|
|
}),
|
|
"strategy",
|
|
);
|
|
assert.equal(
|
|
myProjectConversationTypeOfThread({
|
|
metadata: { project_source: "elsewhere", project_type: "qa" },
|
|
}),
|
|
null,
|
|
);
|
|
});
|
|
|
|
test("metadata wins over the compatibility context fallback", () => {
|
|
assert.equal(
|
|
myProjectConversationTypeOfThread({
|
|
metadata: myProjectThreadMetadata("solution"),
|
|
context: myProjectThreadMetadata("qa"),
|
|
}),
|
|
"solution",
|
|
);
|
|
});
|
|
|
|
test("new-chat route marker round-trips all supported project types", () => {
|
|
for (const type of ["qa", "strategy", "solution"] as const) {
|
|
const path = withMyProjectConversationMarker(
|
|
"/page/strategy/chats/new?keep=1",
|
|
type,
|
|
);
|
|
const params = new URLSearchParams(path.split("?", 2)[1]);
|
|
assert.equal(params.get("keep"), "1");
|
|
assert.equal(myProjectConversationTypeFromSearchParams(params), type);
|
|
}
|
|
});
|