foreman_acd 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +75 -0
  3. data/app/controllers/foreman_acd/app_instances_controller.rb +19 -2
  4. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  5. data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
  6. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
  7. data/app/lib/actions/foreman_acd/run_configurator.rb +10 -7
  8. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +2 -2
  9. data/app/models/foreman_acd/acd_provider.rb +7 -1
  10. data/app/models/foreman_acd/ansible_playbook.rb +2 -1
  11. data/app/models/foreman_acd/app_instance.rb +1 -1
  12. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  13. data/app/services/foreman_acd/app_configurator.rb +59 -15
  14. data/app/services/foreman_acd/app_deployer.rb +8 -2
  15. data/app/services/foreman_acd/inventory_creator.rb +14 -0
  16. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
  17. data/app/views/foreman_acd/app_definitions/_form.html.erb +1 -1
  18. data/app/views/foreman_acd/app_instances/_form.html.erb +1 -1
  19. data/app/views/foreman_acd/app_instances/index.html.erb +5 -3
  20. data/app/views/foreman_acd/app_instances/report.html.erb +1 -1
  21. data/app/views/templates/job/run_acd_ansible_playbook.erb +1 -1
  22. data/config/routes.rb +3 -0
  23. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  24. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  25. data/db/seeds.d/75-job_templates.rb +1 -1
  26. data/lib/foreman_acd.rb +12 -0
  27. data/lib/foreman_acd/engine.rb +26 -4
  28. data/lib/foreman_acd/plugin.rb +0 -9
  29. data/lib/foreman_acd/version.rb +1 -1
  30. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  31. data/package.json +8 -8
  32. data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
  33. data/test/controllers/app_instances_controller_test.rb +8 -3
  34. data/test/controllers/ui_acd_controller_test.rb +22 -6
  35. data/test/factories/foreman_acd_factories.rb +18 -4
  36. data/test/models/acd_provider_test.rb +37 -0
  37. data/test/models/ansible_playbook_test.rb +11 -0
  38. data/test/models/app_definition_test.rb +1 -1
  39. data/test/models/app_instance_test.rb +2 -0
  40. data/test/models/concerns/host_extensions_test.rb +26 -0
  41. data/test/models/foreman_host_test.rb +12 -0
  42. data/webpack/__mocks__/foremanReact/API.js +2 -0
  43. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  44. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  45. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  46. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  47. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  48. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  49. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  50. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +1 -1
  51. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  52. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  53. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
  54. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  55. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  56. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
  57. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  58. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  59. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +1 -0
  60. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  61. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  62. data/webpack/components/ApplicationInstance/ApplicationInstance.js +3 -5
  63. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  64. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
  65. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
  66. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
  67. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  68. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
  69. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
  70. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  71. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  72. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  73. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  74. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  75. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  76. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
  77. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  78. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  79. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  80. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  81. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +2 -21
  82. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  83. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  84. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  85. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
  86. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  87. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
  88. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
  89. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  90. data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
  91. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  92. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
  93. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
  94. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  95. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  96. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  97. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  98. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  99. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  100. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  101. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
  102. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  103. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  104. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  105. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
  106. data/webpack/components/SyncGitRepo/index.js +28 -0
  107. data/webpack/components/common/ExtTextInput.js +43 -0
  108. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  109. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  110. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
  111. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  112. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  113. data/webpack/helper.js +15 -1
  114. data/webpack/helper.test.js +37 -0
  115. data/webpack/index.js +2 -0
  116. data/webpack/reducer.js +4 -0
  117. metadata +92 -11
  118. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  119. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  120. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -15,10 +15,10 @@ import ParameterSelection from '../ParameterSelection';
15
15
  import AddTableEntry from '../common/AddTableEntry';
16
16
  import DeleteTableEntry from '../common/DeleteTableEntry';
17
17
  import RailsData from '../common/RailsData';
18
- import EasyHeaderFormatter from '../common/EasyHeaderFormatter';
19
18
  import AppDefinitionSelector from './components/AppDefinitionSelector';
20
19
  import ServiceCounter from './components/ServiceCounter';
21
20
  import { arrayToObject } from '../../helper';
21
+ import { EasyHeaderFormatter } from '../../helper';
22
22
 
