fix(test): update agents.test.tsx for AgentsPanel table refactor

AgentsPanel no longer renders AgentCardGrid — it uses a Table directly.
The two tests that looked for agent-card-grid are updated to instead verify
the Actions column header appears for admins and is absent for non-admins.
This commit is contained in:
yuneng-jiang 2026-03-07 23:50:06 -08:00
parent 5acb25fd9e
commit 81b223138a

View file

@ -20,6 +20,8 @@ vi.mock("./agents/agent_card_grid", () => ({
),
}));
// Note: agents.tsx no longer uses AgentCardGrid — it renders a Table directly.
vi.mock("./agents/agent_info", () => ({
default: () => <div data-testid="agent-info" />,
}));
@ -54,19 +56,19 @@ describe("AgentsPanel", () => {
expect(screen.queryByText("+ Add New Agent")).not.toBeInTheDocument();
});
it("should pass isAdmin=true to AgentCardGrid for admin role", async () => {
it("should show Actions column header for admin role", async () => {
render(<AgentsPanel accessToken="test-token" userRole="Admin" />);
await waitFor(() => {
const grid = screen.getByTestId("agent-card-grid");
expect(grid).toHaveAttribute("data-is-admin", "true");
expect(screen.getByRole("columnheader", { name: /actions/i })).toBeInTheDocument();
});
});
it("should pass isAdmin=false to AgentCardGrid for internal user role", async () => {
it("should not show Actions column header for internal user role", async () => {
render(<AgentsPanel accessToken="test-token" userRole="Internal User" />);
await waitFor(() => {
const grid = screen.getByTestId("agent-card-grid");
expect(grid).toHaveAttribute("data-is-admin", "false");
expect(screen.queryByRole("columnheader", { name: /actions/i })).not.toBeInTheDocument();
// confirm table is rendered (not still loading)
expect(screen.getByRole("table")).toBeInTheDocument();
});
});