41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { buildAIStewardQAUrl, resolveQAPageAnchor } from "@/components/ai-steward/qaPageAnchor";
|
|
|
|
describe("resolveQAPageAnchor", () => {
|
|
it("uses pathname project anchor for project board routes", () => {
|
|
expect(resolveQAPageAnchor("/projects/17/board", "")).toMatchObject({
|
|
projectId: 17,
|
|
sourceChatId: null,
|
|
anchorType: "project",
|
|
origin: "pathname",
|
|
});
|
|
});
|
|
|
|
it("uses query project filter for space routes", () => {
|
|
expect(resolveQAPageAnchor("/space", "?project_id=19")).toMatchObject({
|
|
projectId: 19,
|
|
sourceChatId: null,
|
|
anchorType: "project_filter",
|
|
origin: "search_param",
|
|
});
|
|
});
|
|
|
|
it("preserves explicit source chat anchor from query params", () => {
|
|
expect(resolveQAPageAnchor("/ai-steward", "?tab=qa&project_id=23&source_chat_id=chat-23")).toMatchObject({
|
|
projectId: 23,
|
|
sourceChatId: "chat-23",
|
|
anchorType: "chat_scope",
|
|
origin: "search_param",
|
|
});
|
|
});
|
|
|
|
it("builds anchored space urls for project entry points", () => {
|
|
expect(buildAIStewardQAUrl({ projectId: 17 })).toBe("/space?view=ai-history&project_id=17");
|
|
expect(buildAIStewardQAUrl({ projectId: "23", sourceChatId: "chat-23" })).toBe(
|
|
"/space?view=ai-history&project_id=23&source_chat_id=chat-23",
|
|
);
|
|
expect(buildAIStewardQAUrl()).toBe("/space?view=ai-history");
|
|
});
|
|
});
|