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,83 @@
import { afterEach, expect, test, vi } from "vitest";
import { GET } from "../../../app/api/dashboard/orders-overview/route";
afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
});
test("proxies recent orders overview from the backend list api", async () => {
vi.stubEnv("BACKEND_BASE_URL", "http://backend.test/api/v1");
const fetchMock = vi.fn().mockResolvedValue(
new Response(
JSON.stringify({
page: 2,
limit: 3,
total: 5,
total_pages: 2,
items: [
{
order_id: 3,
workflow_id: "order-3",
customer_level: "mid",
service_mode: "semi_pro",
status: "waiting_review",
current_step: "review",
updated_at: "2026-03-27T14:00:03Z",
final_asset_id: null,
review_task_status: "revision_uploaded",
latest_revision_asset_id: 8,
latest_revision_version: 1,
revision_count: 1,
pending_manual_confirm: true,
},
],
}),
{
status: 200,
headers: {
"content-type": "application/json",
},
},
),
);
vi.stubGlobal("fetch", fetchMock);
const response = await GET(
new Request("http://frontend.test/api/dashboard/orders-overview?page=2&limit=3&status=waiting_review&query=order-3"),
);
const payload = await response.json();
expect(response.status).toBe(200);
expect(payload).toEqual({
mode: "proxy",
data: {
page: 2,
limit: 3,
total: 5,
totalPages: 2,
items: [
{
orderId: 3,
workflowId: "order-3",
status: "waiting_review",
statusMeta: {
label: "待审核",
tone: "warning",
},
currentStep: "review",
currentStepLabel: "人工审核",
updatedAt: "2026-03-27T14:00:03Z",
},
],
},
message: "订单总览当前显示真实后端最近订单。",
});
expect(fetchMock).toHaveBeenCalledWith(
"http://backend.test/api/v1/orders?page=2&limit=3&status=waiting_review&query=order-3",
expect.any(Object),
);
});