Add new code new version
[sdc.git] / openecomp-ui / test / flows / FlowsListEditor.test.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import expect from 'expect';
22 import React from 'react';
23 import TestUtils from 'react-addons-test-utils';
24 import {mapStateToProps} from 'sdc-app/flows/FlowsListEditor.js';
25 import FlowsListEditorView from 'sdc-app/flows/FlowsListEditorView.jsx';
26
27 describe('Flows List Editor Mapper and View Classes: ', function () {
28
29         it('mapStateToProps mapper exists', () => {
30                 expect(mapStateToProps).toExist();
31         });
32
33         it('mapStateToProps mapper - without flowList', () => {
34                 let flows = {
35                         isDisplayModal: true,
36                         isModalInEditMode: false,
37                         shouldShowWorkflowsEditor: undefined
38                 };
39                 let results = mapStateToProps({flows});
40                 expect(results.flowList).toExist();
41                 expect(results.flowList.length).toEqual(0);
42                 expect(results.shouldShowWorkflowsEditor).toBe(true);
43         });
44
45         it('mapStateToProps mapper - populated flowList', () => {
46                 let artifactName = 'test1', description = 'desc';
47                 let flows = {
48                         flowList: [{artifactName, description}],
49                         isDisplayModal: true,
50                         isModalInEditMode: false,
51                         shouldShowWorkflowsEditor: false
52                 };
53                 let results = mapStateToProps({flows});
54                 expect(results.flowList).toExist();
55                 expect(results.flowList.length).toEqual(1);
56                 expect(results.shouldShowWorkflowsEditor).toBe(false);
57         });
58
59         it('mapStateToProps mapper - populated flowList and currentFlow is in readonly', () => {
60                 let artifactName = 'test1', description = 'desc';
61                 let currentFlow = {artifactName, description, readonly: true};
62                 let flows = {
63                         flowList: [currentFlow],
64                         currentFlow,
65                         isDisplayModal: true,
66                         isModalInEditMode: false,
67                         shouldShowWorkflowsEditor: false
68                 };
69                 let results = mapStateToProps({flows});
70                 expect(results.currentFlow).toExist();
71                 expect(results.isCheckedOut).toEqual(false);
72         });
73
74         it('mapStateToProps mapper - populated flowList and currentFlow is in not readonly', () => {
75                 let artifactName = 'test1', description = 'desc';
76                 let currentFlow = {artifactName, description, readonly: false};
77                 let flows = {
78                         flowList: [currentFlow],
79                         currentFlow,
80                         isDisplayModal: true,
81                         isModalInEditMode: false,
82                         shouldShowWorkflowsEditor: false
83                 };
84                 let results = mapStateToProps({flows});
85                 expect(results.currentFlow).toExist();
86                 expect(results.isCheckedOut).toEqual(true);
87         });
88
89         it('basic view component run with empty flowList and should show the list', () => {
90                 let renderer = TestUtils.createRenderer();
91                 let artifactName = 'test1', description = 'desc';
92                 let currentFlow = {artifactName, description, readonly: false};
93                 renderer.render(<FlowsListEditorView shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
94                 let renderedOutput = renderer.getRenderOutput();
95                 expect(renderedOutput).toExist();
96         });
97
98         it('basic view component run with empty flowList and should show the diagram', () => {
99                 const flow = {
100                         'artifactType': 'WORKFLOW',
101                         'participants': [
102                                 {
103                                         'id': '1',
104                                         'name': 'Customer'
105                                 },
106                                 {
107                                         'id': '2',
108                                         'name': 'CCD'
109                                 },
110                                 {
111                                         'id': '3',
112                                         'name': 'Infrastructure'
113                                 },
114                                 {
115                                         'id': '4',
116                                         'name': 'MSO'
117                                 },
118                                 {
119                                         'id': '5',
120                                         'name': 'SDN-C'
121                                 },
122                                 {
123                                         'id': '6',
124                                         'name': 'A&AI'
125                                 },
126                                 {
127                                         'id': '7',
128                                         'name': 'APP-C'
129                                 },
130                                 {
131                                         'id': '8',
132                                         'name': 'Cloud'
133                                 },
134                                 {
135                                         'id': '9',
136                                         'name': 'DCAE'
137                                 },
138                                 {
139                                         'id': '10',
140                                         'name': 'ALTS'
141                                 },
142                                 {
143                                         'id': '11',
144                                         'name': 'VF'
145                                 }
146                         ],
147                         'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
148                         'artifactDisplayName': 'zizizi',
149                         'artifactGroupType': 'INFORMATIONAL',
150                         'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
151                         'artifactName': 'zizizi',
152                         'artifactLabel': 'zizizi',
153                         'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
154                         'artifactVersion': '1',
155                         'creationDate': 1470144601623,
156                         'lastUpdateDate': 1470144601623,
157                         'description': 'aslkjdfl asfdasdf',
158                         'mandatory': false,
159                         'timeout': 0,
160                         'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
161                         'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
162                         'heatParameters': [],
163                         'sequenceDiagramModel': {
164                                 'diagram': {
165                                         'metadata': {
166                                                 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
167                                                 'name': 'zizizi',
168                                                 'ref': 'BLANK'
169                                         },
170                                         'lifelines': [
171                                                 {
172                                                         'id': '1',
173                                                         'name': 'Customer',
174                                                         'index': 1,
175                                                         'x': 175
176                                                 },
177                                                 {
178                                                         'id': '2',
179                                                         'name': 'CCD',
180                                                         'index': 2,
181                                                         'x': 575
182                                                 },
183                                                 {
184                                                         'id': '3',
185                                                         'name': 'Infrastructure',
186                                                         'index': 3,
187                                                         'x': 975
188                                                 },
189                                                 {
190                                                         'id': '4',
191                                                         'name': 'MSO',
192                                                         'index': 4,
193                                                         'x': 1375
194                                                 },
195                                                 {
196                                                         'id': '5',
197                                                         'name': 'SDN-C',
198                                                         'index': 5,
199                                                         'x': 1775
200                                                 },
201                                                 {
202                                                         'id': '6',
203                                                         'name': 'A&AI',
204                                                         'index': 6,
205                                                         'x': 2175
206                                                 },
207                                                 {
208                                                         'id': '7',
209                                                         'name': 'APP-C',
210                                                         'index': 7,
211                                                         'x': 2575
212                                                 },
213                                                 {
214                                                         'id': '8',
215                                                         'name': 'Cloud',
216                                                         'index': 8,
217                                                         'x': 2975
218                                                 },
219                                                 {
220                                                         'id': '9',
221                                                         'name': 'DCAE',
222                                                         'index': 9,
223                                                         'x': 3375
224                                                 },
225                                                 {
226                                                         'id': '10',
227                                                         'name': 'ALTS',
228                                                         'index': 10,
229                                                         'x': 3775
230                                                 },
231                                                 {
232                                                         'id': '11',
233                                                         'name': 'VF',
234                                                         'index': 11,
235                                                         'x': 4175
236                                                 }
237                                         ],
238                                         'steps': [
239                                                 {
240                                                         'message': {
241                                                                 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84',
242                                                                 'name': '[Unnamed Message]',
243                                                                 'type': 'request',
244                                                                 'from': '1',
245                                                                 'to': '2',
246                                                                 'index': 1
247                                                         }
248                                                 },
249                                                 {
250                                                         'message': {
251                                                                 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c',
252                                                                 'name': '[Unnamed Message]',
253                                                                 'type': 'request',
254                                                                 'from': '1',
255                                                                 'to': '2',
256                                                                 'index': 2
257                                                         }
258                                                 }
259                                         ]
260                                 }
261                         }
262                 };
263                 let renderer = TestUtils.createRenderer();
264                 renderer.render(<FlowsListEditorView currentFlow={flow} shouldShowWorkflowsEditor={false} flowList={[flow]}/>);
265                 let renderedOutput = renderer.getRenderOutput();
266                 expect(renderedOutput).toExist();
267         });
268
269         it('basic view component run with empty flowList and should show popup modal', () => {
270                 let renderer = TestUtils.createRenderer();
271                 let artifactName = 'test1', description = 'desc';
272                 let currentFlow = {artifactName, description, readonly: false};
273                 renderer.render(<FlowsListEditorView isDisplayModal={true} shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
274                 let renderedOutput = renderer.getRenderOutput();
275                 expect(renderedOutput).toExist();
276         });
277
278
279 });