Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Dec 20, 2024
1 parent 63384be commit 0cab6f9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 41 deletions.
38 changes: 28 additions & 10 deletions packages/cli/src/scaling/__tests__/pubsub-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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,
},
});
});

Expand Down Expand Up @@ -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,
},
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down Expand Up @@ -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],
);
Expand Down

0 comments on commit 0cab6f9

Please sign in to comment.