23
23
  import {
24
24
  Table,
@@ -63,8 +63,6 @@ class ApplicationInstance extends React.Component {
63
63
  const invalidMinServices = this.props.services.filter(s => (Number(s.minCount) != 0) && (s.currentCount < s.minCount));
64
64
  const invalidMaxServices = this.props.services.filter(s => (Number(s.maxCount) != 0) && (s.currentCount > s.maxCount));
65
65
 
66
- console.log(invalidMinServices);
67
-
68
66
  if (invalidMinServices.length > 0 || invalidMaxServices.length > 0) {
69
67
  result = false;
70
68
 
@@ -217,8 +215,8 @@ class ApplicationInstance extends React.Component {
217
215
  prettyValue = serviceList[value];
218
216
  return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
219
217
  }
220
- if (additionalData.property == 'hostname') {
221
- if (additionalData.rowData.newEntry === true) {
218
+ if (additionalData.property == 'hostname') {
219
+ if (additionalData.rowData.newEntry === true) {
222
220
  return inlineEditFormatterImpl.renderEditText(value, additionalData);
223
221
  }
224
222
  return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
@@ -0,0 +1,263 @@
1
+ export const applicationInstanceConfData_1 = {
2
+ name: false,
3
+ error: {
4
+ errorMsg: '',
5
+ status: '',
6
+ statusText: ''
7
+ },
8
+ loading: false,
9
+ columns: [
10
+ {
11
+ property: 'hostname',
12
+ header: {
13
+ label: 'Hostname',
14
+ formatters: [
15
+ null
16
+ ],
17
+ props: {
18
+ index: 0,
19
+ style: {
20
+ width: '30%'
21
+ }
22
+ }
23
+ },
24
+ cell: {
25
+ formatters: [
26
+ null
27
+ ]
28
+ }
29
+ },
30
+ {
31
+ property: 'description',
32
+ header: {
33
+ label: 'Description',
34
+ formatters: [
35
+ null
36
+ ],
37
+ props: {
38
+ index: 1,
39
+ style: {
40
+ width: '30%'
41
+ }
42
+ }
43
+ },
44
+ cell: {
45
+ formatters: [
46
+ null
47
+ ]
48
+ }
49
+ },
50
+ {
51
+ property: 'service',
52
+ header: {
53
+ label: 'Service',
54
+ formatters: [
55
+ null
56
+ ],
57
+ props: {
58
+ index: 2,
59
+ style: {
60
+ width: '20%'
61
+ }
62
+ }
63
+ },
64
+ cell: {
65
+ formatters: [
66
+ null
67
+ ]
68
+ }
69
+ },
70
+ {
71
+ property: 'actions',
72
+ header: {
73
+ label: 'Actions',
74
+ formatters: [
75
+ null
76
+ ],
77
+ props: {
78
+ index: 4,
79
+ style: {
80
+ width: '20%'
81
+ }
82
+ }
83
+ },
84
+ cell: {
85
+ formatters: [
86
+ null
87
+ ]
88
+ }
89
+ }
90
+ ],
91
+ appDefinition: {
92
+ id: 1,
93
+ name: 'LAMP',
94
+ description: '',
95
+ services: '[{"id":1,"name":"web","description":"","hostgroup":"1","ansibleGroup":"webservers","minCount":"2","maxCount":"","foremanParameters":[{"id":1,"locked":false,"name":"CP","description":"","type":"computeprofile","value":"1"},{"id":2,"locked":true,"name":"LE","description":"","type":"lifecycleenv","value":"1"}],"ansibleParameters":[{"id":0,"name":"dummy_var","value":"0"}]},{"id":2,"name":"db","description":"","hostgroup":"1","ansibleGroup":"dbservers","minCount":"1","maxCount":"","foremanParameters":[],"ansibleParameters":[{"id":0,"name":"mysqlservice","value":"mysqld"},{"id":1,"name":"mysql_port","value":"3306","locked":true},{"id":2,"name":"dbuser","value":"webapp"},{"id":3,"name":"dbname","value":"ANSAP01"},{"id":4,"name":"upassword","value":"Bond@007"},{"id":5,"name":"masterpassword","value":"MySQL@007"}]}]',
96
+ ansible_vars_all: '[{"id":0,"name":"repository","value":"https://github.com/bennojoy/mywebapp.git"}]',
97
+ location_ids: [
98
+ 2
99
+ ],
100
+ organization_ids: [
101
+ 1
102
+ ],
103
+ created_at: '2021-03-11 12:51:34 +0100',
104
+ updated_at: '2021-03-13 00:06:12 +0100'
105
+ },
106
+ hosts: [
107
+ {
108
+ id: 4,
109
+ hostname: 'great-web-app-db-1',
110
+ service: '2',
111
+ description: '',
112
+ foremanParameters: [],
113
+ ansibleParameters: [
114
+ {
115
+ id: 0,
116
+ name: 'mysqlservice',
117
+ value: 'mysqld'
118
+ },
119
+ {
120
+ id: 1,
121
+ name: 'mysql_port',
122
+ value: '3306'
123
+ },
124
+ {
125
+ id: 2,
126
+ name: 'dbuser',
127
+ value: 'webapp'
128
+ },
129
+ {
130
+ id: 3,
131
+ name: 'dbname',
132
+ value: 'ANSAP01'
133
+ },
134
+ {
135
+ id: 4,
136
+ name: 'upassword',
137
+ value: 'Bond@007'
138
+ },
139
+ {
140
+ id: 5,
141
+ name: 'masterpassword',
142
+ value: 'MySQL@007'
143
+ }
144
+ ]
145
+ },
146
+ {
147
+ id: 1,
148
+ hostname: 'great-web-app-web-1',
149
+ service: '1',
150
+ description: '',
151
+ foremanParameters: [],
152
+ ansibleParameters: [
153
+ {
154
+ id: 0,
155
+ name: 'dummy_var',
156
+ value: '0'
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ id: 2,
162
+ hostname: 'great-web-app-web-2',
163
+ service: '1',
164
+ description: '',
165
+ foremanParameters: [],
166
+ ansibleParameters: [
167
+ {
168
+ id: 0,
169
+ name: 'dummy_var',
170
+ value: '0'
171
+ }
172
+ ]
173
+ }
174
+ ],
175
+ ansibleVarsAll: [
176
+ {
177
+ id: 0,
178
+ name: 'repository',
179
+ value: 'https://github.com/bennojoy/mywebapp.git'
180
+ }
181
+ ],
182
+ services: [
183
+ {
184
+ id: 1,
185
+ name: 'web',
186
+ description: '',
187
+ hostgroup: '1',
188
+ ansibleGroup: 'webservers',
189
+ minCount: '2',
190
+ maxCount: '',
191
+ foremanParameters: [
192
+ {
193
+ id: 1,
194
+ locked: false,
195
+ name: 'CP',
196
+ description: '',
197
+ type: 'computeprofile',
198
+ value: '1'
199
+ },
200
+ {
201
+ id: 2,
202
+ locked: true,
203
+ name: 'LE',
204
+ description: '',
205
+ type: 'lifecycleenv',
206
+ value: '1'
207
+ }
208
+ ],
209
+ ansibleParameters: [
210
+ {
211
+ id: 0,
212
+ name: 'dummy_var',
213
+ value: '0'
214
+ }
215
+ ],
216
+ currentCount: 2
217
+ },
218
+ {
219
+ id: 2,
220
+ name: 'db',
221
+ description: '',
222
+ hostgroup: '1',
223
+ ansibleGroup: 'dbservers',
224
+ minCount: '1',
225
+ maxCount: '',
226
+ foremanParameters: [],
227
+ ansibleParameters: [
228
+ {
229
+ id: 0,
230
+ name: 'mysqlservice',
231
+ value: 'mysqld'
232
+ },
233
+ {
234
+ id: 1,
235
+ name: 'mysql_port',
236
+ value: '3306',
237
+ locked: true
238
+ },
239
+ {
240
+ id: 2,
241
+ name: 'dbuser',
242
+ value: 'webapp'
243
+ },
244
+ {
245
+ id: 3,
246
+ name: 'dbname',
247
+ value: 'ANSAP01'
248
+ },
249
+ {
250
+ id: 4,
251
+ name: 'upassword',
252
+ value: 'Bond@007'
253
+ },
254
+ {
255
+ id: 5,
256
+ name: 'masterpassword',
257
+ value: 'MySQL@007'
258
+ }
259
+ ],
260
+ currentCount: 1
261
+ }
262
+ ]
263
+ }
@@ -0,0 +1,78 @@
1
+ import Immutable from 'seamless-immutable';
2
+ import {
3
+ cloneDeep,
4
+ findIndex,
5
+ findLastIndex,
6
+ } from 'lodash';
7
+
8
+ import {
9
+ applicationInstanceConfData_1,
10
+ } from '../__fixtures__/applicationInstanceConfData_1.fixtures';
11
+
12
+ export const successState = Immutable(applicationInstanceConfData_1);
13
+
14
+ const EDIT_ROW_ID = 2;
15
+
16
+ const editClone = applicationInstanceConfData_1;
17
+ const editIndex = findIndex(editClone.hosts, { id: EDIT_ROW_ID })
18
+ editClone["hosts"][editIndex].backup = cloneDeep(editClone["hosts"][editIndex]);
19
+ export const editState = Immutable(editClone);
20
+
21
+ // Payload Data
22
+ export const initApplicationInstancePayload = applicationInstanceConfData_1;
23
+ export const addHostPayload = { };
24
+ export const deleteHostPayload = {
25
+ rowData: {
26
+ id: EDIT_ROW_ID,
27
+ },
28
+ };
29
+ export const activateEditHostPayload = {
30
+ rowData: {
31
+ id: EDIT_ROW_ID,
32
+ },
33
+ };
34
+ export const confirmEditHostPayload = {
35
+ rowData: {
36
+ id: EDIT_ROW_ID,
37
+ },
38
+ };
39
+ export const cancelEditHostPayload = {
40
+ rowData: {
41
+ id: EDIT_ROW_ID,
42
+ },
43
+ };
44
+ export const changeEditHostPayload = {
45
+ value: "helloworld",
46
+ property: "name",
47
+ rowData: {
48
+ id: EDIT_ROW_ID,
49
+ }
50
+ };
51
+
52
+ export const loadApplicationDefinitionRequestPayload = {
53
+ clearRows: false,
54
+ };
55
+
56
+ export const loadApplicationDefinitionSuccessPayload = {
57
+ app_definition: {
58
+ id: 1,
59
+ name: "LAMP",
60
+ description: "",
61
+ services: "[{\"id\":1,\"name\":\"web\",\"description\":\"\",\"hostgroup\":\"1\",\"ansibleGroup\":\"webservers\",\"minCount\":\"2\",\"maxCount\":\"\",\"foremanParameters\":[{\"id\":1,\"locked\":false,\"name\":\"CP\",\"description\":\"\",\"type\":\"computeprofile\",\"value\":\"1\"},{\"id\":2,\"locked\":true,\"name\":\"LE\",\"description\":\"\",\"type\":\"lifecycleenv\",\"value\":\"1\"}],\"ansibleParameters\":[{\"id\":0,\"name\":\"dummy_var\",\"value\":\"0\"}]},{\"id\":2,\"name\":\"db\",\"description\":\"\",\"hostgroup\":\"1\",\"ansibleGroup\":\"dbservers\",\"minCount\":\"1\",\"maxCount\":\"\",\"foremanParameters\":[],\"ansibleParameters\":[{\"id\":0,\"name\":\"mysqlservice\",\"value\":\"mysqld\"},{\"id\":1,\"name\":\"mysql_port\",\"value\":\"3306\",\"locked\":true},{\"id\":2,\"name\":\"dbuser\",\"value\":\"webapp\"},{\"id\":3,\"name\":\"dbname\",\"value\":\"ANSAP01\"},{\"id\":4,\"name\":\"upassword\",\"value\":\"Bond@007\"},{\"id\":5,\"name\":\"masterpassword\",\"value\":\"MySQL@007\"}]}]",
62
+ "ansible_vars_all": "[{\"id\":0,\"name\":\"repository\",\"value\":\"https://github.com/bennojoy/mywebapp.git\"}]",
63
+ location_ids: [
64
+ 2
65
+ ],
66
+ organization_ids: [
67
+ 1
68
+ ],
69
+ created_at: "2021-03-11 12:51:34 +0100",
70
+ updated_at: "2021-03-13 00:06:12 +0100"
71
+ },
72
+ foreman_data: null,
73
+ ansible_data: null
74
+ };
75
+
76
+ export const loadApplicationDefinitionFailurePayload = {
77
+ error: "Something really bad happend",
78
+ };
@@ -0,0 +1,23 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import ApplicationInstance from '../ApplicationInstance';
4
+
5
+ const noop = () => {};
6
+
7
+ const fixtures = {
8
+ 'should render application instance': {
9
+ data: {
10
+ location: "Default Location",
11
+ organization: "Default Organization",
12
+ appDefinition: {},
13
+ hosts: [],
14
+ ansibleVarsAll: [],
15
+ },
16
+ loadApplicationDefinition: noop,
17
+ initApplicationInstance: noop,
18
+ addApplicationInstanceHost: noop,
19
+ },
20
+ };
21
+
22
+ describe('ApplicationInstance', () =>
23
+ testComponentSnapshotsWithFixtures(ApplicationInstance, fixtures));
@@ -0,0 +1,119 @@
1
+ import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import reducer, { initialState } from '../ApplicationInstanceReducer';
3
+
4
+ import {
5
+ successState,
6
+ editState,
7
+ initApplicationInstancePayload,
8
+ addHostPayload,
9
+ deleteHostPayload,
10
+ activateEditHostPayload,
11
+ confirmEditHostPayload,
12
+ cancelEditHostPayload,
13
+ changeEditHostPayload,
14
+ loadApplicationDefinitionRequestPayload,
15
+ loadApplicationDefinitionSuccessPayload,
16
+ loadApplicationDefinitionFailurePayload,
17
+ } from '../__fixtures__/applicationInstanceReducer.fixtures';
18
+
19
+ import {
20
+ APPLICATION_INSTANCE_INIT,
21
+ APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
22
+ APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
23
+ APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
24
+ APPLICATION_INSTANCE_HOST_DELETE,
25
+ APPLICATION_INSTANCE_HOST_ADD,
26
+ APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
27
+ APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
28
+ APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
29
+ APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
30
+ APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
31
+ APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
32
+ APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
33
+ APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
34
+ APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
35
+ } from '../ApplicationInstanceConstants';
36
+
37
+ const fixtures = {
38
+ 'should return initial state': {
39
+ state: initialState,
40
+ action: {
41
+ type: undefined,
42
+ payload: {},
43
+ },
44
+ },
45
+
46
+ 'should initialize component': {
47
+ state: initialState,
48
+ action: {
49
+ type: APPLICATION_INSTANCE_INIT,
50
+ payload: initApplicationInstancePayload,
51
+ },
52
+ },
53
+ 'should add a host': {
54
+ state: successState,
55
+ action: {
56
+ type: APPLICATION_INSTANCE_HOST_ADD,
57
+ payload: addHostPayload,
58
+ },
59
+ },
60
+ 'should delete a host': {
61
+ state: successState,
62
+ action: {
63
+ type: APPLICATION_INSTANCE_HOST_DELETE,
64
+ payload: deleteHostPayload,
65
+ },
66
+ },
67
+ 'should activate edit host': {
68
+ state: successState,
69
+ action: {
70
+ type: APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
71
+ payload: activateEditHostPayload,
72
+ },
73
+ },
74
+ 'should change edit host': {
75
+ state: editState,
76
+ action: {
77
+ type: APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
78
+ payload: changeEditHostPayload,
79
+ },
80
+ },
81
+ 'should confirm edit host': {
82
+ state: editState,
83
+ action: {
84
+ type: APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
85
+ payload: confirmEditHostPayload,
86
+ },
87
+ },
88
+ 'should cancel edit host': {
89
+ state: editState,
90
+ action: {
91
+ type: APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
92
+ payload: cancelEditHostPayload,
93
+ },
94
+ },
95
+ 'should request load param data': {
96
+ state: successState,
97
+ action: {
98
+ type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
99
+ payload: loadApplicationDefinitionRequestPayload,
100
+ },
101
+ },
102
+ 'should load param data be successful': {
103
+ state: successState,
104
+ action: {
105
+ type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
106
+ payload: loadApplicationDefinitionSuccessPayload,
107
+ },
108
+ },
109
+ 'should load param data be erroneous': {
110
+ state: successState,
111
+ action: {
112
+ type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
113
+ payload: loadApplicationDefinitionFailurePayload,
114
+ },
115
+ },
116
+ };
117
+
118
+ describe('ApplicationInstanceReducer', () =>
119
+ testReducerSnapshotWithFixtures(reducer, fixtures));