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