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,64 @@
import { afterEach, expect, test, vi } from "vitest";
import { POST } from "../../../app/api/reviews/[orderId]/confirm-revision/route";
afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
});
test("proxies revision confirmation and normalizes response data", async () => {
vi.stubEnv("BACKEND_BASE_URL", "http://backend.test/api/v1");
const fetchMock = vi.fn().mockResolvedValue(
new Response(
JSON.stringify({
order_id: 101,
workflow_id: "wf-101",
revision_asset_id: 501,
decision: "approve",
status: "submitted",
}),
{
status: 200,
headers: {
"content-type": "application/json",
},
},
),
);
vi.stubGlobal("fetch", fetchMock);
const request = new Request("http://localhost/api/reviews/101/confirm-revision", {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
reviewer_id: 88,
comment: "确认继续流水线",
}),
});
const response = await POST(request, {
params: Promise.resolve({ orderId: "101" }),
});
const payload = await response.json();
expect(response.status).toBe(200);
expect(payload).toEqual({
mode: "proxy",
data: {
orderId: 101,
workflowId: "wf-101",
revisionAssetId: 501,
decision: "approve",
decisionMeta: {
label: "通过",
tone: "success",
},
status: "submitted",
},
});
});