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,84 @@
import { render, screen } from "@testing-library/react";
import { expect, test } from "vitest";
import { WorkflowDetail } from "@/features/workflows/workflow-detail";
import type { WorkflowDetailVM } from "@/lib/types/view-models";
const BASE_WORKFLOW_DETAIL: WorkflowDetailVM = {
orderId: 101,
workflowId: "wf-101",
workflowType: "mid_end",
status: "waiting_review",
statusMeta: {
label: "待审核",
tone: "warning",
},
currentStep: "review",
currentStepLabel: "人工审核",
currentRevisionAssetId: null,
currentRevisionVersion: null,
latestRevisionAssetId: null,
latestRevisionVersion: null,
revisionCount: 0,
reviewTaskStatus: null,
pendingManualConfirm: false,
createdAt: "2026-03-27T00:00:00Z",
updatedAt: "2026-03-27T00:10:00Z",
steps: [
{
id: 11,
workflowRunId: 9001,
name: "fusion",
label: "融合",
status: "failed",
statusMeta: {
label: "失败",
tone: "danger",
},
input: null,
output: null,
errorMessage: "Temporal activity timed out.",
startedAt: "2026-03-27T00:06:00Z",
endedAt: "2026-03-27T00:07:00Z",
containsMockAssets: false,
mockAssetUris: [],
isCurrent: false,
isFailed: true,
},
{
id: 12,
workflowRunId: 9001,
name: "review",
label: "人工审核",
status: "waiting",
statusMeta: {
label: "等待人工处理",
tone: "warning",
},
input: null,
output: {
preview_uri: "mock://fusion-preview",
},
errorMessage: null,
startedAt: "2026-03-27T00:09:00Z",
endedAt: null,
containsMockAssets: true,
mockAssetUris: ["mock://fusion-preview"],
isCurrent: true,
isFailed: false,
},
],
stepTimelineState: {
kind: "ready",
},
failureCount: 1,
hasMockAssets: true,
};
test("highlights failed steps and mock asset hints in the workflow timeline", () => {
render(<WorkflowDetail viewModel={BASE_WORKFLOW_DETAIL} />);
expect(screen.getByText("失败步骤 1 个")).toBeInTheDocument();
expect(screen.getByText("Temporal activity timed out.")).toBeInTheDocument();
expect(screen.getByText("当前流程包含 mock 资产")).toBeInTheDocument();
});

View File

@@ -0,0 +1,62 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { expect, test, vi } from "vitest";
import { WorkflowLookup } from "@/features/workflows/workflow-lookup";
import type { WorkflowLookupItemVM } from "@/lib/types/view-models";
const WORKFLOW_ITEMS: WorkflowLookupItemVM[] = [
{
orderId: 4201,
workflowId: "wf-4201",
workflowType: "MidEndPipelineWorkflow",
status: "waiting_review",
statusMeta: {
label: "待审核",
tone: "warning",
},
currentStep: "review",
currentStepLabel: "人工审核",
updatedAt: "2026-03-27T09:15:00Z",
},
];
test("shows the real recent-workflows entry state", () => {
render(<WorkflowLookup items={WORKFLOW_ITEMS} />);
expect(screen.getByText("流程追踪首页当前显示真实后端最近流程。")).toBeInTheDocument();
expect(screen.getByText("订单 #4201")).toBeInTheDocument();
});
test("supports workflow status filtering and pagination actions", () => {
const onStatusChange = vi.fn();
const onPageChange = vi.fn();
const onQuerySubmit = vi.fn();
render(
<WorkflowLookup
currentPage={2}
items={WORKFLOW_ITEMS}
onPageChange={onPageChange}
onQuerySubmit={onQuerySubmit}
onStatusChange={onStatusChange}
selectedStatus="waiting_review"
selectedQuery=""
totalPages={3}
/>,
);
fireEvent.change(screen.getByLabelText("流程关键词搜索"), {
target: { value: "4201" },
});
fireEvent.click(screen.getByRole("button", { name: "搜索流程" }));
fireEvent.change(screen.getByLabelText("流程状态筛选"), {
target: { value: "failed" },
});
fireEvent.click(screen.getByRole("button", { name: "上一页" }));
fireEvent.click(screen.getByRole("button", { name: "下一页" }));
expect(onQuerySubmit).toHaveBeenCalledWith("4201");
expect(onStatusChange).toHaveBeenCalledWith("failed");
expect(onPageChange).toHaveBeenNthCalledWith(1, 1);
expect(onPageChange).toHaveBeenNthCalledWith(2, 3);
});