mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Prevent running workflow that has issues if listening to webhook (#11402)
This commit is contained in:
@@ -23,6 +23,7 @@ vi.mock('@/stores/workflows.store', () => ({
|
|||||||
getCurrentWorkflow: vi.fn().mockReturnValue({ id: '123' }),
|
getCurrentWorkflow: vi.fn().mockReturnValue({ id: '123' }),
|
||||||
getNodeByName: vi.fn(),
|
getNodeByName: vi.fn(),
|
||||||
getExecution: vi.fn(),
|
getExecution: vi.fn(),
|
||||||
|
nodeIssuesExit: vi.fn(),
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -124,6 +125,21 @@ describe('useRunWorkflow({ router })', () => {
|
|||||||
expect(uiStore.addActiveAction).toHaveBeenCalledWith('workflowRunning');
|
expect(uiStore.addActiveAction).toHaveBeenCalledWith('workflowRunning');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should prevent running a webhook-based workflow that has issues', async () => {
|
||||||
|
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||||
|
vi.mocked(workflowsStore).nodesIssuesExist = true;
|
||||||
|
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue({
|
||||||
|
executionId: '123',
|
||||||
|
waitingForWebhook: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(runWorkflowApi({} as IStartRunData)).rejects.toThrow(
|
||||||
|
'workflowRun.showError.resolveOutstandingIssues',
|
||||||
|
);
|
||||||
|
|
||||||
|
vi.mocked(workflowsStore).nodesIssuesExist = false;
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle workflow run failure', async () => {
|
it('should handle workflow run failure', async () => {
|
||||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
|||||||
workflowsStore.activeExecutionId = response.executionId;
|
workflowsStore.activeExecutionId = response.executionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.waitingForWebhook === true && useWorkflowsStore().nodesIssuesExist) {
|
||||||
|
uiStore.removeActiveAction('workflowRunning');
|
||||||
|
throw new Error(i18n.baseText('workflowRun.showError.resolveOutstandingIssues'));
|
||||||
|
}
|
||||||
|
|
||||||
if (response.waitingForWebhook === true) {
|
if (response.waitingForWebhook === true) {
|
||||||
workflowsStore.executionWaitingForWebhook = true;
|
workflowsStore.executionWaitingForWebhook = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2130,6 +2130,7 @@
|
|||||||
"workflowRun.noActiveConnectionToTheServer": "Lost connection to the server",
|
"workflowRun.noActiveConnectionToTheServer": "Lost connection to the server",
|
||||||
"workflowRun.showError.title": "Problem running workflow",
|
"workflowRun.showError.title": "Problem running workflow",
|
||||||
"workflowRun.showError.payloadTooLarge": "Please execute the whole workflow, rather than just the node. (Existing execution data is too large.)",
|
"workflowRun.showError.payloadTooLarge": "Please execute the whole workflow, rather than just the node. (Existing execution data is too large.)",
|
||||||
|
"workflowRun.showError.resolveOutstandingIssues": "Please resolve outstanding issues before you activate it",
|
||||||
"workflowRun.showMessage.message": "Please fix them before executing",
|
"workflowRun.showMessage.message": "Please fix them before executing",
|
||||||
"workflowRun.showMessage.title": "Workflow has issues",
|
"workflowRun.showMessage.title": "Workflow has issues",
|
||||||
"workflowSettings.callerIds": "IDs of workflows that can call this one",
|
"workflowSettings.callerIds": "IDs of workflows that can call this one",
|
||||||
|
|||||||
Reference in New Issue
Block a user