mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 13:39:44 +02:00
fix(editor): Do not run the workflow when the save before execute fails (#39763)
This commit is contained in:
parent
f9dbd2c8d6
commit
7204df600d
|
|
@ -466,6 +466,22 @@ describe('useRunWorkflow({ router })', () => {
|
|||
await runWorkflow({});
|
||||
|
||||
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
|
||||
expect(workflowsStore.runWorkflow).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not run when the save before execute fails with autosave enabled', async () => {
|
||||
vi.spyOn(settingsStore, 'isAutosaveEnabled', 'get').mockReturnValue(true);
|
||||
vi.mocked(uiStore).stateIsDirty = true;
|
||||
vi.mocked(workflowsStore).isWorkflowSaved = { '123': true };
|
||||
|
||||
const workflowSaving = useWorkflowSaving({ router });
|
||||
vi.mocked(workflowSaving.saveCurrentWorkflow).mockResolvedValueOnce(false);
|
||||
const { runWorkflow } = useRunWorkflow({ router });
|
||||
const result = await runWorkflow({});
|
||||
|
||||
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
|
||||
expect(workflowsStore.runWorkflow).not.toHaveBeenCalled();
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should prompt the user and save when they confirm if autosave is disabled and state is dirty (ADO-5328)', async () => {
|
||||
|
|
@ -515,6 +531,21 @@ describe('useRunWorkflow({ router })', () => {
|
|||
|
||||
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not run a new workflow when its first save fails', async () => {
|
||||
vi.spyOn(settingsStore, 'isAutosaveEnabled', 'get').mockReturnValue(false);
|
||||
vi.mocked(uiStore).stateIsDirty = false;
|
||||
vi.mocked(workflowsStore).isWorkflowSaved = {};
|
||||
|
||||
const workflowSaving = useWorkflowSaving({ router });
|
||||
vi.mocked(workflowSaving.saveCurrentWorkflow).mockResolvedValueOnce(false);
|
||||
const { runWorkflow } = useRunWorkflow({ router });
|
||||
const result = await runWorkflow({});
|
||||
|
||||
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
|
||||
expect(workflowsStore.runWorkflow).not.toHaveBeenCalled();
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('scoped workflow document store (eval-loop reruns)', () => {
|
||||
|
|
|
|||
|
|
@ -175,15 +175,15 @@ export function useRunWorkflow(useRunWorkflowOpts: {
|
|||
if (response !== MODAL_CONFIRM) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNewWorkflow || uiStore.stateIsDirty) {
|
||||
const saved = await workflowSaving.saveCurrentWorkflow({
|
||||
id: workflowDocumentStore.value.workflowId,
|
||||
});
|
||||
if (!saved) {
|
||||
return undefined;
|
||||
}
|
||||
} else if (isNewWorkflow || (uiStore.stateIsDirty && settingsStore.isAutosaveEnabled)) {
|
||||
await workflowSaving.saveCurrentWorkflow({ id: workflowDocumentStore.value.workflowId });
|
||||
}
|
||||
|
||||
const workflowData = workflowDocumentStore.value.serialize();
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ describe('LogsOverviewPanel', () => {
|
|||
|
||||
it('should trigger partial execution if the button is clicked', async () => {
|
||||
const spyRun = vi.spyOn(workflowsStore, 'runWorkflow');
|
||||
workflowsStore.isWorkflowSaved = { 'test-workflow-id': true };
|
||||
|
||||
const logs = createLogTree(
|
||||
createTestWorkflowObject(aiManualWorkflow),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user