foreman_acd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +87 -0
- data/Rakefile +49 -0
- data/app/assets/javascripts/foreman_acd/acd_dummy.js +3 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +55 -0
- data/app/controllers/foreman_acd/api/v2/base_controller.rb +16 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +53 -0
- data/app/controllers/foreman_acd/app_instances_controller.rb +158 -0
- data/app/controllers/foreman_acd/application_controller.rb +10 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +23 -0
- data/app/controllers/ui_acd_controller.rb +30 -0
- data/app/models/foreman_acd/app_definition.rb +23 -0
- data/app/models/foreman_acd/app_instance.rb +21 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +40 -0
- data/app/views/foreman_acd/app_definitions/edit.html.erb +11 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +27 -0
- data/app/views/foreman_acd/app_definitions/new.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/_form.html.erb +46 -0
- data/app/views/foreman_acd/app_instances/edit.html.erb +11 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +30 -0
- data/app/views/foreman_acd/app_instances/new.html.erb +11 -0
- data/app/views/ui_acd/app.json.rabl +9 -0
- data/app/views/ui_acd/app_definition.json.rabl +5 -0
- data/app/views/ui_acd/computeprofile.json.rabl +4 -0
- data/app/views/ui_acd/domain.json.rabl +4 -0
- data/app/views/ui_acd/environment.json.rabl +4 -0
- data/app/views/ui_acd/fdata.json.rabl +24 -0
- data/app/views/ui_acd/lifecycle_environment.json.rabl +4 -0
- data/app/views/ui_acd/ptable.json.rabl +4 -0
- data/config/routes.rb +24 -0
- data/db/migrate/20190610202252_create_app_definitions.rb +19 -0
- data/db/migrate/20190625140305_create_app_instances.rb +19 -0
- data/lib/foreman_acd/engine.rb +43 -0
- data/lib/foreman_acd/plugin.rb +80 -0
- data/lib/foreman_acd/version.rb +5 -0
- data/lib/foreman_acd.rb +7 -0
- data/lib/tasks/foreman_acd_tasks.rake +47 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_acd.po +19 -0
- data/locale/foreman_acd.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/package.json +121 -0
- data/test/controllers/app_definitions_controller_test.rb +24 -0
- data/test/controllers/app_instances_controller_test.rb +24 -0
- data/test/controllers/ui_acd_controller_test.rb +26 -0
- data/test/factories/foreman_acd_factories.rb +17 -0
- data/test/models/app_definition_test.rb +11 -0
- data/test/models/app_instance_test.rb +8 -0
- data/test/test_plugin_helper.rb +8 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/Select.js +2 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +468 -0
- data/webpack/components/ParameterSelection/ParameterSelection.scss +3 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +294 -0
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +31 -0
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +52 -0
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +175 -0
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +15 -0
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +162 -0
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +194 -0
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +127 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +48 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +150 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +47 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +454 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +2265 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +209 -0
- data/webpack/components/ParameterSelection/index.js +39 -0
- data/webpack/index.js +8 -0
- data/webpack/reducer.js +7 -0
- data/webpack/test_setup.js +11 -0
- metadata +206 -0
@@ -0,0 +1,162 @@
|
|
1
|
+
export const newDefinition = {
|
2
|
+
organization: "Default Organization",
|
3
|
+
location: "Default Location",
|
4
|
+
hostgroups: {
|
5
|
+
"1": "centos7"
|
6
|
+
},
|
7
|
+
loadForemanDataUrl: "/acd/ui_acd_fdata/__id__",
|
8
|
+
mode: "newDefinition"
|
9
|
+
};
|
10
|
+
export const editDefinition = {
|
11
|
+
organization: "Default Organization",
|
12
|
+
location: "Default Location",
|
13
|
+
hostgroups: {
|
14
|
+
"1": "centos7"
|
15
|
+
},
|
16
|
+
loadForemanDataUrl: "/acd/ui_acd_fdata/__id__",
|
17
|
+
mode: "editDefinition",
|
18
|
+
appDefinition: {
|
19
|
+
id: 1,
|
20
|
+
name: "Test123",
|
21
|
+
hostgroup_id: 1
|
22
|
+
},
|
23
|
+
parameters: [
|
24
|
+
{
|
25
|
+
id: 1,
|
26
|
+
name: "PuppetEnv",
|
27
|
+
description: "",
|
28
|
+
type: "puppetenv",
|
29
|
+
value: "2"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
id: 2,
|
33
|
+
name: "PW",
|
34
|
+
description: "",
|
35
|
+
type: "password",
|
36
|
+
value: "rooot"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
id: 3,
|
40
|
+
name: "Blub",
|
41
|
+
description: "",
|
42
|
+
type: "hostparam",
|
43
|
+
value: "awesome"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
id: 4,
|
47
|
+
name: "111allo",
|
48
|
+
description: "",
|
49
|
+
type: "ip",
|
50
|
+
value: "1.1.1.1"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
id: 5,
|
54
|
+
name: "1111aasdfasf",
|
55
|
+
description: "",
|
56
|
+
type: "hostname",
|
57
|
+
value: "dername"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
id: 6,
|
61
|
+
name: "222nocheiner",
|
62
|
+
description: "",
|
63
|
+
type: "hostparam",
|
64
|
+
value: ""
|
65
|
+
},
|
66
|
+
{
|
67
|
+
id: 7,
|
68
|
+
name: "aaaaa",
|
69
|
+
description: "aa",
|
70
|
+
type: "ptable",
|
71
|
+
value: ""
|
72
|
+
},
|
73
|
+
{
|
74
|
+
id: 8,
|
75
|
+
name: "aaa",
|
76
|
+
description: "",
|
77
|
+
type: "hostparam",
|
78
|
+
value: "2134234"
|
79
|
+
}
|
80
|
+
]
|
81
|
+
};
|
82
|
+
|
83
|
+
export const newInstance = {
|
84
|
+
mode: "newInstance",
|
85
|
+
organization: "Default Organization",
|
86
|
+
location: "Default Location",
|
87
|
+
applications: {
|
88
|
+
"1": "Test123",
|
89
|
+
"2": "sowasvonneu"
|
90
|
+
},
|
91
|
+
loadParameterSelectionUrl: "/acd/ui_acd_app/__id__",
|
92
|
+
loadForemanDataUrl: "/acd/ui_acd_fdata/__id__"
|
93
|
+
};
|
94
|
+
export const editInstance = {
|
95
|
+
mode: "editInstance",
|
96
|
+
organization: "Default Organization",
|
97
|
+
location: "Default Location",
|
98
|
+
loadForemanDataUrl: "/acd/ui_acd_fdata/__id__",
|
99
|
+
appDefinition: {
|
100
|
+
id: 1,
|
101
|
+
name: "Test123",
|
102
|
+
hostgroup_id: 1
|
103
|
+
},
|
104
|
+
parameters: [
|
105
|
+
{
|
106
|
+
id: 1,
|
107
|
+
name: "PuppetEnv",
|
108
|
+
description: "",
|
109
|
+
type: "puppetenv",
|
110
|
+
value: "2"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
id: 2,
|
114
|
+
name: "PW",
|
115
|
+
description: "",
|
116
|
+
type: "password",
|
117
|
+
value: "rooot"
|
118
|
+
},
|
119
|
+
{
|
120
|
+
id: 3,
|
121
|
+
name: "Blub",
|
122
|
+
description: "",
|
123
|
+
type: "hostparam",
|
124
|
+
value: "awesome"
|
125
|
+
},
|
126
|
+
{
|
127
|
+
id: 4,
|
128
|
+
name: "111allo",
|
129
|
+
description: "",
|
130
|
+
type: "ip",
|
131
|
+
value: "1.1.1.1"
|
132
|
+
},
|
133
|
+
{
|
134
|
+
id: 5,
|
135
|
+
name: "1111aasdfasf",
|
136
|
+
description: "",
|
137
|
+
type: "hostname",
|
138
|
+
value: "dername"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
id: 6,
|
142
|
+
name: "222nocheiner",
|
143
|
+
description: "",
|
144
|
+
type: "hostparam",
|
145
|
+
value: "adfasdf"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
id: 7,
|
149
|
+
name: "aaaaa",
|
150
|
+
description: "aa",
|
151
|
+
type: "ptable",
|
152
|
+
value: "104"
|
153
|
+
},
|
154
|
+
{
|
155
|
+
id: 8,
|
156
|
+
name: "aaa",
|
157
|
+
description: "",
|
158
|
+
type: "hostparam",
|
159
|
+
value: "2134234"
|
160
|
+
}
|
161
|
+
]
|
162
|
+
};
|
@@ -0,0 +1,194 @@
|
|
1
|
+
export const parameterSelectionData_1 = {
|
2
|
+
editMode: false,
|
3
|
+
error: {
|
4
|
+
errorMsg: '',
|
5
|
+
status: '',
|
6
|
+
statusText: ''
|
7
|
+
},
|
8
|
+
foremanData: {
|
9
|
+
hostgroup_id: 1,
|
10
|
+
environments: [
|
11
|
+
{
|
12
|
+
id: 1,
|
13
|
+
name: 'production'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
id: 2,
|
17
|
+
name: 'test'
|
18
|
+
}
|
19
|
+
],
|
20
|
+
lifecycle_environments: [],
|
21
|
+
domains: [],
|
22
|
+
computeprofiles: [],
|
23
|
+
ptables: [
|
24
|
+
{
|
25
|
+
id: 105,
|
26
|
+
name: 'Kickstart default'
|
27
|
+
},
|
28
|
+
{
|
29
|
+
id: 104,
|
30
|
+
name: 'Kickstart default thin'
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
hostgroupId: 1,
|
35
|
+
loading: false,
|
36
|
+
sortingColumns: {
|
37
|
+
name: {
|
38
|
+
direction: 'asc',
|
39
|
+
position: 0
|
40
|
+
}
|
41
|
+
},
|
42
|
+
appDefinition: {
|
43
|
+
id: 1,
|
44
|
+
name: 'Test123',
|
45
|
+
hostgroup_id: 1
|
46
|
+
},
|
47
|
+
columns: [
|
48
|
+
{
|
49
|
+
property: 'name',
|
50
|
+
header: {
|
51
|
+
label: 'Name',
|
52
|
+
props: {
|
53
|
+
index: 0,
|
54
|
+
sort: true,
|
55
|
+
style: {
|
56
|
+
width: '20%'
|
57
|
+
}
|
58
|
+
},
|
59
|
+
},
|
60
|
+
},
|
61
|
+
{
|
62
|
+
property: 'description',
|
63
|
+
header: {
|
64
|
+
label: 'Description',
|
65
|
+
props: {
|
66
|
+
index: 1,
|
67
|
+
sort: true,
|
68
|
+
style: {
|
69
|
+
width: '25%'
|
70
|
+
}
|
71
|
+
},
|
72
|
+
},
|
73
|
+
cell: {
|
74
|
+
props: {
|
75
|
+
index: 1
|
76
|
+
},
|
77
|
+
}
|
78
|
+
},
|
79
|
+
{
|
80
|
+
property: 'type',
|
81
|
+
header: {
|
82
|
+
label: 'Type',
|
83
|
+
props: {
|
84
|
+
index: 2,
|
85
|
+
sort: true,
|
86
|
+
style: {
|
87
|
+
width: '20%'
|
88
|
+
}
|
89
|
+
},
|
90
|
+
},
|
91
|
+
cell: {
|
92
|
+
props: {
|
93
|
+
index: 2
|
94
|
+
},
|
95
|
+
}
|
96
|
+
},
|
97
|
+
{
|
98
|
+
property: 'value',
|
99
|
+
header: {
|
100
|
+
label: 'Default value',
|
101
|
+
props: {
|
102
|
+
index: 3,
|
103
|
+
sort: true,
|
104
|
+
style: {
|
105
|
+
width: '25%'
|
106
|
+
}
|
107
|
+
},
|
108
|
+
},
|
109
|
+
cell: {
|
110
|
+
props: {
|
111
|
+
index: 3
|
112
|
+
},
|
113
|
+
}
|
114
|
+
},
|
115
|
+
{
|
116
|
+
property: 'actions',
|
117
|
+
header: {
|
118
|
+
label: 'Actions',
|
119
|
+
props: {
|
120
|
+
index: 4
|
121
|
+
},
|
122
|
+
},
|
123
|
+
cell: {
|
124
|
+
props: {
|
125
|
+
index: 4
|
126
|
+
},
|
127
|
+
}
|
128
|
+
}
|
129
|
+
],
|
130
|
+
rows: [
|
131
|
+
{
|
132
|
+
id: 1,
|
133
|
+
name: 'PuppetEnv',
|
134
|
+
description: '',
|
135
|
+
type: 'puppetenv',
|
136
|
+
value: '2'
|
137
|
+
},
|
138
|
+
{
|
139
|
+
id: 2,
|
140
|
+
name: 'PW',
|
141
|
+
description: '',
|
142
|
+
type: 'password',
|
143
|
+
value: 'rooot'
|
144
|
+
},
|
145
|
+
{
|
146
|
+
id: 3,
|
147
|
+
name: 'Blub',
|
148
|
+
description: '',
|
149
|
+
type: 'hostparam',
|
150
|
+
value: 'awesome'
|
151
|
+
},
|
152
|
+
{
|
153
|
+
id: 4,
|
154
|
+
name: '111allo',
|
155
|
+
description: '',
|
156
|
+
type: 'ip',
|
157
|
+
value: '1.1.1.1'
|
158
|
+
},
|
159
|
+
{
|
160
|
+
id: 5,
|
161
|
+
name: '1111aasdfasf',
|
162
|
+
description: '',
|
163
|
+
type: 'hostname',
|
164
|
+
value: 'dername'
|
165
|
+
},
|
166
|
+
{
|
167
|
+
id: 6,
|
168
|
+
name: '222nocheiner',
|
169
|
+
description: '',
|
170
|
+
type: 'hostparam',
|
171
|
+
value: ''
|
172
|
+
},
|
173
|
+
{
|
174
|
+
id: 7,
|
175
|
+
name: 'aaaaa',
|
176
|
+
description: 'aa',
|
177
|
+
type: 'ptable',
|
178
|
+
value: ''
|
179
|
+
},
|
180
|
+
{
|
181
|
+
id: 8,
|
182
|
+
name: 'aaa',
|
183
|
+
description: '',
|
184
|
+
type: 'hostparam',
|
185
|
+
value: '2134234'
|
186
|
+
}
|
187
|
+
],
|
188
|
+
parameterTypes: {
|
189
|
+
computeprofile: 'Compute profile',
|
190
|
+
domain: 'Domain',
|
191
|
+
hostparam: 'Host parameter',
|
192
|
+
lifecycleenv: 'Lifecycle environment'
|
193
|
+
}
|
194
|
+
};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
cloneDeep,
|
4
|
+
findIndex,
|
5
|
+
findLastIndex,
|
6
|
+
} from 'lodash';
|
7
|
+
|
8
|
+
import {
|
9
|
+
parameterSelectionData_1,
|
10
|
+
} from '../__fixtures__/parameterSelectionData_1.fixtures';
|
11
|
+
|
12
|
+
export const successState = Immutable(parameterSelectionData_1);
|
13
|
+
|
14
|
+
const EDIT_ROW_ID = 5;
|
15
|
+
|
16
|
+
var editClone = parameterSelectionData_1;
|
17
|
+
var editIndex = findIndex(editClone.rows, { id: EDIT_ROW_ID })
|
18
|
+
editClone["rows"][editIndex].backup = cloneDeep(editClone["rows"][editIndex]);
|
19
|
+
export const editState = Immutable(editClone);
|
20
|
+
|
21
|
+
export const initParameterSelectionPayload = parameterSelectionData_1;
|
22
|
+
export const addParameterPayload = { };
|
23
|
+
export const deleteParameterPayload = {
|
24
|
+
rowData: {
|
25
|
+
id: EDIT_ROW_ID,
|
26
|
+
},
|
27
|
+
};
|
28
|
+
export const activateEditParameterPayload = {
|
29
|
+
rowData: {
|
30
|
+
id: EDIT_ROW_ID,
|
31
|
+
},
|
32
|
+
};
|
33
|
+
export const confirmEditParameterPayload = {
|
34
|
+
rowData: {
|
35
|
+
id: EDIT_ROW_ID,
|
36
|
+
},
|
37
|
+
};
|
38
|
+
export const cancelEditParameterPayload = {
|
39
|
+
rowData: {
|
40
|
+
id: EDIT_ROW_ID,
|
41
|
+
},
|
42
|
+
};
|
43
|
+
export const changeEditParameterPayload = {
|
44
|
+
value: "helloworld",
|
45
|
+
property: "value",
|
46
|
+
rowData: {
|
47
|
+
id: EDIT_ROW_ID,
|
48
|
+
}
|
49
|
+
};
|
50
|
+
export const sortParameterPayload = {
|
51
|
+
selectedColumn: "type",
|
52
|
+
};
|
53
|
+
|
54
|
+
export const loadForemanDataRequestPayload = {
|
55
|
+
clearRows: false,
|
56
|
+
};
|
57
|
+
export const loadForemanDataSuccessPayload = {
|
58
|
+
hostgroup_id: 1,
|
59
|
+
environments: [
|
60
|
+
{
|
61
|
+
id: 1,
|
62
|
+
name: "production"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
id: 2,
|
66
|
+
name: "test"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
lifecycle_environments: [],
|
70
|
+
domains: [],
|
71
|
+
computeprofiles: [],
|
72
|
+
ptables: [
|
73
|
+
{
|
74
|
+
id: 105,
|
75
|
+
name: "Kickstart default"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
id: 104,
|
79
|
+
name: "Kickstart default thin"
|
80
|
+
}
|
81
|
+
]
|
82
|
+
};
|
83
|
+
export const loadForemanDataFailurePayload = {
|
84
|
+
error: "Something really bad happend",
|
85
|
+
};
|
86
|
+
|
87
|
+
export const loadParameterSelectionRequestPayload = { };
|
88
|
+
export const loadParameterSelectionSuccessPayload = {
|
89
|
+
app_definition: {
|
90
|
+
id: 2,
|
91
|
+
name: "sowasvonneu",
|
92
|
+
description: "",
|
93
|
+
hostgroup_id: 1,
|
94
|
+
parameters: "[{\"id\":0,\"name\":\"richtigneu\",\"description\":\"\",\"type\":\"puppetenv\",\"value\":\"1\"},{\"id\":1,\"name\":\"ganzgut\",\"description\":\"\",\"type\":\"ip\",\"value\":\"1.1.1.2\"}]",
|
95
|
+
created_at: "2019-11-13 17:47:27 +0100",
|
96
|
+
updated_at: "2019-11-13 17:47:27 +0100"
|
97
|
+
},
|
98
|
+
fdata: {
|
99
|
+
hostgroup_id: 1,
|
100
|
+
environments: [
|
101
|
+
{
|
102
|
+
id: 1,
|
103
|
+
name: "production"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
id: 2,
|
107
|
+
name: "test"
|
108
|
+
}
|
109
|
+
],
|
110
|
+
lifecycle_environments: [],
|
111
|
+
domains: [],
|
112
|
+
computeprofiles: [],
|
113
|
+
ptables: [
|
114
|
+
{
|
115
|
+
id: 105,
|
116
|
+
name: "Kickstart default"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
id: 104,
|
120
|
+
name: "Kickstart default thin"
|
121
|
+
}
|
122
|
+
]
|
123
|
+
}
|
124
|
+
};
|
125
|
+
export const loadParameterSelectionFailurePayload = {
|
126
|
+
error: "Something really bad happend",
|
127
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import ParameterSelection from '../ParameterSelection';
|
4
|
+
|
5
|
+
import {
|
6
|
+
newDefinition,
|
7
|
+
editDefinition,
|
8
|
+
newInstance,
|
9
|
+
editInstance,
|
10
|
+
} from '../__fixtures__/parameterSelection.fixtures'
|
11
|
+
|
12
|
+
jest.mock('foremanReact/components/common/forms/Select');
|
13
|
+
|
14
|
+
const noop = () => {};
|
15
|
+
|
16
|
+
const fixtures = {
|
17
|
+
'should render newDefinition': {
|
18
|
+
loading: false,
|
19
|
+
data: newDefinition,
|
20
|
+
error: { statusText: '', errorMsg: '' },
|
21
|
+
initParameterSelection: noop,
|
22
|
+
loadForemanData: noop,
|
23
|
+
},
|
24
|
+
'should render editDefinition': {
|
25
|
+
loading: false,
|
26
|
+
data: editDefinition,
|
27
|
+
error: { statusText: '', errorMsg: '' },
|
28
|
+
initParameterSelection: noop,
|
29
|
+
loadForemanData: noop,
|
30
|
+
},
|
31
|
+
'should render newInstance': {
|
32
|
+
loading: false,
|
33
|
+
data: newInstance,
|
34
|
+
error: { statusText: '', errorMsg: '' },
|
35
|
+
initParameterSelection: noop,
|
36
|
+
loadForemanData: noop,
|
37
|
+
},
|
38
|
+
'should render editInstance': {
|
39
|
+
loading: false,
|
40
|
+
data: editInstance,
|
41
|
+
error: { statusText: '', errorMsg: '' },
|
42
|
+
initParameterSelection: noop,
|
43
|
+
loadForemanData: noop,
|
44
|
+
},
|
45
|
+
};
|
46
|
+
|
47
|
+
describe('ParameterSelection', () =>
|
48
|
+
testComponentSnapshotsWithFixtures(ParameterSelection, fixtures));
|
@@ -0,0 +1,150 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import reducer, { initialState } from '../ParameterSelectionReducer';
|
3
|
+
|
4
|
+
import {
|
5
|
+
successState,
|
6
|
+
editState,
|
7
|
+
initParameterSelectionPayload,
|
8
|
+
addParameterPayload,
|
9
|
+
deleteParameterPayload,
|
10
|
+
activateEditParameterPayload,
|
11
|
+
confirmEditParameterPayload,
|
12
|
+
cancelEditParameterPayload,
|
13
|
+
changeEditParameterPayload,
|
14
|
+
sortParameterPayload,
|
15
|
+
loadForemanDataRequestPayload,
|
16
|
+
loadForemanDataSuccessPayload,
|
17
|
+
loadForemanDataFailurePayload,
|
18
|
+
loadParameterSelectionRequestPayload,
|
19
|
+
loadParameterSelectionSuccessPayload,
|
20
|
+
loadParameterSelectionFailurePayload,
|
21
|
+
} from '../__fixtures__/parameterSelectionReducer.fixtures';
|
22
|
+
|
23
|
+
import {
|
24
|
+
INIT_PARAMETER_SELECTION,
|
25
|
+
PARAMETER_DELETE,
|
26
|
+
PARAMETER_ADD,
|
27
|
+
PARAMETER_EDIT_ACTIVATE,
|
28
|
+
PARAMETER_EDIT_CONFIRM,
|
29
|
+
PARAMETER_EDIT_CHANGE,
|
30
|
+
PARAMETER_EDIT_CANCEL,
|
31
|
+
PARAMETER_SORT,
|
32
|
+
LOAD_FOREMAN_DATA_REQUEST,
|
33
|
+
LOAD_FOREMAN_DATA_SUCCESS,
|
34
|
+
LOAD_FOREMAN_DATA_FAILURE,
|
35
|
+
LOAD_PARAMETER_SELECTION_REQUEST,
|
36
|
+
LOAD_PARAMETER_SELECTION_SUCCESS,
|
37
|
+
LOAD_PARAMETER_SELECTION_FAILURE,
|
38
|
+
} from '../ParameterSelectionConstants';
|
39
|
+
|
40
|
+
const fixtures = {
|
41
|
+
'should return initial state': {
|
42
|
+
state: initialState,
|
43
|
+
action: {
|
44
|
+
type: undefined,
|
45
|
+
payload: {},
|
46
|
+
},
|
47
|
+
},
|
48
|
+
|
49
|
+
'should initialize component': {
|
50
|
+
state: initialState,
|
51
|
+
action: {
|
52
|
+
type: INIT_PARAMETER_SELECTION,
|
53
|
+
payload: initParameterSelectionPayload,
|
54
|
+
},
|
55
|
+
},
|
56
|
+
'should add a parameter': {
|
57
|
+
state: successState,
|
58
|
+
action: {
|
59
|
+
type: PARAMETER_ADD,
|
60
|
+
payload: addParameterPayload,
|
61
|
+
},
|
62
|
+
},
|
63
|
+
'should delete a parameter': {
|
64
|
+
state: successState,
|
65
|
+
action: {
|
66
|
+
type: PARAMETER_DELETE,
|
67
|
+
payload: deleteParameterPayload,
|
68
|
+
},
|
69
|
+
},
|
70
|
+
'should activate edit parameter': {
|
71
|
+
state: successState,
|
72
|
+
action: {
|
73
|
+
type: PARAMETER_EDIT_ACTIVATE,
|
74
|
+
payload: activateEditParameterPayload,
|
75
|
+
},
|
76
|
+
},
|
77
|
+
'should confirm edit parameter': {
|
78
|
+
state: editState,
|
79
|
+
action: {
|
80
|
+
type: PARAMETER_EDIT_CONFIRM,
|
81
|
+
payload: confirmEditParameterPayload,
|
82
|
+
},
|
83
|
+
},
|
84
|
+
'should cancel edit parameter': {
|
85
|
+
state: editState,
|
86
|
+
action: {
|
87
|
+
type: PARAMETER_EDIT_CANCEL,
|
88
|
+
payload: cancelEditParameterPayload,
|
89
|
+
},
|
90
|
+
},
|
91
|
+
'should change edit parameter': {
|
92
|
+
state: editState,
|
93
|
+
action: {
|
94
|
+
type: PARAMETER_EDIT_CHANGE,
|
95
|
+
payload: changeEditParameterPayload,
|
96
|
+
},
|
97
|
+
},
|
98
|
+
'should sort parameter': {
|
99
|
+
state: successState,
|
100
|
+
action: {
|
101
|
+
type: PARAMETER_SORT,
|
102
|
+
payload: sortParameterPayload,
|
103
|
+
},
|
104
|
+
},
|
105
|
+
'should request load foreman data': {
|
106
|
+
state: successState,
|
107
|
+
action: {
|
108
|
+
type: LOAD_FOREMAN_DATA_REQUEST,
|
109
|
+
payload: loadForemanDataRequestPayload,
|
110
|
+
},
|
111
|
+
},
|
112
|
+
'should load foreman data be successful': {
|
113
|
+
state: successState,
|
114
|
+
action: {
|
115
|
+
type: LOAD_FOREMAN_DATA_SUCCESS,
|
116
|
+
payload: loadForemanDataSuccessPayload,
|
117
|
+
},
|
118
|
+
},
|
119
|
+
'should load foreman data be erroneous': {
|
120
|
+
state: successState,
|
121
|
+
action: {
|
122
|
+
type: LOAD_FOREMAN_DATA_FAILURE,
|
123
|
+
payload: loadForemanDataFailurePayload,
|
124
|
+
},
|
125
|
+
},
|
126
|
+
'should request parameter selection': {
|
127
|
+
state: initialState,
|
128
|
+
action: {
|
129
|
+
type: LOAD_PARAMETER_SELECTION_REQUEST,
|
130
|
+
payload: loadParameterSelectionRequestPayload,
|
131
|
+
},
|
132
|
+
},
|
133
|
+
'should load parameter selection be successful': {
|
134
|
+
state: initialState,
|
135
|
+
action: {
|
136
|
+
type: LOAD_PARAMETER_SELECTION_SUCCESS,
|
137
|
+
payload: loadParameterSelectionSuccessPayload,
|
138
|
+
},
|
139
|
+
},
|
140
|
+
'should load parameter selection be erroneous': {
|
141
|
+
state: initialState,
|
142
|
+
action: {
|
143
|
+
type: LOAD_PARAMETER_SELECTION_FAILURE,
|
144
|
+
payload: loadParameterSelectionFailurePayload,
|
145
|
+
},
|
146
|
+
},
|
147
|
+
};
|
148
|
+
|
149
|
+
describe('ParameterSelectionReducer', () =>
|
150
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|