-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage-generation.test.js
More file actions
78 lines (67 loc) · 2.92 KB
/
Copy pathimage-generation.test.js
File metadata and controls
78 lines (67 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { describe, expect, test } from "bun:test";
import {
buildCodexImageWorkerPrompt,
buildImagePrompt,
resolveGeminiImageRuntime,
resolveImageProvider,
resolveImageTimeoutMs,
} from "./image-generation.js";
describe("buildImagePrompt", () => {
test("uses photorealistic Chinese portrait constraints for Codex self-portrait revisions", () => {
const prompt = buildImagePrompt("画一个自画像,我想要帅哥,中国人,真实感,不要大叔,不要动漫", {
ETWIN_DISPLAY_NAME: "Codex Twin",
ETWIN_PERSONA: "codex",
});
expect(prompt).toContain("Codex Twin");
expect(prompt).toContain("Photorealistic handsome Chinese man");
expect(prompt).toContain("Chinese / East Asian facial features");
expect(prompt).toContain("realistic cinematic photograph");
expect(prompt).toContain("Avoid: anime, manga, illustration, digital painting, CGI, 3D render");
expect(prompt).toContain("mature uncle");
});
test("uses the configured companion name for CC self-portrait requests", () => {
const prompt = buildImagePrompt("你能画个自画像么?", { ETWIN_DISPLAY_NAME: "CC Twin", ETWIN_PERSONA: "cc" });
expect(prompt).toContain("CC Twin");
expect(prompt).not.toContain("Codex Twin");
});
});
describe("resolveImageProvider", () => {
test("defaults to Codex native image generation", () => {
expect(resolveImageProvider({})).toBe("codex-native");
expect(resolveImageProvider({ ETWIN_IMAGE_MODEL: "gemini-3-pro" })).toBe("codex-native");
});
test("only uses Gemini when explicitly selected", () => {
expect(resolveImageProvider({ ETWIN_IMAGE_PROVIDER: "gemini" })).toBe("gemini");
});
});
describe("resolveGeminiImageRuntime", () => {
test("derives portable defaults from the current home directory", () => {
expect(resolveGeminiImageRuntime({}, "/tmp/example-home")).toEqual({
cwd: "/tmp/example-home/content-publisher",
cliPath: "/tmp/example-home/content-publisher/scripts/gemini-web-image/gemini-web-image.ts",
});
});
test("supports an explicit publisher directory and absolute CLI", () => {
expect(resolveGeminiImageRuntime({
ETWIN_CONTENT_PUBLISHER_DIR: "/srv/publisher",
ETWIN_IMAGE_CLI: "/opt/bin/image.ts",
}, "/ignored")).toEqual({
cwd: "/srv/publisher",
cliPath: "/opt/bin/image.ts",
});
});
});
describe("resolveImageTimeoutMs", () => {
test("uses a longer default for native image generation", () => {
expect(resolveImageTimeoutMs({})).toBe(600000);
});
});
describe("buildCodexImageWorkerPrompt", () => {
test("forces built-in image_gen and blocks Gemini", () => {
const prompt = buildCodexImageWorkerPrompt("画一个真实中国人头像", "/tmp/out.png");
expect(prompt).toContain("built-in Codex image_gen");
expect(prompt).toContain("Do not use Gemini");
expect(prompt).toContain("/tmp/out.png");
expect(prompt).toContain("SUCCESS: path=/tmp/out.png");
});
});