Templates: show correct values of sdnc-preload, volume-group name
[vid.git] / vid-webpack-master / cypress / integration / iFrames / instantiation-templates.e2e.ts
1 describe('Drawing Board: Instantiation Templates', function () {
2
3   describe('Instantiation templates ', () => {
4
5     beforeEach(() => {
6       cy.clearSessionStorage();
7       cy.setTestApiParamToVNF();
8       cy.initAAIMock();
9       cy.initGetAAISubDetails();
10       cy.initVidMock();
11       cy.initDrawingBoardUserPermission();
12       cy.login();
13
14       mockAsyncBulkResponse();
15     });
16
17     afterEach(() => {
18       cy.screenshot();
19     });
20
21     describe('Load Page and Deploy', () => {
22
23       it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`,  () => {
24
25         loadDrawingBoardWithRecreateMode();
26
27         // Then...
28         cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
29         assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
30       });
31
32       it('Given a stored template - when "edit" vnf and vfmodules are opened - then template’s details are visible as expected', ()=> {
33
34         loadDrawingBoardWithRecreateMode();
35
36         // Then...
37         editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
38         .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007')
39         .getElementByDataTestsId("productFamily").should('contain', 'Emanuel')
40         .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
41         .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
42         .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1')
43         .getElementByDataTestsId("rollback").should('contain', 'Rollback')
44         .checkPlatformValue('xxx1')
45          .getElementByDataTestsId("cancelButton").click();
46
47         editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0")
48         .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01')
49         .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
50         .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
51         .getElementByDataTestsId("rollback").should('contain', 'Rollback')
52         .getElementByDataTestsId("cancelButton").click();
53
54         editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1")
55         .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01')
56         .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol')
57         .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
58         .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
59         .getElementByDataTestsId("rollback").should('contain', 'Rollback')
60         .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on')
61         .getElementByDataTestsId("cancelButton").click();
62
63
64
65         assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
66         });
67
68       it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`,  function ()  {
69
70         loadDrawingBoardWithRecreateMode();
71
72         cy.openServiceContextMenu()
73         .getElementByDataTestsId("context-menu-header-edit-item").click()
74         .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI')
75         .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS')
76         .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA')
77         .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland')
78         .getElementByDataTestsId("project").should('contain', 'WATKINS')
79         .getElementByDataTestsId("rollback").should('contain', 'Rollback');
80
81       });
82
83
84
85       });
86     });
87   });
88
89 function loadDrawingBoardWithRecreateMode() {
90   const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
91   const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
92
93   const drawingBoardAction = `RECREATE`;
94   const templateTopologyEndpoint = "templateTopology";
95   cy.route(`**/rest/models/services/${serviceModelId}`,
96     'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
97   .as('serviceModel');
98
99   cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
100     'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
101   .as('templateTopology');
102
103   // When...
104
105   cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
106     `?jobId=${templateUuid}` +
107     `&serviceModelId=${serviceModelId}`);
108
109   cy.wait('@serviceModel');
110   cy.wait('@templateTopology');
111 }
112
113 function editNode(dataTestId: string) {
114   return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId)
115     .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
116 }
117
118 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
119   cy.getDrawingBoardDeployBtn().click();
120   cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
121     cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
122       convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
123
124       let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
125       cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
126     });
127   });
128 }
129
130   //We use this function because the deployService() on drawing-board-header.component class
131   // changes rollbackOnFailure value from string type to boolean.
132   function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
133     expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
134   }
135
136 function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
137   let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
138   delete xhrTempBody.isDirty;
139   return xhrTempBody;
140 }
141
142   function mockAsyncBulkResponse() {
143     cy.server().route({
144       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
145       method: 'POST',
146       status: 200,
147       response: "[]",
148     }).as("expectedPostAsyncInstantiation");
149   }