Skip to content

Commit 8053a4a

Browse files
fix: Run workflow if active and single webhook service has pin data (#12425)
1 parent 452a7bf commit 8053a4a

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

packages/editor-ui/src/composables/useRunWorkflow.test.ts

+49
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,55 @@ describe('useRunWorkflow({ router })', () => {
219219
type: 'error',
220220
});
221221
});
222+
it('should execute workflow has pin data and is active with single webhook trigger', async () => {
223+
const pinia = createTestingPinia({ stubActions: false });
224+
setActivePinia(pinia);
225+
const toast = useToast();
226+
const i18n = useI18n();
227+
const { runWorkflow } = useRunWorkflow({ router });
228+
229+
vi.mocked(workflowsStore).isWorkflowActive = true;
230+
231+
vi.mocked(useWorkflowHelpers({ router })).getWorkflowDataToSave.mockResolvedValue({
232+
nodes: [
233+
{
234+
name: 'Slack',
235+
type: 'n8n-nodes-base.slackTrigger',
236+
disabled: false,
237+
},
238+
],
239+
pinData: {
240+
Slack: [{ json: { value: 'data2' } }],
241+
},
242+
} as unknown as IWorkflowData);
243+
244+
const mockExecutionResponse = { executionId: '123' };
245+
246+
vi.mocked(uiStore).activeActions = [''];
247+
vi.mocked(workflowHelpers).getCurrentWorkflow.mockReturnValue({
248+
name: 'Test Workflow',
249+
} as unknown as Workflow);
250+
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockExecutionResponse);
251+
vi.mocked(workflowsStore).nodesIssuesExist = true;
252+
vi.mocked(workflowHelpers).getWorkflowDataToSave.mockResolvedValue({
253+
id: 'workflowId',
254+
nodes: [],
255+
} as unknown as IWorkflowData);
256+
vi.mocked(workflowsStore).getWorkflowRunData = {
257+
NodeName: [],
258+
};
259+
260+
const result = await runWorkflow({});
261+
expect(result).toEqual(mockExecutionResponse);
262+
263+
expect(toast.showMessage).not.toHaveBeenCalledWith({
264+
title: i18n.baseText('workflowRun.showError.deactivate'),
265+
message: i18n.baseText('workflowRun.showError.productionActive', {
266+
interpolate: { nodeName: 'Webhook' },
267+
}),
268+
type: 'error',
269+
});
270+
});
222271
});
223272

224273
describe('runWorkflow()', () => {

packages/editor-ui/src/composables/useRunWorkflow.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
240240
SINGLE_WEBHOOK_TRIGGERS.includes(node.type),
241241
);
242242

243-
if (singleWebhookTrigger && workflowsStore.isWorkflowActive) {
243+
if (
244+
singleWebhookTrigger &&
245+
workflowsStore.isWorkflowActive &&
246+
!workflowData.pinData?.[singleWebhookTrigger.name]
247+
) {
244248
toast.showMessage({
245249
title: i18n.baseText('workflowRun.showError.deactivate'),
246250
message: i18n.baseText('workflowRun.showError.productionActive', {

0 commit comments

Comments
 (0)