Skip to content
Source
Sign inSign up

textGenerationPrompts.test.ts

31 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { buildThreadTitlePrompt } from "./textGenerationPrompts.ts";
4import { normalizeCliError } from "./textGenerationUtils.ts";
5​
6describe("normalizeCliError", () => {
7 it("does not expose CLI failure details in the public error message", () => {
8 const result = normalizeCliError(
9 "codex",
10 "generateCommitMessage",
11 new Error("request failed with access_token=secret-token"),
12 "Failed to generate a commit message",
13 );
14​
15 expect(result.detail).toBe("Failed to generate a commit message");
16 expect(result.message).not.toContain("secret-token");
17 });
18});
19​
20describe("buildThreadTitlePrompt", () => {
21 it("names the project to leave out of initial and regenerated titles", () => {
22 for (const previousTitle of [undefined, "Hyperdrive Config Crash"]) {
23 const { prompt } = buildThreadTitlePrompt({
24 message: "hyperdrive init crashes without a config",
25 previousTitle,
26 projectTitle: "Hyperdrive",
27 });
28 expect(prompt).toContain('Never include the project name ("Hyperdrive")');
29 }
30 });
31});