Skip to content

Commit

Permalink
fix(core): Save exeution progress for waiting executions, even when p…
Browse files Browse the repository at this point in the history
…rogress saving is disabled (#11535)

Co-authored-by: Michael Kret <[email protected]>
  • Loading branch information
netroy and michael-radency authored Nov 4, 2024
1 parent 19a5c2f commit 6b9353c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
deepCopy,
ErrorReporterProxy,
type IRunExecutionData,
type ITaskData,
Expand Down Expand Up @@ -57,7 +58,7 @@ test('should ignore on leftover async call', async () => {
expect(executionRepository.updateExistingExecution).not.toHaveBeenCalled();
});

test('should update execution', async () => {
test('should update execution when saving progress is enabled', async () => {
jest.spyOn(fnModule, 'toSaveSettings').mockReturnValue({
...commonSettings,
progress: true,
Expand Down Expand Up @@ -86,6 +87,37 @@ test('should update execution', async () => {
expect(reporterSpy).not.toHaveBeenCalled();
});

test('should update execution when saving progress is disabled, but waitTill is defined', async () => {
jest.spyOn(fnModule, 'toSaveSettings').mockReturnValue({
...commonSettings,
progress: false,
});

const reporterSpy = jest.spyOn(ErrorReporterProxy, 'error');

executionRepository.findSingleExecution.mockResolvedValue({} as IExecutionResponse);

const args = deepCopy(commonArgs);
args[4].waitTill = new Date();
await saveExecutionProgress(...args);

expect(executionRepository.updateExistingExecution).toHaveBeenCalledWith('some-execution-id', {
data: {
executionData: undefined,
resultData: {
lastNodeExecuted: 'My Node',
runData: {
'My Node': [{}],
},
},
startData: {},
},
status: 'running',
});

expect(reporterSpy).not.toHaveBeenCalled();
});

test('should report error on failure', async () => {
jest.spyOn(fnModule, 'toSaveSettings').mockReturnValue({
...commonSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function saveExecutionProgress(
) {
const saveSettings = toSaveSettings(workflowData.settings);

if (!saveSettings.progress) return;
if (!saveSettings.progress && !executionData.waitTill) return;

const logger = Container.get(Logger);

Expand Down

0 comments on commit 6b9353c

Please sign in to comment.