1 import * as _ from "lodash";
2 import {PropertyPath} from "lodash";
4 describe('Drawing Board: Instantiation Templates', function () {
6 describe('Instantiation templates ', () => {
9 cy.clearSessionStorage();
10 cy.setTestApiParamToGR();
12 cy.initGetAAISubDetails();
14 cy.initDrawingBoardUserPermission();
17 mockAsyncBulkResponse();
24 describe('Load Page and Deploy', () => {
26 it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, () => {
28 loadDrawingBoardWithRecreateMode();
31 cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
32 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
35 it('Given a stored template - when "edit" vnf and vfmodules are opened - then template’s details are visible as expected and deploy without changes', () => {
37 loadDrawingBoardWithRecreateMode();
40 editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
41 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007')
42 .getElementByDataTestsId("productFamily").should('contain', 'Emanuel')
43 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
44 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
45 .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1')
46 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
47 .checkPlatformValue('xxx1')
48 .getElementByDataTestsId("cancelButton").click();
50 editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0")
51 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01')
52 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
53 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
54 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
55 .getElementByDataTestsId("cancelButton").click();
57 editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1")
58 .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01')
59 .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol')
60 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
61 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
62 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
63 .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on')
64 .getElementByDataTestsId("cancelButton").click();
66 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
69 it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`, function () {
71 loadDrawingBoardWithRecreateMode();
73 cy.openServiceContextMenu()
74 .getElementByDataTestsId("context-menu-header-edit-item").click()
75 .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI')
76 .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS')
77 .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA')
78 .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland')
79 .getElementByDataTestsId("project").should('contain', 'WATKINS')
80 .getElementByDataTestsId("rollback").should('contain', 'Rollback');
85 {desc: "with changes", modifySomeValues: true},
86 {desc: "without changes", modifySomeValues: false},
87 ].forEach((testCase) => {
89 it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () {
91 loadDrawingBoardWithRecreateMode();
94 cy.openServiceContextMenu();
95 cy.getElementByDataTestsId("context-menu-header-edit-item").click();
96 if (testCase.modifySomeValues) {
97 cy.clearInput("instanceName");
98 cy.typeToInput("instanceName", "different.instance.name");
100 cy.getElementByDataTestsId('form-set').click();
103 editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0");
104 if (testCase.modifySomeValues) {
105 cy.selectPlatformValue('platform');
106 cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909");
108 cy.getElementByDataTestsId('form-set').click();
111 editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0");
112 if (testCase.modifySomeValues) {
113 cy.getElementByDataTestsId('sdncPreLoad').click();
115 cy.getElementByDataTestsId('form-set').click();
119 "vnfs", "vProbe_NC_VNF 0"
121 let vfModule_0Path = [
122 ...vnfPath, "vfModules",
123 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0",
124 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg",
127 assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [
128 {path: ["instanceName"], value: "different.instance.name"},
129 {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined},
130 {path: ["existingNames", "different.instance.name"], value: ""},
132 {path: [...vnfPath, "platformName"], value: "xxx1,platform"},
133 {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"},
135 {path: [...vfModule_0Path, "sdncPreLoad"], value: true},
145 function loadDrawingBoardWithRecreateMode() {
146 const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
147 const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
149 const drawingBoardAction = `RECREATE`;
150 const templateTopologyEndpoint = "templateTopology";
151 cy.route(`**/rest/models/services/${serviceModelId}`,
152 'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
155 cy.route(`**/instantiationTemplates/${templateTopologyEndpoint}/${templateUuid}`,
156 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
157 .as('templateTopology');
161 cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
162 `?jobId=${templateUuid}` +
163 `&serviceModelId=${serviceModelId}`);
165 cy.wait('@serviceModel');
166 cy.wait('@templateTopology');
169 function editNode(dataTestId: string) {
170 return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId)
171 .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
174 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
175 cy.getDrawingBoardDeployBtn().click();
176 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
177 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
178 convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
180 let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
181 cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
187 function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
188 cy.getDrawingBoardDeployBtn().click();
189 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
191 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => {
192 setDeviationInExpected(expectedResult, deviationFromExpected);
193 cy.deepCompare(xhr.request.body, expectedResult);
199 function setDeviationInExpected(expectedResult: any, deviation: { path: PropertyPath; value: any }[]) {
200 for (const caveat of deviation) {
201 _.set(expectedResult, caveat.path, caveat.value);
205 //We use this function because the deployService() on drawing-board-header.component class
206 // changes rollbackOnFailure value from string type to boolean.
207 function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
208 expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
211 function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
212 let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
213 delete xhrTempBody.isDirty;
217 function mockAsyncBulkResponse() {
219 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
223 }).as("expectedPostAsyncInstantiation");