Add AI copilot chat panel to the diagram editor with streaming responses, chat history persistence, and markdown rendering. Includes copilot API route, diagram-aware system prompt, and schema with 15 passing tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { buildCopilotSystemPrompt } from "./system-prompt";
|
|
|
|
import type { DiagramType } from "./types";
|
|
|
|
describe("buildCopilotSystemPrompt", () => {
|
|
it("should include the diagram type in uppercase", () => {
|
|
const prompt = buildCopilotSystemPrompt("bpmn");
|
|
expect(prompt).toContain("BPMN");
|
|
expect(prompt).toContain("Type: BPMN");
|
|
});
|
|
|
|
it("should include diagram description for each type", () => {
|
|
const types: DiagramType[] = [
|
|
"bpmn",
|
|
"er",
|
|
"orgchart",
|
|
"architecture",
|
|
"sequence",
|
|
"flowchart",
|
|
];
|
|
|
|
for (const type of types) {
|
|
const prompt = buildCopilotSystemPrompt(type);
|
|
expect(prompt).toContain(`Type: ${type.toUpperCase()}`);
|
|
expect(prompt).toContain("domaingraph AI copilot");
|
|
expect(prompt).toContain("CHAT-ONLY mode");
|
|
}
|
|
});
|
|
|
|
it("should mention chat-only constraint", () => {
|
|
const prompt = buildCopilotSystemPrompt("er");
|
|
expect(prompt).toContain("CHAT-ONLY mode");
|
|
expect(prompt).toContain("cannot modify the diagram directly");
|
|
});
|
|
|
|
it("should include today's date", () => {
|
|
const prompt = buildCopilotSystemPrompt("flowchart");
|
|
const year = new Date().getFullYear().toString();
|
|
expect(prompt).toContain(year);
|
|
});
|
|
|
|
it("should include ER-specific description", () => {
|
|
const prompt = buildCopilotSystemPrompt("er");
|
|
expect(prompt).toContain("Entity-Relationship");
|
|
expect(prompt).toContain("entities");
|
|
});
|
|
|
|
it("should include architecture-specific description", () => {
|
|
const prompt = buildCopilotSystemPrompt("architecture");
|
|
expect(prompt).toContain("services");
|
|
expect(prompt).toContain("databases");
|
|
});
|
|
});
|