fix(editor): Prevent running workflow that has issues if listening to webhook (#11402)

This commit is contained in:
Iván Ovejero 2024-10-25 10:48:41 +02:00 committed by GitHub
parent 7fc3b25d21
commit 8b0a48f530
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View file

@ -23,6 +23,7 @@ vi.mock('@/stores/workflows.store', () => ({
getCurrentWorkflow: vi.fn().mockReturnValue({ id: '123' }),
getNodeByName: vi.fn(),
getExecution: vi.fn(),
nodeIssuesExit: vi.fn(),
}),
}));
@ -124,6 +125,21 @@ describe('useRunWorkflow({ router })', () => {
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 () => {
const { runWorkflowApi } = useRunWorkflow({ router });

View file

@ -81,6 +81,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
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) {
workflowsStore.executionWaitingForWebhook = true;
}

View file

@ -2130,6 +2130,7 @@
"workflowRun.noActiveConnectionToTheServer": "Lost connection to the server",
"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.resolveOutstandingIssues": "Please resolve outstanding issues before you activate it",
"workflowRun.showMessage.message": "Please fix them before executing",
"workflowRun.showMessage.title": "Workflow has issues",
"workflowSettings.callerIds": "IDs of workflows that can call this one",