63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import {
|
|
resolveVip98kTaskInvocation,
|
|
type Vip98kTaskInvocation,
|
|
} from "@/lib/ai/vip98k-task-invocation";
|
|
|
|
const textToImageInvocation: Vip98kTaskInvocation = {
|
|
kind: "tool",
|
|
method: "POST",
|
|
path: "/api/external/tools/generate?tool_id=google%2Fnano-banana-2%2Ftext-to-image",
|
|
contentType: "application/json",
|
|
requestExample: { prompt: "Generate an image" },
|
|
resultMethod: "GET",
|
|
resultPath:
|
|
"/api/external/tools/result?tool_id=google%2Fnano-banana-2%2Ftext-to-image&taskId={task_id}",
|
|
};
|
|
|
|
test.describe("VIP98K reference-image routing", () => {
|
|
test("replaces a text-to-image alias invocation with the resolved reference tool", () => {
|
|
const invocation = resolveVip98kTaskInvocation(
|
|
"google/nano-banana-2/reference-to-image",
|
|
textToImageInvocation
|
|
);
|
|
|
|
expect(invocation?.path).toContain(
|
|
"tool_id=google%2Fnano-banana-2%2Freference-to-image"
|
|
);
|
|
expect(invocation?.resultPath).toContain(
|
|
"tool_id=google%2Fnano-banana-2%2Freference-to-image"
|
|
);
|
|
expect(invocation?.requestExample).toMatchObject({
|
|
prompt: "",
|
|
video_clips: [{ fps: 1, url: "", ends: 0, start: 0 }],
|
|
});
|
|
});
|
|
|
|
test("keeps the catalog invocation when it already targets the resolved tool", () => {
|
|
const catalogInvocation: Vip98kTaskInvocation = {
|
|
...textToImageInvocation,
|
|
path: "/api/external/tools/generate?tool_id=google%2Fnano-banana-2%2Freference-to-image",
|
|
resultPath:
|
|
"/api/external/tools/result?tool_id=google%2Fnano-banana-2%2Freference-to-image&taskId={task_id}",
|
|
requestExample: {
|
|
prompt: "Catalog prompt",
|
|
video_clips: [{ fps: 2, url: "catalog", ends: 1, start: 0 }],
|
|
},
|
|
};
|
|
|
|
expect(
|
|
resolveVip98kTaskInvocation(
|
|
"google/nano-banana-2/reference-to-image",
|
|
catalogInvocation
|
|
)
|
|
).toBe(catalogInvocation);
|
|
});
|
|
|
|
test("does not rewrite unrelated tools", () => {
|
|
expect(
|
|
resolveVip98kTaskInvocation("other/image-model", textToImageInvocation)
|
|
).toBe(textToImageInvocation);
|
|
});
|
|
});
|