upgrade vfmodule when upgraded already service, vnf and brother vfmodule e2e
[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       jsonBuilderAndMock.basicJson(
100         res,
101         Cypress.config('baseUrl') + "/aai_get_service_instance_topology/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
102         200, 0,
103         "initServiceInstanceTopology",
104       )
105     });
106
107     cy.openIframe(`app/ui/#/servicePlanning/VIEW?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
108     //cy.visit("welcome.htm"); //relaod page to not break the following tests
109
110     //testing left side
111     cy.getElementByDataTestsId('node-2017-388_PASQUALE-vPE 1').find(`[data-tests-id='node-type-indicator']`).should('have.text', 'VNF');
112     cy.getElementByDataTestsId('node-2017-488_PASQUALE-vPE 0').click({force: true});
113     cy.getElementByDataTestsId('node-2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1').find(`[data-tests-id='node-type-indicator']`).should('have.text', 'M');
114
115     //testing right side
116     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');
117     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').eq(0).click({force: true});
118     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');
119
120     //check vnf node tree sub header
121     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');
122     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', '');
123     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').find("[data-tests-id='status-property-inMaint']").should('not.exist');
124
125     //check vf Module node tree sub header
126     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');
127     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');
128     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', '');
129
130     cy.getElementByDataTestsId("serviceInstance").should('have.text', 'Service instance:');
131     cy.getElementByDataTestsId("serviceName").should('have.text', 'mCaNkinstancename');
132     cy.getElementByDataTestsId("orchStatusLabel").should('have.text', 'Orch Status:');
133     cy.getElementByDataTestsId("orchStatusValue").should('have.text', 'Active');
134     cy.getElementByDataTestsId("quantityLabel").should('be.visible');
135     cy.getElementByDataTestsId("servicesQuantity").should('have.text', ' 1 ');
136
137
138   });
139
140   it('check component info for 2 trees for vnf, vf-module, and network', function(){
141     initServicePlanning(_VIEW);
142     testComponentInfoForVNF();
143     testComponentInfoForVFMODULE();
144     testComponentInfoForNetwork();
145   });
146
147   it(`when open service planning in view mode service instance is shown as expected - e2e with API's ServiceTreeWithMultipleChildren`, function () {
148     initServicePlanning(_VIEW);
149     /*
150     0. title area -> generic stuff
151                      instance name
152                      orch status
153                      service name
154     */
155     cy.getElementByDataTestsId("serviceInstance").should('have.text', 'Service instance:');
156     cy.getElementByDataTestsId("orchStatusLabel").should('have.text', 'Orch Status:');
157     cy.getElementByDataTestsId("quantityLabel").should('be.visible');
158     cy.getElementByDataTestsId("servicesQuantity").should('have.text', ' 1 ');
159
160     // specific
161     cy.getElementByDataTestsId("serviceName").should('have.text', 'SERVICE_INSTANCE_NAME');
162     cy.getElementByDataTestsId("orchStatusValue").should('have.text', 'GARBAGE DATA');
163     cy.get('span#service-model-name').should('have.text', 'ComplexService');
164
165     // test component info of service-level
166     let labelsAndValues = [
167       ['Model version', '1.0'],
168       ['Instance ID', 'service-instance-id'],
169       ['Service type', 'service-instance-type'],
170     ];
171     cy.assertComponentInfoTitleLabelsAndValues('Service Instance INFO', labelsAndValues);
172
173
174     // expand all
175     cy.get('available-models-tree').find('.toggle-children').click({ multiple: true });
176
177     /*
178     1. Left tree -> VNF with 3 vf modules
179                     Network
180                     Configuration
181     */
182     const leftShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = {
183       'node-VF_vGeraldine 0': {
184         'node-type-indicator': 'VNF',
185         'node-name': 'VF_vGeraldine 0',
186         'numberButton': '1',
187       },
188       'node-vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0': {
189         'node-type-indicator': 'M',
190         'node-name': 'vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0',
191         'numberButton': '',
192       },
193       'node-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1': {
194         'node-type-indicator': 'M',
195         'node-name': 'vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',
196         'numberButton': '1',
197       },
198       'node-vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2': {
199         'node-type-indicator': 'M',
200         'node-name': 'vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2',
201         'numberButton': '',
202       },
203       'node-ExtVL 0': {
204         'node-type-indicator': 'N',
205         'node-name': 'ExtVL 0',
206         'numberButton': '2',
207       },
208       'node-Port Mirroring Configuration By Policy 0': {
209         'node-type-indicator': 'C',
210         'node-name': 'Port Mirroring Configuration By Policy 0',
211         'numberButton': '',
212       },
213     };
214
215     for (let node in leftShouldHaves) {
216       for (let span in leftShouldHaves[node]) {
217         const expected = leftShouldHaves[node][span];
218         cy.getElementByDataTestsId(node).find(`[data-tests-id='${span}']`).should(expected ? 'have.text' : 'not.exist', expected);
219       }
220     }
221
222     /*
223     2. Right tree -> VNF with 2 vf modules
224                      2 networks
225                      IGNORE, don't check: first node, which have no Service connection
226     */
227     const rightShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = {
228       'node-d6557200-ecf2-4641-8094-5393ae3aae60-VF_vGeraldine 0:0': {
229         'node-type-indicator': 'VNF',
230         'node-name': 'VNF2_INSTANCE_NAME',
231         'status-property-orchStatus': '',
232         'status-property-provStatus': '',
233         'status-property-inMaint': '',
234       },
235       'node-dc229cd8-c132-4455-8517-5c1787c18b14-dc229cd8-c132-4455-8517-5c1787c18b14:0': {
236         'node-type-indicator': 'M',
237         'node-name': 'ss820f_0918_base',
238         'status-property-orchStatus': 'Assigned',
239         'status-property-provStatus': '',
240       },
241       'node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1:0': {
242         'node-type-indicator': 'M',
243         'node-name': 'ss820f_0918_db',
244         'status-property-orchStatus': 'deleted',
245         'status-property-provStatus': '',
246         'status-property-inMaint': '',
247       },
248       'node-ddc3f20c-08b5-40fd-af72-c6d14636b986-ExtVL 0:0': {
249         'node-type-indicator': 'N',
250         'node-name': 'NETWORK3_INSTANCE_NAME',
251         'status-property-orchStatus': 'Assigned',
252         'status-property-provStatus': 'nvtprov',
253       },
254       'node-ddc3f20c-08b5-40fd-af72-c6d14636b986-ExtVL 0:1': {
255         'node-type-indicator': 'N',
256         'node-name': 'NETWORK4_INSTANCE_NAME',
257         'status-property-orchStatus': 'Created',
258         'status-property-provStatus': 'preprov',
259       },
260     };
261
262     for (let node in rightShouldHaves) {
263       var [nodeName, nodeEq] = node.split(":");
264       for (let span in rightShouldHaves[node]) {
265         cy.getElementByDataTestsId(nodeName).eq(+nodeEq).find(`[data-tests-id='${span}']`).should('have.text', rightShouldHaves[node][span]);
266       }
267     }
268
269     /*
270     3. Left to right connections ->
271                     vnf: # of instances = 1, click -> vnf selected
272                     vf module1: # of instances = 1, click -> 1 vfmodule "ss820f_0918_db" selected
273                     vf module2: # of instances = 0, click -> nothing
274                     vf module3: # of instances = 0, click -> nothing
275                     network: # of instances = 2, click -> 2 networks selected
276                     configuration: # of instances = 0, click -> nothing
277     */
278     const leftShouldHighlight: { [text: string]: string[] } = {
279       'VF_vGeraldine 0': ['VNF2_INSTANCE_NAME'],
280       'vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0': [],
281       'vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1': ['ss820f_0918_db'],
282       'vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2': [],
283       'ExtVL 0': ['NETWORK3_INSTANCE_NAME', 'NETWORK4_INSTANCE_NAME'],
284       'Port Mirroring Configuration By Policy 0': [],
285     };
286
287     for (let text in leftShouldHighlight) {
288       cy.get('available-models-tree').contains(text).click();
289
290       cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', text + leftShouldHighlight[text].join(''));
291     }
292
293     /*
294     4. Right to left connections ->
295                     vnf: click -> vnf selected
296                     vf module1: click -> nothing
297                     vf module2: click -> vemme0 selected
298                     network1: click -> network selected
299                     network2: click -> network selected
300      */
301     const rightShouldHighlight: { [text: string]: string[] } = {
302       'VNF2_INSTANCE_NAME': ['VF_vGeraldine 0'],
303       'ss820f_0918_base': [],
304       'ss820f_0918_db': ['vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1'],
305       'NETWORK3_INSTANCE_NAME': ['ExtVL 0'],
306       'NETWORK4_INSTANCE_NAME': ['ExtVL 0'],
307     };
308
309     for (let node in rightShouldHighlight) {
310       cy.get('drawing-board-tree').contains(node).click();
311       cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', rightShouldHighlight[node].join('') + node);
312     }
313     cy.getElementByDataTestsId('isViewOnly-status-test').contains('VIEW ONLY');
314
315
316     /*
317       5. Click outside should remove highlight from all trees.
318      */
319
320     cy.clickOutside('search-left-tree-input', ()=>{
321       cy.get('.node-content-wrapper-active.node-content-wrapper-focused').should('have.length', 2)
322     },  ()=>{
323       cy.get('.node-content-wrapper-active.node-content-wrapper-focused').should('have.length', 0);
324     });
325
326
327   });
328
329   function testComponentInfoForVNF(){
330     const labelsAndValuesForModel = [
331       ['Model version', '2.0'],
332       ['Model customization ID', '91415b44-753d-494c-926a-456a9172bbb9'],
333       ['Min instances', '0'],
334       ['Max instances', 'Unlimited (default)']
335     ];
336     const extraLabelsAndValuesForInstance = [['Instance type', 'VNF2_INSTANCE_TYPE'],['In maintenance','true'], ['Instance ID', 'VNF2_INSTANCE_ID']];
337     testComponentInfoByType('node-VF_vGeraldine 0', labelsAndValuesForModel,'VNF INFO',
338       'VNF2_INSTANCE_NAME', extraLabelsAndValuesForInstance,'VNF Instance INFO');
339
340   }
341
342   function testComponentInfoForVFMODULE(){
343     const labelsAndValuesForModel = [
344       ['Model version', '2'],
345       ['Model customization ID', '55b1be94-671a-403e-a26c-667e9c47d091'],
346       ['Base module', 'false'],
347       ['Min instances', '0'],
348       ['Max instances', 'Unlimited (default)'],
349       ['Initial instances count', '0']
350     ];
351     const extraLabelsAndValuesForInstance = [['In maintenance','true'], ['Instance ID', '2c1ca484-cbc2-408b-ab86-25a2c15ce280']];
352     testComponentInfoByType('node-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',labelsAndValuesForModel,'VFModule INFO',
353       'ss820f_0918_db',extraLabelsAndValuesForInstance,'VFModule Instance INFO')
354
355   }
356
357   function testComponentInfoForNetwork(){
358     const labelsAndValuesForModel = [
359       ['Model version', '37.0'],
360       ['Min instances', '0'],
361       ['Max instances', 'Unlimited (default)'],
362       ['Model customization ID', '94fdd893-4a36-4d70-b16a-ec29c54c184f'],
363       ['Network role','network role 1, network role 2']
364     ];
365     const extraLabelsAndValuesForInstance = [['In maintenance','false'], ['Instance ID', 'NETWORK3_INSTANCE_ID'],['Instance type', 'CONTRAIL30_BASIC']];
366     testComponentInfoByType('node-ExtVL 0',labelsAndValuesForModel,'Network INFO',
367       'NETWORK3_INSTANCE_NAME',extraLabelsAndValuesForInstance,'Network Instance INFO');
368
369   }
370
371   function testComponentInfoByType(leftNode:string, labelsAndValuesForModel: string[][], expectedTitleForModel:string, rightNode:string, extraLabelsAndValuesForInstance: string[][], expectedTitleForInstance:string){
372     cy.getElementByDataTestsId(leftNode).eq(0).click({force: true});
373     cy.assertComponentInfoTitleLabelsAndValues(expectedTitleForModel, labelsAndValuesForModel);
374
375     let labelsAndValuesForInstance = labelsAndValuesForModel.concat(extraLabelsAndValuesForInstance);
376     cy.get('drawing-board-tree').contains(rightNode).click();
377     cy.assertComponentInfoTitleLabelsAndValues(expectedTitleForInstance, labelsAndValuesForInstance);
378   }
379
380
381 });