change management cypress test
[vid.git] / vid-webpack-master / cypress / integration / iFrames / vnf.update.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
3 import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
4 import {AsyncInstantiationModel} from "../../support/jsonBuilders/models/asyncInstantiation.model";
5
6 describe('Delete vnf instance', function () {
7   let jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
8
9   let jsonBuilderInstantiationBuilder: JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
10
11   beforeEach(() => {
12     cy.window().then((win) => {
13       win.sessionStorage.clear();
14       cy.preventErrorsOnLoading();
15       cy.initAAIMock();
16       cy.initVidMock();
17       cy.initZones();
18       cy.permissionVidMock();
19       cy.login();
20     });
21   });
22
23   afterEach(() => {
24     cy.screenshot();
25   });
26
27   it(`Update vnf - add 1 delete 1`, function () {
28     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
29     const SERVICE_TYPE: string = "TYLER SILVIA";
30     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
31     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
32
33     cy.server().route({
34       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
35       method: 'POST',
36       status: 200,
37       response: "[]",
38     }).as("expectedPostAsyncInstantiation");
39
40     cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/serviceModels/ecompNamingFalseModel.json').then((res) => {
41       res.service.vidNotions.instantiationType = 'ALaCarte';
42       jsonBuilderAndMock.basicJson(
43         res,
44         Cypress.config('baseUrl') + "/rest/models/services/6b528779-44a3-4472-bdff-9cd15ec93450",
45         200,
46         0,
47         "ecompNamingFalseModel",
48       )
49     });
50
51     cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/getServiceInstanceTopologyResult.json').then((res) => {
52       res.networks = {};
53       res.isALaCarte = true;
54       res.instanceId = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
55
56       const vnf = res.vnfs['2017-488_PASQUALE-vPE 0'];
57       vnf.instanceId = "VNF_INSTANCE_ID";
58       vnf.vfModules['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0']['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot'].instanceId = "VF_MODULE_BASE_INSTANCE_ID";
59       vnf.vfModules['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1']['2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc'].instanceId = "VF_MODULE_INSTANCE_ID";
60
61       jsonBuilderAndMock.basicJson(
62         res,
63         Cypress.config('baseUrl') + "/aai_get_service_instance_topology/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
64         200, 0,
65         "initServiceInstanceTopology",
66       )
67     });
68
69     cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
70
71     // add a vnf on update mode
72     cy.drawingBoardPressAddButtonByElementName('node-2017-388_PASQUALE-vPE 0').click({force: true});
73     cy.selectDropdownOptionByText('rollback', 'Rollback');
74     cy.fillVnfPopup();
75
76     // delete VNF
77     cy.drawingBoardTreeOpenContextMenuByElementDataTestId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0', 0)
78       .drawingBoardTreeClickOnContextMenuOptionByName('Delete');
79
80     // update service
81     cy.getDrawingBoardDeployBtn().click();
82
83     cy.getReduxState().then((state) => {
84       const vnf = state.service.serviceInstance[SERVICE_MODEL_ID].vnfs["2017-388_PASQUALE-vPE 0_1"];
85       cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
86         cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/vidRequestDelete1Create1Vnf.json').then((expectedResult) => {
87           expectedResult.vnfs["2017-388_PASQUALE-vPE 0_1"].trackById = vnf.trackById;
88           cy.deepCompare(expectedResult, xhr.request.body);
89         });
90       });
91     });
92   });
93
94 });