feat: connect resource library workflows
This commit is contained in:
@@ -8,12 +8,14 @@ test("renders a dense toolbar row with compact controls", () => {
|
||||
render(
|
||||
<PageToolbar>
|
||||
<Input aria-label="search" />
|
||||
<Select aria-label="status">
|
||||
<option value="all">全部状态</option>
|
||||
</Select>
|
||||
<Select
|
||||
aria-label="status"
|
||||
options={[{ value: "all", label: "全部状态" }]}
|
||||
value="all"
|
||||
/>
|
||||
</PageToolbar>,
|
||||
);
|
||||
|
||||
expect(screen.getByLabelText("search").className).toContain("h-9");
|
||||
expect(screen.getByLabelText("status").className).toContain("h-9");
|
||||
expect(screen.getByRole("combobox", { name: "status" }).className).toContain("h-9");
|
||||
});
|
||||
|
||||
32
tests/ui/select.test.tsx
Normal file
32
tests/ui/select.test.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { expect, test, vi } from "vitest";
|
||||
|
||||
import { Select } from "@/components/ui/select";
|
||||
|
||||
test("renders a shadcn-style popover select and emits the chosen value", () => {
|
||||
const onValueChange = vi.fn();
|
||||
|
||||
render(
|
||||
<Select
|
||||
aria-label="status"
|
||||
options={[
|
||||
{ value: "all", label: "全部状态" },
|
||||
{ value: "waiting_review", label: "待审核" },
|
||||
]}
|
||||
placeholder="请选择状态"
|
||||
value="all"
|
||||
onValueChange={onValueChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
const trigger = screen.getByRole("combobox", { name: "status" });
|
||||
expect(trigger.className).toContain("inline-flex");
|
||||
expect(trigger.className).toContain("justify-between");
|
||||
fireEvent.click(trigger);
|
||||
|
||||
expect(screen.getByRole("option", { name: "待审核" })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("option", { name: "待审核" }));
|
||||
|
||||
expect(onValueChange).toHaveBeenCalledWith("waiting_review");
|
||||
});
|
||||
Reference in New Issue
Block a user