feat: bootstrap auto virtual tryon admin frontend
This commit is contained in:
48
tests/ui/status-badge.test.tsx
Normal file
48
tests/ui/status-badge.test.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { StatusBadge } from "@/components/ui/status-badge";
|
||||
|
||||
// @ts-expect-error "running" is a step status, not a review decision.
|
||||
const invalidReviewDecisionProps: ComponentProps<typeof StatusBadge> = {
|
||||
variant: "reviewDecision",
|
||||
status: "running",
|
||||
};
|
||||
|
||||
test("renders the waiting review label", () => {
|
||||
render(<StatusBadge status="waiting_review" />);
|
||||
|
||||
expect(screen.getByText("待审核")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("uses order status metadata for the rendered tone", () => {
|
||||
render(<StatusBadge status="failed" />);
|
||||
|
||||
expect(screen.getByText("失败")).toHaveAttribute("data-tone", "danger");
|
||||
});
|
||||
|
||||
test("can render review decision metadata when a variant is provided", () => {
|
||||
render(<StatusBadge status="reject" variant="reviewDecision" />);
|
||||
|
||||
expect(screen.getByText("驳回")).toHaveAttribute("data-tone", "danger");
|
||||
});
|
||||
|
||||
test("renders step status metadata for the stepStatus variant", () => {
|
||||
render(<StatusBadge status="running" variant="stepStatus" />);
|
||||
|
||||
expect(screen.getByText("执行中")).toHaveAttribute("data-tone", "info");
|
||||
});
|
||||
|
||||
test("renders workflow step metadata for the workflowStep variant", () => {
|
||||
render(<StatusBadge status="review" variant="workflowStep" />);
|
||||
|
||||
expect(screen.getByText("人工审核")).toHaveAttribute("data-tone", "warning");
|
||||
});
|
||||
|
||||
test("throws a descriptive error for invalid runtime status and variant pairings", () => {
|
||||
expect(() =>
|
||||
render(<StatusBadge status={"reject" as never} variant="order" />),
|
||||
).toThrow('Invalid status "reject" for variant "order".');
|
||||
|
||||
expect(invalidReviewDecisionProps.variant).toBe("reviewDecision");
|
||||
});
|
||||
Reference in New Issue
Block a user