diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/jobs/__tests__/stream-agent-chat.job.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/jobs/__tests__/stream-agent-chat.job.spec.ts index 522bc79325..755a9c098f 100644 --- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/jobs/__tests__/stream-agent-chat.job.spec.ts +++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/jobs/__tests__/stream-agent-chat.job.spec.ts @@ -230,11 +230,14 @@ describe('StreamAgentChatJob', () => { ); expect(chunkEvents).toHaveLength(TEXT_CHUNKS.length); - expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + expect(publishedEvents[publishedEvents.length - 2]).toMatchObject({ type: 'stream-error', code: 'STREAM_EXECUTION_FAILED', message: 'provider exploded', }); + expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + type: 'queue-updated', + }); expect(publishedEvents.map((event) => event.type)).not.toContain( 'message-persisted', ); @@ -264,10 +267,13 @@ describe('StreamAgentChatJob', () => { 'model resolution failed', ); - expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + expect(publishedEvents[publishedEvents.length - 2]).toMatchObject({ type: 'stream-error', message: 'model resolution failed', }); + expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + type: 'queue-updated', + }); expect(threadRepository.update).toHaveBeenCalledWith( 'workspace-id', { id: 'thread-id', activeStreamId: 'stream-id' }, @@ -287,9 +293,12 @@ describe('StreamAgentChatJob', () => { ); expect(chunkEvents).toHaveLength(TEXT_CHUNKS.length); - expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + expect(publishedEvents[publishedEvents.length - 2]).toMatchObject({ type: 'stream-error', }); + expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + type: 'queue-updated', + }); expect(publishedEvents.map((event) => event.type)).not.toContain( 'message-persisted', ); @@ -304,10 +313,13 @@ describe('StreamAgentChatJob', () => { code: AiExceptionCode.WORKSPACE_NOT_FOUND, }); - expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + expect(publishedEvents[publishedEvents.length - 2]).toMatchObject({ type: 'stream-error', code: AiExceptionCode.WORKSPACE_NOT_FOUND, }); + expect(publishedEvents[publishedEvents.length - 1]).toMatchObject({ + type: 'queue-updated', + }); expect(threadRepository.update).toHaveBeenCalledWith( 'workspace-id', { id: 'thread-id' },