feat: bootstrap auto virtual tryon admin frontend

This commit is contained in:
afei A
2026-03-27 23:38:50 +08:00
commit 98c6b741d6
119 changed files with 19046 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import { expect, test } from "vitest";
import { GET } from "../../../app/api/libraries/[libraryType]/route";
test("returns honest placeholder library data for unsupported backend modules", async () => {
const response = await GET(new Request("http://localhost/api/libraries/models"), {
params: Promise.resolve({ libraryType: "models" }),
});
const payload = await response.json();
expect(response.status).toBe(200);
expect(payload).toMatchObject({
mode: "placeholder",
data: {
items: expect.arrayContaining([
expect.objectContaining({
libraryType: "models",
isMock: true,
}),
]),
},
message: "资源库当前使用占位数据,真实后端接口尚未提供。",
});
});
test("rejects unsupported placeholder library types with a normalized error", async () => {
const response = await GET(new Request("http://localhost/api/libraries/unknown"), {
params: Promise.resolve({ libraryType: "unknown" }),
});
const payload = await response.json();
expect(response.status).toBe(404);
expect(payload).toEqual({
error: "NOT_FOUND",
message: "不支持的资源库类型。",
});
});
test("rejects inherited object keys instead of treating them as valid library types", async () => {
const response = await GET(new Request("http://localhost/api/libraries/toString"), {
params: Promise.resolve({ libraryType: "toString" }),
});
const payload = await response.json();
expect(response.status).toBe(404);
expect(payload).toEqual({
error: "NOT_FOUND",
message: "不支持的资源库类型。",
});
});