fix: Run workflow if active and single webhook service has pin data (#12425)

This commit is contained in:
Michael Kret 2025-01-06 11:11:36 +02:00 committed by GitHub
parent 452a7bfe2c
commit 8053a4a176
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 1 deletions

View file

@ -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()', () => {

View file

@ -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', {