@@ -28,7 +28,7 @@ describe("useAgentLogs", () => {
2828expect ( wsSpy ) . not . toHaveBeenCalled ( ) ;
2929} ) ;
3030
31- it ( "should return existing logs without network calls" , async ( ) => {
31+ it ( "should return existing logs without network calls if state is off " , async ( ) => {
3232const queryClient = createTestQueryClient ( ) ;
3333queryClient . setQueryData (
3434agentLogsKey ( MockWorkspace . id , MockWorkspaceAgent . id ) ,
@@ -39,7 +39,7 @@ describe("useAgentLogs", () => {
3939const { result} = renderUseAgentLogs ( queryClient , {
4040workspaceId :MockWorkspace . id ,
4141agentId :MockWorkspaceAgent . id ,
42- agentLifeCycleState :"ready " ,
42+ agentLifeCycleState :"off " ,
4343} ) ;
4444await waitFor ( ( ) => {
4545expect ( result . current ) . toHaveLength ( 5 ) ;
@@ -48,12 +48,12 @@ describe("useAgentLogs", () => {
4848expect ( wsSpy ) . not . toHaveBeenCalled ( ) ;
4949} ) ;
5050
51- it ( "should fetch logs when empty and should not connect to WebSocket when not starting " , async ( ) => {
51+ it ( "should fetch logs when empty" , async ( ) => {
5252const queryClient = createTestQueryClient ( ) ;
5353const fetchSpy = jest
5454. spyOn ( API , "getWorkspaceAgentLogs" )
5555. mockResolvedValueOnce ( generateLogs ( 5 ) ) ;
56- const wsSpy = jest . spyOn ( APIModule , "watchWorkspaceAgentLogs" ) ;
56+ jest . spyOn ( APIModule , "watchWorkspaceAgentLogs" ) ;
5757const { result} = renderUseAgentLogs ( queryClient , {
5858workspaceId :MockWorkspace . id ,
5959agentId :MockWorkspaceAgent . id ,
@@ -63,10 +63,9 @@ describe("useAgentLogs", () => {
6363expect ( result . current ) . toHaveLength ( 5 ) ;
6464} ) ;
6565expect ( fetchSpy ) . toHaveBeenCalledWith ( MockWorkspaceAgent . id ) ;
66- expect ( wsSpy ) . not . toHaveBeenCalled ( ) ;
6766} ) ;
6867
69- it ( "should fetch logs and connect to websocket when agent is starting " , async ( ) => {
68+ it ( "should fetch logs and connect to websocket" , async ( ) => {
7069const queryClient = createTestQueryClient ( ) ;
7170const logs = generateLogs ( 5 ) ;
7271const fetchSpy = jest