Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Jan 2, 2025
1 parent 4e9f2b3 commit 432ebd9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
49 changes: 49 additions & 0 deletions packages/editor-ui/src/composables/useRunWorkflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,55 @@ describe('useRunWorkflow({ router })', () => {
type: 'error',
});
});
it('should execute workflow has pin data and is active with single webhook trigger', async () => {
const pinia = createTestingPinia({ stubActions: false });
setActivePinia(pinia);
const toast = useToast();
const i18n = useI18n();
const { runWorkflow } = useRunWorkflow({ router });

vi.mocked(workflowsStore).isWorkflowActive = true;

vi.mocked(useWorkflowHelpers({ router })).getWorkflowDataToSave.mockResolvedValue({
nodes: [
{
name: 'Slack',
type: 'n8n-nodes-base.slackTrigger',
disabled: false,
},
],
pinData: {
Slack: [{ json: { value: 'data2' } }],
},
} as unknown as IWorkflowData);

const mockExecutionResponse = { executionId: '123' };

vi.mocked(uiStore).activeActions = [''];
vi.mocked(workflowHelpers).getCurrentWorkflow.mockReturnValue({
name: 'Test Workflow',
} as unknown as Workflow);
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockExecutionResponse);
vi.mocked(workflowsStore).nodesIssuesExist = true;
vi.mocked(workflowHelpers).getWorkflowDataToSave.mockResolvedValue({
id: 'workflowId',
nodes: [],
} as unknown as IWorkflowData);
vi.mocked(workflowsStore).getWorkflowRunData = {
NodeName: [],
};

const result = await runWorkflow({});
expect(result).toEqual(mockExecutionResponse);

expect(toast.showMessage).not.toHaveBeenCalledWith({
title: i18n.baseText('workflowRun.showError.deactivate'),
message: i18n.baseText('workflowRun.showError.productionActive', {
interpolate: { nodeName: 'Webhook' },
}),
type: 'error',
});
});
});

describe('runWorkflow()', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/editor-ui/src/composables/useRunWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
SINGLE_WEBHOOK_TRIGGERS.includes(node.type),
);

if (singleWebhookTrigger && workflowsStore.isWorkflowActive) {
if (
singleWebhookTrigger &&
workflowsStore.isWorkflowActive &&
!workflowData.pinData?.[singleWebhookTrigger.name]
) {
toast.showMessage({
title: i18n.baseText('workflowRun.showError.deactivate'),
message: i18n.baseText('workflowRun.showError.productionActive', {
Expand Down

0 comments on commit 432ebd9

Please sign in to comment.