mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Include execution progress in save settings (no-changelog) (#7769)
This commit is contained in:
154
packages/cli/test/unit/execution-lifecyle/toSaveSettings.test.ts
Normal file
154
packages/cli/test/unit/execution-lifecyle/toSaveSettings.test.ts
Normal file
@@ -0,0 +1,154 @@
|
||||
import config from '@/config';
|
||||
import { toSaveSettings } from '@/executionLifecycleHooks/toSaveSettings';
|
||||
|
||||
afterEach(() => {
|
||||
config.load(config.default);
|
||||
});
|
||||
|
||||
describe('failed production executions', () => {
|
||||
it('should favor workflow settings over defaults', () => {
|
||||
config.set('executions.saveDataOnError', 'none');
|
||||
|
||||
const saveSettings = toSaveSettings({ saveDataErrorExecution: 'all' });
|
||||
|
||||
expect(saveSettings.error).toBe(true);
|
||||
|
||||
config.set('executions.saveDataOnError', 'all');
|
||||
|
||||
const _saveSettings = toSaveSettings({ saveDataErrorExecution: 'none' });
|
||||
|
||||
expect(_saveSettings.error).toBe(false);
|
||||
});
|
||||
|
||||
it('should fall back to default if no workflow setting', () => {
|
||||
config.set('executions.saveDataOnError', 'all');
|
||||
|
||||
const saveSettings = toSaveSettings();
|
||||
|
||||
expect(saveSettings.error).toBe(true);
|
||||
|
||||
config.set('executions.saveDataOnError', 'none');
|
||||
|
||||
const _saveSettings = toSaveSettings();
|
||||
|
||||
expect(_saveSettings.error).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sucessful production executions', () => {
|
||||
it('should favor workflow settings over defaults', () => {
|
||||
config.set('executions.saveDataOnSuccess', 'none');
|
||||
|
||||
const saveSettings = toSaveSettings({ saveDataSuccessExecution: 'all' });
|
||||
|
||||
expect(saveSettings.success).toBe(true);
|
||||
|
||||
config.set('executions.saveDataOnSuccess', 'all');
|
||||
|
||||
const _saveSettings = toSaveSettings({ saveDataSuccessExecution: 'none' });
|
||||
|
||||
expect(_saveSettings.success).toBe(false);
|
||||
});
|
||||
|
||||
it('should fall back to default if no workflow setting', () => {
|
||||
config.set('executions.saveDataOnSuccess', 'all');
|
||||
|
||||
const saveSettings = toSaveSettings();
|
||||
|
||||
expect(saveSettings.success).toBe(true);
|
||||
|
||||
config.set('executions.saveDataOnSuccess', 'none');
|
||||
|
||||
const _saveSettings = toSaveSettings();
|
||||
|
||||
expect(_saveSettings.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('manual executions', () => {
|
||||
it('should favor workflow setting over default', () => {
|
||||
config.set('executions.saveDataManualExecutions', false);
|
||||
|
||||
const saveSettings = toSaveSettings({ saveManualExecutions: true });
|
||||
|
||||
expect(saveSettings.manual).toBe(true);
|
||||
|
||||
config.set('executions.saveDataManualExecutions', true);
|
||||
|
||||
const _saveSettings = toSaveSettings({ saveManualExecutions: false });
|
||||
|
||||
expect(_saveSettings.manual).toBe(false);
|
||||
});
|
||||
|
||||
it('should favor fall back to default if workflow setting is explicit default', () => {
|
||||
config.set('executions.saveDataManualExecutions', true);
|
||||
|
||||
const saveSettings = toSaveSettings({ saveManualExecutions: 'DEFAULT' });
|
||||
|
||||
expect(saveSettings.manual).toBe(true);
|
||||
|
||||
config.set('executions.saveDataManualExecutions', false);
|
||||
|
||||
const _saveSettings = toSaveSettings({ saveManualExecutions: 'DEFAULT' });
|
||||
|
||||
expect(_saveSettings.manual).toBe(false);
|
||||
});
|
||||
|
||||
it('should fall back to default if no workflow setting', () => {
|
||||
config.set('executions.saveDataManualExecutions', true);
|
||||
|
||||
const saveSettings = toSaveSettings();
|
||||
|
||||
expect(saveSettings.manual).toBe(true);
|
||||
|
||||
config.set('executions.saveDataManualExecutions', false);
|
||||
|
||||
const _saveSettings = toSaveSettings();
|
||||
|
||||
expect(_saveSettings.manual).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('execution progress', () => {
|
||||
it('should favor workflow setting over default', () => {
|
||||
config.set('executions.saveExecutionProgress', false);
|
||||
|
||||
const saveSettings = toSaveSettings({ saveExecutionProgress: true });
|
||||
|
||||
expect(saveSettings.progress).toBe(true);
|
||||
|
||||
config.set('executions.saveExecutionProgress', true);
|
||||
|
||||
const _saveSettings = toSaveSettings({ saveExecutionProgress: false });
|
||||
|
||||
expect(_saveSettings.progress).toBe(false);
|
||||
});
|
||||
|
||||
it('should favor fall back to default if workflow setting is explicit default', () => {
|
||||
config.set('executions.saveExecutionProgress', true);
|
||||
|
||||
const saveSettings = toSaveSettings({ saveExecutionProgress: 'DEFAULT' });
|
||||
|
||||
expect(saveSettings.progress).toBe(true);
|
||||
|
||||
config.set('executions.saveExecutionProgress', false);
|
||||
|
||||
const _saveSettings = toSaveSettings({ saveExecutionProgress: 'DEFAULT' });
|
||||
|
||||
expect(_saveSettings.progress).toBe(false);
|
||||
});
|
||||
|
||||
it('should fall back to default if no workflow setting', () => {
|
||||
config.set('executions.saveExecutionProgress', true);
|
||||
|
||||
const saveSettings = toSaveSettings();
|
||||
|
||||
expect(saveSettings.progress).toBe(true);
|
||||
|
||||
config.set('executions.saveExecutionProgress', false);
|
||||
|
||||
const _saveSettings = toSaveSettings();
|
||||
|
||||
expect(_saveSettings.progress).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user