From 8e070114d6fcbf2df78fe4f239c8918c95464a09 Mon Sep 17 00:00:00 2001 From: Markus Bucher Date: Thu, 18 Apr 2024 18:04:01 +0000 Subject: [PATCH 01/21] Add render tests --- .../ApplicationDefinitionImport.test.js | 46 +++- .../ApplicationDefinitionImport.test.js.snap | 118 ++++++++++ .../ParameterSelectionActions.js | 2 +- .../parameterSelectionData_1.fixtures.js | 15 +- .../__tests__/ParameterSelection.test.js | 79 ++++--- .../ParameterSelection.test.js.snap | 100 +++++++++ .../ParameterSelectionReducer.test.js.snap | 210 ++++++++---------- .../ParameterSelectionSelectors.test.js.snap | 15 +- .../SyncGitRepo/__tests__/SyncGitRepo.test.js | 86 ++++++- .../__snapshots__/SyncGitRepo.test.js.snap | 184 ++++++++++++++- 10 files changed, 675 insertions(+), 180 deletions(-) diff --git a/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js b/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js index dd97e64b..f3af90c2 100644 --- a/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +++ b/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js @@ -4,15 +4,45 @@ import ApplicationDefinitionImport from '../ApplicationDefinitionImport'; const noop = () => {}; +const baseFixtures = { + location: 'Default Location', + organization: 'Default Organization', + hostgroups: { '1': 'alma8' }, + ansiblePlaybookServices: [], + initApplicationDefinitionImport: noop, + addApplicationDefinitionImportService: noop, + closeAlertModal: noop, + changeEditApplicationDefinitionImportService: noop, + handleImportAnsiblePlaybook: noop, +}; + const fixtures = { - 'should render application definition import': { - location: "Default Location", - organization: "Default Organization", - hostgroups: [], - ansiblePlaybookServices: [], - initApplicationDefinitionImport: noop, - addApplicationDefinitionImportService: noop, - closeAlertModal: noop, + 'should render application definition import': baseFixtures, + + 'should render application definition import with loaded archive': { + ...baseFixtures, + ansiblePlaybookServices: [ + { + id: 1, + name: 'Service1', + hostgroup: '', + backup: { + id: 1, + name: 'Service1', + hostgroup: '', + }, + }, + { + id: 2, + name: 'Service2', + hostgroup: '', + backup: { + id: 2, + name: 'Service2', + hostgroup: '', + }, + }, + ], }, }; diff --git a/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap b/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap index 2925a9d5..6455725c 100644 --- a/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +++ b/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap @@ -60,3 +60,121 @@ exports[`ApplicationDefinitionImport should render application definition import /> `; + +exports[`ApplicationDefinitionImport should render application definition import with loaded archive 1`] = ` + + + + + } + onHide={[Function]} + primaryAction={[Function]} + primaryActionButtonBsStyle="danger" + primaryActionButtonContent="OK" + primaryContent="" + secondaryAction={[Function]} + secondaryActionButtonBsStyle="default" + secondaryActionButtonContent={null} + secondaryContent={null} + show={false} + title="" + /> +
+ + + + + + +
+
+ +
+ + +
+ +
+`; diff --git a/webpack/components/ParameterSelection/ParameterSelectionActions.js b/webpack/components/ParameterSelection/ParameterSelectionActions.js index e7566bf6..2ff5e9ff 100644 --- a/webpack/components/ParameterSelection/ParameterSelectionActions.js +++ b/webpack/components/ParameterSelection/ParameterSelectionActions.js @@ -180,7 +180,7 @@ export const initParameterSelection = ( }, idx++); initialState.parameters = parameters; - initialState.allowedParameterTypes = []; + initialState.allowedParameterTypes = {}; if ((paramType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) && (parameters)) { let pTypes = PARAMETER_SELECTION_TYPES; diff --git a/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js b/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js index d9b08c2d..d789b9dd 100644 --- a/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +++ b/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js @@ -215,14 +215,13 @@ export const parameterSelectionData_1 = { value: '1' } ], - allowedParameterTypes: [ - 'domain', - 'hostparam', - 'ip', - 'ptable', - 'puppetenv', - 'password', - ], + allowedParameterTypes: { + domain: 'Domain', + hostparam: 'Host parameter', + ip: 'IP', + ptable: 'Partition table', + puppetenv: 'Puppet environment', + }, parameterTypes: { domain: 'Domain', hostparam: 'Host parameter', diff --git a/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js b/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js index 5d96d471..72151472 100644 --- a/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +++ b/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js @@ -9,49 +9,56 @@ import { const noop = () => {}; +const baseFixtures = { + loading: true, + location: 'Default Location', + organization: 'Default Organization', + editMode: false, + editModeCallback: noop, + paramDataUrl: '/acd/ui_acd_fdata/__id__', + paramType: undefined, + data: {}, + addParameter: noop, + confirmEditParametre: noop, + cancelEditParameter: noop, + loadParamData: noop, + initParameterSelection: noop, +}; + const fixtures = { + 'should render loading': baseFixtures, + 'should render foreman parameter selection': { - location: "Default Location", - organization: "Default Organization", - editModeCallback: noop, - paramDataUrl: "/acd/ui_acd_fdata/__id__", - paramType: PARAMETER_SELECTION_PARAM_TYPE_FOREMAN, - data: { - type: PARAMETER_SELECTION_PARAM_TYPE_FOREMAN, - parameters: [], - useDefaultValue: true, - allowRowAdjustment: true, - allowNameAdjustment: true, - allowDescriptionAdjustment: true, + ...baseFixtures, + ...{ + loading: false, + paramType: PARAMETER_SELECTION_PARAM_TYPE_FOREMAN, + data: { + type: PARAMETER_SELECTION_PARAM_TYPE_FOREMAN, + parameters: [], + useDefaultValue: true, + allowRowAdjustment: true, + allowNameAdjustment: true, + allowDescriptionAdjustment: true, + }, }, - addParameter: noop, - confirmEditParametre: noop, - cancelEditParameter: noop, - editModeCallback: noop, - loadParamData: noop, - initParameterSelection: noop, }, 'should render ansible parameter selection': { - location: "Default Location", - organization: "Default Organization", - editModeCallback: noop, - paramType: PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE, - data: { - type: PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE, - parameters: [], - useDefaultValue: false, - allowRowAdjustment: true, - allowNameAdjustment: true, - allowDescriptionAdjustment: true, + ...baseFixtures, + ...{ + loading: false, + paramType: PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE, + data: { + type: PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE, + parameters: [], + useDefaultValue: false, + allowRowAdjustment: true, + allowNameAdjustment: true, + allowDescriptionAdjustment: true, + }, }, - addParameter: noop, - confirmEditParametre: noop, - cancelEditParameter: noop, - editModeCallback: noop, - loadParamData: noop, - initParameterSelection: noop, - } + }, }; describe('ParameterSelection', () => diff --git a/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap b/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap index 93eac221..d90a8c4c 100644 --- a/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +++ b/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap @@ -199,3 +199,103 @@ exports[`ParameterSelection should render foreman parameter selection 1`] = ` `; + +exports[`ParameterSelection should render loading 1`] = ` +
+
+
+ +
+ + +
+
+
+ +
+