Skip to content

Commit

Permalink
test(editor): Add workflow settings unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cstuncsik committed Nov 8, 2024
1 parent cf3b392 commit 95a53e9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/editor-ui/src/__tests__/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export const defaultSettings: FrontendSettings = {
},
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
pushBackend: 'websocket',
saveDataErrorExecution: 'DEFAULT',
saveDataSuccessExecution: 'DEFAULT',
saveDataErrorExecution: 'all',
saveDataSuccessExecution: 'all',
saveManualExecutions: false,
saveExecutionProgress: false,
sso: {
Expand Down
46 changes: 46 additions & 0 deletions packages/editor-ui/src/components/WorkflowSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,50 @@ describe('WorkflowSettingsVue', () => {

expect(getByTestId('workflow-caller-policy-workflow-ids')).toHaveValue(cleanedUpWorkflowList);
});

test.each([
['workflow-settings-save-failed-executions', 'Default - Save', () => {}],
[
'workflow-settings-save-failed-executions',
'Default - Do not save',
() => {
settingsStore.saveDataErrorExecution = 'none';
},
],
['workflow-settings-save-success-executions', 'Default - Save', () => {}],
[
'workflow-settings-save-success-executions',
'Default - Do not save',
() => {
settingsStore.saveDataSuccessExecution = 'none';
},
],
[
'workflow-settings-save-manual-executions',
'Default - Save',
() => {
settingsStore.saveManualExecutions = true;
},
],
['workflow-settings-save-manual-executions', 'Default - Do not save', () => {}],
[
'workflow-settings-save-execution-progress',
'Default - Save',
() => {
settingsStore.saveDataProgressExecution = true;
},
],
['workflow-settings-save-execution-progress', 'Default - Do not save', () => {}],
])(
'should show %s dropdown correct default value as %s',
async (testId, optionText, storeSetter) => {
storeSetter();
const { getByTestId } = createComponent({ pinia });
await nextTick();

const dropdownItems = await getDropdownItems(getByTestId(testId));

expect(dropdownItems[0]).toHaveTextContent(optionText);
},
);
});
1 change: 1 addition & 0 deletions packages/editor-ui/src/components/WorkflowSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ onMounted(async () => {
defaultValues.value.saveDataErrorExecution = settingsStore.saveDataErrorExecution;
defaultValues.value.saveDataSuccessExecution = settingsStore.saveDataSuccessExecution;
defaultValues.value.saveManualExecutions = settingsStore.saveManualExecutions;
defaultValues.value.saveExecutionProgress = settingsStore.saveDataProgressExecution;
defaultValues.value.timezone = rootStore.timezone;
defaultValues.value.workflowCallerPolicy = settingsStore.workflowCallerPolicyDefaultOption;
Expand Down

0 comments on commit 95a53e9

Please sign in to comment.