feat(core): Implement inter-main communication for test webhooks in multi-main setup (#8267)
This commit is contained in:
@@ -90,22 +90,30 @@ describe('update()', () => {
|
||||
const owner = await createOwner();
|
||||
const workflow = await createWorkflow({ active: true }, owner);
|
||||
|
||||
const broadcastSpy = jest.spyOn(multiMainSetup, 'broadcastWorkflowActiveStateChanged');
|
||||
const publishSpy = jest.spyOn(multiMainSetup, 'publish');
|
||||
|
||||
workflow.active = false;
|
||||
await workflowService.update(owner, workflow, workflow.id);
|
||||
|
||||
expect(broadcastSpy).toHaveBeenCalledTimes(1);
|
||||
expect(publishSpy).toHaveBeenCalledTimes(1);
|
||||
expect(publishSpy).toHaveBeenCalledWith(
|
||||
'workflowActiveStateChanged',
|
||||
expect.objectContaining({
|
||||
newState: false,
|
||||
oldState: true,
|
||||
workflowId: workflow.id,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('should not broadcast active workflow state change if state did not change', async () => {
|
||||
const owner = await createOwner();
|
||||
const workflow = await createWorkflow({ active: true }, owner);
|
||||
|
||||
const broadcastSpy = jest.spyOn(multiMainSetup, 'broadcastWorkflowActiveStateChanged');
|
||||
const publishSpy = jest.spyOn(multiMainSetup, 'publish');
|
||||
|
||||
await workflowService.update(owner, workflow, workflow.id);
|
||||
|
||||
expect(broadcastSpy).not.toHaveBeenCalled();
|
||||
expect(publishSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ let testWebhooks: TestWebhooks;
|
||||
|
||||
describe('TestWebhooks', () => {
|
||||
beforeAll(() => {
|
||||
testWebhooks = new TestWebhooks(mock(), mock(), registrations);
|
||||
testWebhooks = new TestWebhooks(mock(), mock(), registrations, mock());
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('WebSocketPush', () => {
|
||||
},
|
||||
};
|
||||
|
||||
webSocketPush.send('executionRecovered', data, sessionId1);
|
||||
webSocketPush.sendToOneSession('executionRecovered', data, sessionId1);
|
||||
|
||||
expect(mockWebSocket1.send).toHaveBeenCalledWith(
|
||||
JSON.stringify({
|
||||
@@ -91,7 +91,7 @@ describe('WebSocketPush', () => {
|
||||
},
|
||||
};
|
||||
|
||||
webSocketPush.broadcast('executionRecovered', data);
|
||||
webSocketPush.sendToAllSessions('executionRecovered', data);
|
||||
|
||||
const expectedMsg = JSON.stringify({
|
||||
type: 'executionRecovered',
|
||||
|
||||
Reference in New Issue
Block a user