Show the VF module version on the view/edit screen
[vid.git] / vid-webpack-master / cypress / integration / iFrames / viewOnlyDrawingBoard.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 /// <reference types="Cypress" />
3 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
4 import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
5 import {AsyncInstantiationModel} from "../../support/jsonBuilders/models/asyncInstantiation.model";
6
7 var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
8 var jsonBuilderInstantiationBuilder: JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
9 const SERVICE_MODEL_ID: string = '6e59c5de-f052-46fa-aa7e-2fca9d674c44';
10 const SERVICE_INVARIANT_ID: string = "d27e42cf-087e-4d31-88ac-6c4b7585f800";
11
12 export const initServicePlanning = function (viewOrEdit: string, customModelFilePath?: string ){
13   const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
14   const SERVICE_TYPE: string = "TYLER SILVIA";
15   const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
16   if (Cypress._.isNil(customModelFilePath)){
17     customModelFilePath = '../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json';
18   }
19
20   cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json').then((res) => {
21     jsonBuilderAndMock.basicJson(
22       res,
23       Cypress.config('baseUrl') + "/rest/models/services/6e59c5de-f052-46fa-aa7e-2fca9d674c44",
24       200,
25       0,
26       "ServiceTreeWithMultipleChildren_serviceModel",
27     )
28   });
29
30   cy.readFile(customModelFilePath).then((res) => {
31     jsonBuilderAndMock.basicJson(
32       res,
33       Cypress.config('baseUrl') + "/aai_get_service_instance_topology/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
34       200, 0,
35       "ServiceTreeWithMultipleChildren_serviceInstance",
36     );
37   });
38   cy.openIframe(`app/ui/#/servicePlanning/${viewOrEdit}?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
39 }
40
41 describe('View only drawing board', function () {
42   const _VIEW = "VIEW";
43
44   beforeEach(() => {
45       cy.clearSessionStorage();
46       cy.preventErrorsOnLoading();
47       cy.initAAIMock();
48       cy.initVidMock();
49       cy.mockLatestVersionForService(SERVICE_MODEL_ID, SERVICE_INVARIANT_ID);
50       cy.initZones();
51       cy.permissionVidMock();
52       cy.login();
53   });
54
55   afterEach(() => {
56     cy.screenshot();
57   });
58
59   it('error should display on api error', function () {
60     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
61     const SERVICE_TYPE: string = "TYLER SILVIA";
62     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
63     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
64
65     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/serviceModels/ecompNamingFalseModel.json').then((res) => {
66       jsonBuilderInstantiationBuilder.basicJson(
67         res,
68         Cypress.config('baseUrl') + "/rest/models/services/6b528779-44a3-4472-bdff-9cd15ec93450",
69         500,
70         0,
71         "error 500 getServiceInstanceTopology"
72       );
73
74       cy.openIframe(`app/ui/#/servicePlanning/VIEW?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
75
76       cy.get('div.title')
77         .contains('Server not available');
78
79     });
80   });
81
82   it(`when open service planning in view mode service instance is shown as expected`, function () {
83     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
84     const SERVICE_TYPE: string = "TYLER SILVIA";
85     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
86     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
87
88     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/serviceModels/ecompNamingFalseModel.json').then((res) => {
89       jsonBuilderAndMock.basicJson(
90         res,
91         Cypress.config('baseUrl') + "/rest/models/services/6b528779-44a3-4472-bdff-9cd15ec93450",
92         200,
93         0,
94         "ecompNamingFalseModel",
95       )
96     });
97
98     cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/getServiceInstanceTopologyResult.json').then((res) => {
99       res.vnfs['2017-488_PASQUALE-vPE 0']
100         .vfModules['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0']['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot']
101       .modelInfo.modelVersion = '2';
102       res.vnfs['2017-488_PASQUALE-vPE 0']
103         .vfModules['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1']['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc']
104         .modelInfo.modelVersion = null;
105
106       jsonBuilderAndMock.basicJson(
107         res,
108         Cypress.config('baseUrl') + "/aai_get_service_instance_topology/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
109         200, 0,
110         "initServiceInstanceTopology",
111       )
112     });
113
114     cy.openIframe(`app/ui/#/servicePlanning/VIEW?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
115     //cy.visit("welcome.htm"); //relaod page to not break the following tests
116
117     //testing left side
118     cy.getElementByDataTestsId('node-2017-388_PASQUALE-vPE 1').find(`[data-tests-id='node-type-indicator']`).should('have.text', 'VNF');
119     cy.getElementByDataTestsId('node-2017-488_PASQUALE-vPE 0').click({force: true});
120     cy.getElementByDataTestsId('node-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1').find(`[data-tests-id='node-type-indicator']`).should('have.text', 'M');
121
122     //testing right side
123     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').find(`[data-tests-id='node-type-indicator']`).should('have.length', 3).and('have.text', 'VNFVNFVNF');
124     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').eq(0).click({force: true});
125     cy.getElementByDataTestsId('node-f8360508-3f17-4414-a2ed-6bc71161e8db-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0').eq(0).find(`[data-tests-id='node-type-indicator']`).should('have.text', 'M');
126
127     //check vnf node tree sub header
128     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').find("[data-tests-id='status-property-orchStatus']").eq(0).should('have.text', 'Created');
129     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').find("[data-tests-id='status-property-provStatus']").eq(0).should('have.text', '');
130     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').find("[data-tests-id='status-property-inMaint']").should('not.exist');
131
132     //check vf Module node tree sub header
133     cy.getElementByDataTestsId('node-f8360508-3f17-4414-a2ed-6bc71161e8db-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0').find("[data-tests-id='status-property-provStatus']").eq(0).should('have.text', 'Prov Status');
134     cy.getElementByDataTestsId('node-f8360508-3f17-4414-a2ed-6bc71161e8db-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0').find("[data-tests-id='status-property-orchStatus']").eq(0).should('have.text', 'Active');
135     cy.getElementByDataTestsId('node-f8360508-3f17-4414-a2ed-6bc71161e8db-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0').find("[data-tests-id='status-property-inMaint']").eq(0).should('have.text', '');
136
137     checkVfModuleModelVersion('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0',
138     'node-f8360508-3f17-4414-a2ed-6bc71161e8db-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0',
139       '2');
140
141     checkVfModuleModelVersion('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0',
142       'node-25284168-24bb-4698-8cb4-3f509146eca5-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',
143       '');
144
145     cy.getElementByDataTestsId("serviceInstance").should('have.text', 'Service instance:');
146     cy.getElementByDataTestsId("serviceName").should('have.text', 'mCaNkinstancename');
147     cy.getElementByDataTestsId("orchStatusLabel").should('have.text', 'Orch Status:');
148     cy.getElementByDataTestsId("orchStatusValue").should('have.text', 'Active');
149     cy.getElementByDataTestsId("quantityLabel").should('be.visible');
150     cy.getElementByDataTestsId("servicesQuantity").should('have.text', ' 1 ');
151
152
153   });
154
155   it('check component info for 2 trees for vnf, vf-module, and network', function(){
156     initServicePlanning(_VIEW);
157     testComponentInfoForVNF();
158     testComponentInfoForVFMODULE();
159     testComponentInfoForNetwork();
160   });
161
162   it(`when open service planning in view mode service instance is shown as expected - e2e with API's ServiceTreeWithMultipleChildren`, function () {
163     initServicePlanning(_VIEW);
164     /*
165     0. title area -> generic stuff
166                      instance name
167                      orch status
168                      service name
169     */
170     cy.getElementByDataTestsId("serviceInstance").should('have.text', 'Service instance:');
171     cy.getElementByDataTestsId("orchStatusLabel").should('have.text', 'Orch Status:');
172     cy.getElementByDataTestsId("quantityLabel").should('be.visible');
173     cy.getElementByDataTestsId("servicesQuantity").should('have.text', ' 1 ');
174
175     // specific
176     cy.getElementByDataTestsId("serviceName").should('have.text', 'SERVICE_INSTANCE_NAME');
177     cy.getElementByDataTestsId("orchStatusValue").should('have.text', 'GARBAGE DATA');
178     cy.get('span#service-model-name').should('have.text', 'ComplexService');
179
180     // test component info of service-level
181     let labelsAndValues = [
182       ['Model version', '1.0'],
183       ['Instance ID', 'service-instance-id'],
184       ['Service type', 'service-instance-type'],
185     ];
186     cy.assertComponentInfoTitleLabelsAndValues('Service Instance INFO', labelsAndValues);
187
188
189     // expand all
190     cy.get('available-models-tree').find('.toggle-children').click({ multiple: true });
191
192     /*
193     1. Left tree -> VNF with 3 vf modules
194                     Network
195                     Configuration
196     */
197     const leftShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = {
198       'node-VF_vGeraldine 0': {
199         'node-type-indicator': 'VNF',
200         'node-name': 'VF_vGeraldine 0',
201         'numberButton': '1',
202       },
203       'node-vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0': {
204         'node-type-indicator': 'M',
205         'node-name': 'vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0',
206         'numberButton': '',
207       },
208       'node-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1': {
209         'node-type-indicator': 'M',
210         'node-name': 'vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',
211         'numberButton': '1',
212       },
213       'node-vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2': {
214         'node-type-indicator': 'M',
215         'node-name': 'vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2',
216         'numberButton': '',
217       },
218       'node-ExtVL 0': {
219         'node-type-indicator': 'N',
220         'node-name': 'ExtVL 0',
221         'numberButton': '2',
222       },
223       'node-Port Mirroring Configuration By Policy 0': {
224         'node-type-indicator': 'C',
225         'node-name': 'Port Mirroring Configuration By Policy 0',
226         'numberButton': '',
227       },
228     };
229
230     for (let node in leftShouldHaves) {
231       for (let span in leftShouldHaves[node]) {
232         const expected = leftShouldHaves[node][span];
233         cy.getElementByDataTestsId(node).find(`[data-tests-id='${span}']`).should(expected ? 'have.text' : 'not.exist', expected);
234       }
235     }
236
237     /*
238     2. Right tree -> VNF with 2 vf modules
239                      2 networks
240                      IGNORE, don't check: first node, which have no Service connection
241     */
242     const rightShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = {
243       'node-d6557200-ecf2-4641-8094-5393ae3aae60-VF_vGeraldine 0:0': {
244         'node-type-indicator': 'VNF',
245         'node-name': 'VNF2_INSTANCE_NAME',
246         'status-property-orchStatus': '',
247         'status-property-provStatus': '',
248         'status-property-inMaint': '',
249       },
250       'node-dc229cd8-c132-4455-8517-5c1787c18b14-dc229cd8-c132-4455-8517-5c1787c18b14:0': {
251         'node-type-indicator': 'M',
252         'node-name': 'ss820f_0918_base',
253         'status-property-orchStatus': 'Assigned',
254         'status-property-provStatus': '',
255       },
256       'node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1:0': {
257         'node-type-indicator': 'M',
258         'node-name': 'ss820f_0918_db',
259         'status-property-orchStatus': 'deleted',
260         'status-property-provStatus': '',
261         'status-property-inMaint': '',
262       },
263       'node-ddc3f20c-08b5-40fd-af72-c6d14636b986-ExtVL 0:0': {
264         'node-type-indicator': 'N',
265         'node-name': 'NETWORK3_INSTANCE_NAME',
266         'status-property-orchStatus': 'Assigned',
267         'status-property-provStatus': 'nvtprov',
268       },
269       'node-ddc3f20c-08b5-40fd-af72-c6d14636b986-ExtVL 0:1': {
270         'node-type-indicator': 'N',
271         'node-name': 'NETWORK4_INSTANCE_NAME',
272         'status-property-orchStatus': 'Created',
273         'status-property-provStatus': 'preprov',
274       },
275     };
276
277     for (let node in rightShouldHaves) {
278       var [nodeName, nodeEq] = node.split(":");
279       for (let span in rightShouldHaves[node]) {
280         cy.getElementByDataTestsId(nodeName).eq(+nodeEq).find(`[data-tests-id='${span}']`).should('have.text', rightShouldHaves[node][span]);
281       }
282     }
283
284     /*
285     3. Left to right connections ->
286                     vnf: # of instances = 1, click -> vnf selected
287                     vf module1: # of instances = 1, click -> 1 vfmodule "ss820f_0918_db" selected
288                     vf module2: # of instances = 0, click -> nothing
289                     vf module3: # of instances = 0, click -> nothing
290                     network: # of instances = 2, click -> 2 networks selected
291                     configuration: # of instances = 0, click -> nothing
292     */
293     const leftShouldHighlight: { [text: string]: string[] } = {
294       'VF_vGeraldine 0': ['VNF2_INSTANCE_NAME'],
295       'vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0': [],
296       'vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1': ['ss820f_0918_db'],
297       'vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2': [],
298       'ExtVL 0': ['NETWORK3_INSTANCE_NAME', 'NETWORK4_INSTANCE_NAME'],
299       'Port Mirroring Configuration By Policy 0': [],
300     };
301
302     for (let text in leftShouldHighlight) {
303       cy.get('available-models-tree').contains(text).click();
304
305       cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', text + leftShouldHighlight[text].join(''));
306     }
307
308     /*
309     4. Right to left connections ->
310                     vnf: click -> vnf selected
311                     vf module1: click -> nothing
312                     vf module2: click -> vemme0 selected
313                     network1: click -> network selected
314                     network2: click -> network selected
315      */
316     const rightShouldHighlight: { [text: string]: string[] } = {
317       'VNF2_INSTANCE_NAME': ['VF_vGeraldine 0'],
318       'ss820f_0918_base': [],
319       'ss820f_0918_db': ['vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1'],
320       'NETWORK3_INSTANCE_NAME': ['ExtVL 0'],
321       'NETWORK4_INSTANCE_NAME': ['ExtVL 0'],
322     };
323
324     for (let node in rightShouldHighlight) {
325       cy.get('drawing-board-tree').contains(node).click();
326       cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', rightShouldHighlight[node].join('') + node);
327     }
328     cy.getElementByDataTestsId('isViewOnly-status-test').contains('VIEW ONLY');
329
330
331     /*
332       5. Click outside should remove highlight from all trees.
333      */
334
335     cy.clickOutside('search-left-tree-input', ()=>{
336       cy.get('.node-content-wrapper-active.node-content-wrapper-focused').should('have.length', 2)
337     },  ()=>{
338       cy.get('.node-content-wrapper-active.node-content-wrapper-focused').should('have.length', 0);
339     });
340
341
342   });
343
344   function checkVfModuleModelVersion(vnfNodeDataTestId: string, vfModuleDataTestId: string, vfModuleModelVersion: string){
345     cy.getElementByDataTestsId(vnfNodeDataTestId)
346     .getElementByDataTestsId(vfModuleDataTestId)
347     .find("[data-tests-id='status-property-modelVersion']").eq(0).should('have.text', vfModuleModelVersion);
348   }
349   function testComponentInfoForVNF(){
350     const labelsAndValuesForModel = [
351       ['Model version', '2.0'],
352       ['Model customization ID', '91415b44-753d-494c-926a-456a9172bbb9'],
353       ['Min instances', '0'],
354       ['Max instances', 'Unlimited (default)']
355     ];
356     const extraLabelsAndValuesForInstance = [['Instance type', 'VNF2_INSTANCE_TYPE'],['In maintenance','true'], ['Instance ID', 'VNF2_INSTANCE_ID']];
357     testComponentInfoByType('node-VF_vGeraldine 0', labelsAndValuesForModel,'VNF INFO',
358       'VNF2_INSTANCE_NAME', extraLabelsAndValuesForInstance,'VNF Instance INFO');
359
360   }
361
362   function testComponentInfoForVFMODULE(){
363     const labelsAndValuesForModel = [
364       ['Model version', '2'],
365       ['Model customization ID', '55b1be94-671a-403e-a26c-667e9c47d091'],
366       ['Base module', 'false'],
367       ['Min instances', '0'],
368       ['Max instances', 'Unlimited (default)'],
369       ['Initial instances count', '0']
370     ];
371     const extraLabelsAndValuesForInstance = [['In maintenance','true'], ['Instance ID', '2c1ca484-cbc2-408b-ab86-25a2c15ce280']];
372     testComponentInfoByType('node-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',labelsAndValuesForModel,'VFModule INFO',
373       'ss820f_0918_db',extraLabelsAndValuesForInstance,'VFModule Instance INFO')
374
375   }
376
377   function testComponentInfoForNetwork(){
378     const labelsAndValuesForModel = [
379       ['Model version', '37.0'],
380       ['Min instances', '0'],
381       ['Max instances', 'Unlimited (default)'],
382       ['Model customization ID', '94fdd893-4a36-4d70-b16a-ec29c54c184f'],
383       ['Network role','network role 1, network role 2']
384     ];
385     const extraLabelsAndValuesForInstance = [['In maintenance','false'], ['Instance ID', 'NETWORK3_INSTANCE_ID'],['Instance type', 'CONTRAIL30_BASIC']];
386     testComponentInfoByType('node-ExtVL 0',labelsAndValuesForModel,'Network INFO',
387       'NETWORK3_INSTANCE_NAME',extraLabelsAndValuesForInstance,'Network Instance INFO');
388
389   }
390
391   function testComponentInfoByType(leftNode:string, labelsAndValuesForModel: string[][], expectedTitleForModel:string, rightNode:string, extraLabelsAndValuesForInstance: string[][], expectedTitleForInstance:string){
392     cy.getElementByDataTestsId(leftNode).eq(0).click({force: true});
393     cy.assertComponentInfoTitleLabelsAndValues(expectedTitleForModel, labelsAndValuesForModel);
394
395     let labelsAndValuesForInstance = labelsAndValuesForModel.concat(extraLabelsAndValuesForInstance);
396     cy.get('drawing-board-tree').contains(rightNode).click();
397     cy.assertComponentInfoTitleLabelsAndValues(expectedTitleForInstance, labelsAndValuesForInstance);
398   }
399
400
401 });