From 0cab6f97a42803cfa8c60fcba5dc823ea97696a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 20 Dec 2024 17:40:20 +0100 Subject: [PATCH] Fix tests --- .../scaling/__tests__/pubsub-handler.test.ts | 38 ++++++++--- .../collaboration.service.test.ts | 68 ++++++++++--------- 2 files changed, 65 insertions(+), 41 deletions(-) diff --git a/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts b/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts index d24339887d45e..4f8c8af85956f 100644 --- a/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts +++ b/packages/cli/src/scaling/__tests__/pubsub-handler.test.ts @@ -620,7 +620,10 @@ describe('PubSubHandler', () => { expect(activeWorkflowManager.add).toHaveBeenCalledWith(workflowId, 'activate', undefined, { shouldPublish: false, }); - expect(push.broadcast).toHaveBeenCalledWith('workflowActivated', { workflowId }); + expect(push.broadcast).toHaveBeenCalledWith({ + type: 'workflowActivated', + data: { workflowId }, + }); expect(publisher.publishCommand).toHaveBeenCalledWith({ command: 'display-workflow-activation', payload: { workflowId }, @@ -680,7 +683,10 @@ describe('PubSubHandler', () => { expect(activeWorkflowManager.removeWorkflowTriggersAndPollers).toHaveBeenCalledWith( workflowId, ); - expect(push.broadcast).toHaveBeenCalledWith('workflowDeactivated', { workflowId }); + expect(push.broadcast).toHaveBeenCalledWith({ + type: 'workflowDeactivated', + data: { workflowId }, + }); expect(publisher.publishCommand).toHaveBeenCalledWith({ command: 'display-workflow-deactivation', payload: { workflowId }, @@ -735,7 +741,10 @@ describe('PubSubHandler', () => { eventService.emit('display-workflow-activation', { workflowId }); - expect(push.broadcast).toHaveBeenCalledWith('workflowActivated', { workflowId }); + expect(push.broadcast).toHaveBeenCalledWith({ + type: 'workflowActivated', + data: { workflowId }, + }); }); it('should handle `display-workflow-deactivation` event', () => { @@ -758,7 +767,10 @@ describe('PubSubHandler', () => { eventService.emit('display-workflow-deactivation', { workflowId }); - expect(push.broadcast).toHaveBeenCalledWith('workflowDeactivated', { workflowId }); + expect(push.broadcast).toHaveBeenCalledWith({ + type: 'workflowDeactivated', + data: { workflowId }, + }); }); it('should handle `display-workflow-activation-error` event', () => { @@ -782,9 +794,12 @@ describe('PubSubHandler', () => { eventService.emit('display-workflow-activation-error', { workflowId, errorMessage }); - expect(push.broadcast).toHaveBeenCalledWith('workflowFailedToActivate', { - workflowId, - errorMessage, + expect(push.broadcast).toHaveBeenCalledWith({ + type: 'workflowFailedToActivate', + data: { + workflowId, + errorMessage, + }, }); }); @@ -874,9 +889,12 @@ describe('PubSubHandler', () => { eventService.emit('response-to-get-worker-status', workerStatus); - expect(push.broadcast).toHaveBeenCalledWith('sendWorkerStatusMessage', { - workerId: workerStatus.senderId, - status: workerStatus, + expect(push.broadcast).toHaveBeenCalledWith({ + type: 'sendWorkerStatusMessage', + data: { + workerId: workerStatus.senderId, + status: workerStatus, + }, }); }); }); diff --git a/packages/cli/test/integration/collaboration/collaboration.service.test.ts b/packages/cli/test/integration/collaboration/collaboration.service.test.ts index df5f901f2817d..ab7a8314b3a55 100644 --- a/packages/cli/test/integration/collaboration/collaboration.service.test.ts +++ b/packages/cli/test/integration/collaboration/collaboration.service.test.ts @@ -78,37 +78,41 @@ describe('CollaborationService', () => { // Assert expect(sendToUsersSpy).toHaveBeenNthCalledWith( 1, - 'collaboratorsChanged', { - collaborators: [ - { - lastSeen: expect.any(String), - user: owner.toIUser(), - }, - ], - workflowId: workflow.id, + type: 'collaboratorsChanged', + data: { + collaborators: [ + { + lastSeen: expect.any(String), + user: owner.toIUser(), + }, + ], + workflowId: workflow.id, + }, }, [owner.id], ); expect(sendToUsersSpy).toHaveBeenNthCalledWith( 2, - 'collaboratorsChanged', { - collaborators: expect.arrayContaining([ - expect.objectContaining({ - lastSeen: expect.any(String), - user: expect.objectContaining({ - id: owner.id, + type: 'collaboratorsChanged', + data: { + collaborators: expect.arrayContaining([ + expect.objectContaining({ + lastSeen: expect.any(String), + user: expect.objectContaining({ + id: owner.id, + }), }), - }), - expect.objectContaining({ - lastSeen: expect.any(String), - user: expect.objectContaining({ - id: memberWithAccess.id, + expect.objectContaining({ + lastSeen: expect.any(String), + user: expect.objectContaining({ + id: memberWithAccess.id, + }), }), - }), - ]), - workflowId: workflow.id, + ]), + workflowId: workflow.id, + }, }, [owner.id, memberWithAccess.id], ); @@ -151,17 +155,19 @@ describe('CollaborationService', () => { // Assert expect(sendToUsersSpy).toHaveBeenCalledWith( - 'collaboratorsChanged', { - collaborators: expect.arrayContaining([ - expect.objectContaining({ - lastSeen: expect.any(String), - user: expect.objectContaining({ - id: memberWithAccess.id, + type: 'collaboratorsChanged', + data: { + collaborators: expect.arrayContaining([ + expect.objectContaining({ + lastSeen: expect.any(String), + user: expect.objectContaining({ + id: memberWithAccess.id, + }), }), - }), - ]), - workflowId: workflow.id, + ]), + workflowId: workflow.id, + }, }, [memberWithAccess.id], );