mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Fix push message type inference (#12331)
This commit is contained in:
@@ -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,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -806,15 +821,21 @@ describe('PubSubHandler', () => {
|
||||
|
||||
const pushRef = 'test-push-ref';
|
||||
const type = 'executionStarted';
|
||||
const args = { testArg: 'value' };
|
||||
const data = {
|
||||
executionId: '123',
|
||||
mode: 'webhook' as const,
|
||||
startedAt: new Date(),
|
||||
workflowId: '456',
|
||||
flattedRunData: '[]',
|
||||
};
|
||||
|
||||
push.getBackend.mockReturnValue(
|
||||
mock<WebSocketPush>({ hasPushRef: jest.fn().mockReturnValue(true) }),
|
||||
);
|
||||
|
||||
eventService.emit('relay-execution-lifecycle-event', { type, args, pushRef });
|
||||
eventService.emit('relay-execution-lifecycle-event', { type, data, pushRef });
|
||||
|
||||
expect(push.send).toHaveBeenCalledWith(type, args, pushRef);
|
||||
expect(push.send).toHaveBeenCalledWith({ type, data }, pushRef);
|
||||
});
|
||||
|
||||
it('should handle `clear-test-webhooks` event', () => {
|
||||
@@ -868,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,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user