@@ -10,7 +10,7 @@ import { withAuthProvider, withProxyProvider } from "testHelpers/storybook";
1010import type { Meta , StoryObj } from "@storybook/react-vite" ;
1111import { API } from "api/api" ;
1212import { MockUsers } from "pages/UsersPage/storybookData/users" ;
13- import { expect , spyOn , userEvent , within } from "storybook/test" ;
13+ import { expect , spyOn , userEvent , waitFor , within } from "storybook/test" ;
1414import { getTemplatesQueryKey } from "../../api/queries/templates" ;
1515import TasksPage from "./TasksPage" ;
1616
@@ -145,6 +145,29 @@ export const LoadedTasksWaitingForInputTab: Story = {
145145 spyOn ( API , "getTasks" ) . mockResolvedValue ( [
146146 {
147147 ...firstTask ,
148+ id : "active-idle-task" ,
149+ display_name : "Active Idle Task" ,
150+ status : "active" ,
151+ current_state : {
152+ ...firstTask . current_state ,
153+ state : "idle" ,
154+ } ,
155+ } ,
156+ {
157+ ...firstTask ,
158+ id : "paused-idle-task" ,
159+ display_name : "Paused Idle Task" ,
160+ status : "paused" ,
161+ current_state : {
162+ ...firstTask . current_state ,
163+ state : "idle" ,
164+ } ,
165+ } ,
166+ {
167+ ...firstTask ,
168+ id : "error-idle-task" ,
169+ display_name : "Error Idle Task" ,
170+ status : "error" ,
148171 current_state : {
149172 ...firstTask . current_state ,
150173 state : "idle" ,
@@ -161,6 +184,23 @@ export const LoadedTasksWaitingForInputTab: Story = {
161184 name : / w a i t i n g f o r i n p u t / i,
162185 } ) ;
163186 await userEvent . click ( waitingForInputTab ) ;
187+
188+ // Wait for the table to update after tab switch
189+ await waitFor ( async ( ) => {
190+ const table = canvas . getByRole ( "table" ) ;
191+ const tableContent = within ( table ) ;
192+
193+ // Active idle task should be visible
194+ expect ( tableContent . getByText ( "Active Idle Task" ) ) . toBeInTheDocument ( ) ;
195+
196+ // Only active idle tasks should be visible in the table
197+ expect (
198+ tableContent . queryByText ( "Paused Idle Task" ) ,
199+ ) . not . toBeInTheDocument ( ) ;
200+ expect (
201+ tableContent . queryByText ( "Error Idle Task" ) ,
202+ ) . not . toBeInTheDocument ( ) ;
203+ } ) ;
164204 } ) ;
165205 } ,
166206} ;
0 commit comments