Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion site/src/pages/TasksPage/TasksPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { withAuthProvider, withProxyProvider } from "testHelpers/storybook";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { API } from "api/api";
import { MockUsers } from "pages/UsersPage/storybookData/users";
import { expect, spyOn, userEvent, within } from "storybook/test";
import { expect, spyOn, userEvent, waitFor, within } from "storybook/test";
import { getTemplatesQueryKey } from "../../api/queries/templates";
import TasksPage from "./TasksPage";

Expand Down Expand Up @@ -145,6 +145,29 @@ export const LoadedTasksWaitingForInputTab: Story = {
spyOn(API, "getTasks").mockResolvedValue([
{
...firstTask,
id: "active-idle-task",
display_name: "Active Idle Task",
status: "active",
current_state: {
...firstTask.current_state,
state: "idle",
},
},
{
...firstTask,
id: "paused-idle-task",
display_name: "Paused Idle Task",
status: "paused",
current_state: {
...firstTask.current_state,
state: "idle",
},
},
{
...firstTask,
id: "error-idle-task",
display_name: "Error Idle Task",
status: "error",
current_state: {
...firstTask.current_state,
state: "idle",
Expand All @@ -161,6 +184,23 @@ export const LoadedTasksWaitingForInputTab: Story = {
name: /waiting for input/i,
});
await userEvent.click(waitingForInputTab);

// Wait for the table to update after tab switch
await waitFor(async () => {
const table = canvas.getByRole("table");
const tableContent = within(table);

// Active idle task should be visible
expect(tableContent.getByText("Active Idle Task")).toBeInTheDocument();

// Only active idle tasks should be visible in the table
expect(
tableContent.queryByText("Paused Idle Task"),
).not.toBeInTheDocument();
expect(
tableContent.queryByText("Error Idle Task"),
).not.toBeInTheDocument();
});
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/TasksPage/TasksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TasksPage: FC = () => {
refetchInterval: 10_000,
});
const idleTasks = tasksQuery.data?.filter(
(task) => task.current_state?.state === "idle",
(task) => task.status === "active" && task.current_state?.state === "idle",
);
const displayedTasks =
tab.value === "waiting-for-input" ? idleTasks : tasksQuery.data;
Expand Down
Loading