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 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
31 cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
32 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
35 it('Given a template - User can remove existing VNF', () => {
37 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
39 removeVNFWithVFModules('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0');
40 removeVNFWithVFModules('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0');
42 cy.getDrawingBoardDeployBtn().click();
43 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
44 cy.deepCompare(bodyOf(xhr).vnfs, {});
49 it('Given a template - User can add new VNF', () => {
50 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
52 addNewNode('node-vProbe_NC_VNF 0-add-btn')
54 .getDrawingBoardDeployBtn().click()
55 .wait('@expectedPostAsyncInstantiation').then(xhr => {
56 const vnfRequest = bodyOf(xhr).vnfs['vProbe_NC_VNF 0_2'];
58 expect(vnfRequest.action).equals("Create");
59 expect(vnfRequest.rollbackOnFailure).equals("true");
60 expect(vnfRequest.originalName).equals("vProbe_NC_VNF 0");
61 expect(vnfRequest.productFamilyId).equals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
62 expect(vnfRequest.lcpCloudRegionId).equals("hvf6");
63 expect(vnfRequest.lineOfBusiness).equals("zzz1");
64 expect(vnfRequest.platformName).equals("xxx1");
65 expect(vnfRequest.tenantId).equals("229bcdc6eaeb4ca59d55221141d01f8e");
68 // check instance name not change if empty
69 cy.editNode('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 0)
70 .clearInput('instanceName');
71 cy.getElementByDataTestsId('form-set').click({force: true}).then((done) => {
72 cy.editNode('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 0)
73 .getElementByDataTestsId('instanceName').should('be.empty')
78 it('Given a template - User can Duplicate VNF', () => {
79 const numberOfDuplicate: number = 4;
80 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
81 cy.nodeAction('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 'Duplicate')
82 .getElementByDataTestsId('duplicate-amount-vfmodules').select(numberOfDuplicate.toString())
83 .getTagElementContainsText('button', 'Duplicate').click()
84 .getDrawingBoardDeployBtn().click()
85 .wait('@expectedPostAsyncInstantiation').then(xhr => {
86 expect(Object.keys(bodyOf(xhr).vnfs).length).equals(numberOfDuplicate + 2);
90 it('Given a stored template - when "edit" vnf and vfmodules are opened - then template’s details are visible as expected and deploy without changes', () => {
92 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
95 cy.editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
96 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007')
97 .getElementByDataTestsId("productFamily").should('contain', 'Emanuel')
98 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
99 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
100 .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1')
101 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
102 .checkPlatformValue('xxx1')
103 .getElementByDataTestsId("cancelButton").click();
105 cy.editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0")
106 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01')
107 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
108 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
109 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
110 .getElementByDataTestsId("cancelButton").click();
112 cy.editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1")
113 .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01')
114 .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol')
115 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
116 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
117 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
118 .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on')
119 .getElementByDataTestsId("cancelButton").click();
121 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([
122 {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect
123 {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"},
127 it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`, function () {
129 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
131 cy.openServiceContextMenu()
132 .getElementByDataTestsId("context-menu-header-edit-item").click()
133 .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI')
134 .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS')
135 .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA')
136 .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland')
137 .getElementByDataTestsId("project").should('contain', 'WATKINS')
138 .getElementByDataTestsId("rollback").should('contain', 'Rollback');
142 it(`Given a stored template - add one VfModule, edit its details, and deploy - deploy is added with the vfModule details`, () => {
143 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
145 let newVfModuleName = "new.vfmodule.name";
146 let module1ModelId = "VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1";
147 let module1CustomizationId = `vprobe_nc_vnf0..${module1ModelId}`;
149 // Click target VNF on right tree
150 cy.getElementByDataTestsId('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0').first().click();
152 // Click [+] vfModule on left tree
153 cy.drawingBoardPressAddButtonByElementName(`node-${module1CustomizationId}`)
154 .click({force: true});
156 cy.editNode(`node-c09e4530-8fd8-418f-9483-2f57ce927b05-${module1CustomizationId}`, 1);
157 cy.clearInput("instanceName");
158 cy.typeToInput("instanceName", newVfModuleName);
159 cy.selectDropdownOptionByText('lcpRegion', 'hvf6');
160 cy.selectDropdownOptionByText('tenant', 'DN5242-Nov21-T1');
161 cy.getElementByDataTestsId('form-set').click();
164 cy.getReduxState().then((state) => {
165 let vfModules_1Path = [
166 ...vnfPath, "vfModules", module1CustomizationId,
169 let serviceInstanceElementOnRedux = state.service.serviceInstance[(templateWithVnfSetup.serviceModelId)];
170 let latestVfModule_1Path = findPathOfLatestVfModule(serviceInstanceElementOnRedux, vfModules_1Path);
172 // This is a funny merge, as values are already there, but that way ensures
173 // the values that selected are really deployed, while limiting the cost of
174 // maintenance, by taking other vfModule's fields as granted.
175 let latestVfModule_1ExpectedValue = _.merge(
176 _.get(serviceInstanceElementOnRedux, latestVfModule_1Path),
178 instanceName: newVfModuleName,
179 volumeGroupName: `${newVfModuleName}_vol`,
180 lcpCloudRegionId: "hvf6",
181 tenantId: "4914ab0ab3a743e58f0eefdacc1dde77",
185 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([
186 {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect
187 {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"},
188 {path: ["existingNames", newVfModuleName], value: ""},
189 {path: ["existingNames", `${newVfModuleName}_vol`], value: ""},
190 {path: latestVfModule_1Path, value: latestVfModule_1ExpectedValue},
191 {path: ["validationCounter"], value: null}, // side-effect
197 it('Given a template - User can remove existing vfmodule', function () {
199 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
200 cy.nodeAction('node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1', 'Remove');
201 let removed_vfModule_Path = [
202 ...vnfPath, "vfModules",
203 "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1",
206 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([
207 {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect
208 {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"},
209 {path: [...removed_vfModule_Path], value: undefined},
214 {desc: "with changes", modifySomeValues: true},
215 {desc: "without changes", modifySomeValues: false},
216 ].forEach((testCase) => {
218 it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () {
220 cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup);
223 cy.openServiceContextMenu();
224 cy.getElementByDataTestsId("context-menu-header-edit-item").click();
225 if (testCase.modifySomeValues) {
226 cy.clearInput("instanceName");
227 cy.typeToInput("instanceName", "different.instance.name");
229 cy.getElementByDataTestsId('form-set').click();
232 cy.editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0");
233 if (testCase.modifySomeValues) {
234 cy.selectPlatformValue('platform');
235 cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909");
237 cy.getElementByDataTestsId('form-set').click();
240 cy.editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0");
241 if (testCase.modifySomeValues) {
242 cy.getElementByDataTestsId('sdncPreLoad').click();
244 cy.getElementByDataTestsId('form-set').click();
247 let vfModule_0Path = [
248 ...vnfPath, "vfModules",
249 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0",
250 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg",
253 assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [
254 {path: ["instanceName"], value: "different.instance.name"},
255 {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined},
256 {path: ["existingNames", "different.instance.name"], value: ""},
258 {path: [...vnfPath, "platformName"], value: "xxx1,platform"},
259 {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"},
261 {path: [...vfModule_0Path, "sdncPreLoad"], value: true},
267 it(`Given a stored template of Network - - it is loaded`, () => {
269 cy.loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup);
272 cy.getElementByDataTestsId("node-SR-IOV Provider 2-1").should('be.visible');
273 cy.getElementByDataTestsId("node-SR-IOV Provider 2-2").should('be.visible');
274 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network();
277 it(`Given a stored template of Network - User can remove existing network`, () => {
279 cy.loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup);
281 cy.nodeAction('node-01f4c475-3f89-4f00-a2f4-39a873dba0ae-SR-IOV Provider 2-1', 'Remove');
282 let removed_network_Path = [
283 "networks", "SR-IOV Provider 2-1",
286 let removed_network_counter_Path = [
287 "existingNetworksCounterMap", "f6b6d141-0d4c-427d-ad35-797f3d1abe71",
290 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network([
291 {path: removed_network_Path, value: undefined},
292 {path: removed_network_counter_Path, value: 0},
296 it('Given a template - User can add a new network', () => {
298 cy.loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup);
301 addNewNode('node-SR-IOV Provider 2-1-add-btn')
303 .getDrawingBoardDeployBtn().click()
304 .wait('@expectedPostAsyncInstantiation').then(xhr => {
305 const networkRequest = bodyOf(xhr).networks['SR-IOV Provider 2-1_1'];
307 expect(networkRequest.action).equals("Create");
308 expect(networkRequest.rollbackOnFailure).equals("true");
309 expect(networkRequest.originalName).equals("SR-IOV Provider 2-1");
310 expect(networkRequest.productFamilyId).equals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
311 expect(networkRequest.lcpCloudRegionId).equals("hvf6");
312 expect(networkRequest.lineOfBusiness).equals("zzz1");
313 expect(networkRequest.platformName).equals("xxx1");
314 expect(networkRequest.tenantId).equals("229bcdc6eaeb4ca59d55221141d01f8e");
321 let apiTestResources = '../vid-automation/src/test/resources/asyncInstantiation/';
323 const templateWithVnfSetup = {
324 serviceModelId: '6cfeeb18-c2b0-49df-987a-da47493c8e38',
325 instanceTemplateFile: apiTestResources + 'templates__instance_template.json',
326 instanceTemplateSetWithoutModifyFile: apiTestResources + 'templates__instance_from_template__set_without_modify1.json',
327 serviceModelFile: '../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json',
330 const templateWithNetworkSetup = {
331 serviceModelId: 'a1a14610-ee40-4049-8007-0608a20dd1fa',
332 instanceTemplateFile: apiTestResources + 'templates__instance_template_network.json',
333 serviceModelFile: '../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model_network.json',
337 "vnfs", "vProbe_NC_VNF 0"
341 "vnfs", "vProbe_NC_VNF 0_1"
346 function addNewNode(dataTestId: string) {
347 return cy.getElementByDataTestsId(dataTestId).click({force: true})
350 function removeVNFWithVFModules(dataTestId: string) {
351 return cy.nodeAction(dataTestId, 'Remove')
352 .getTagElementContainsText('button', 'Remove VNF').click()
355 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
356 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(templateWithVnfSetup.instanceTemplateFile, deviationFromExpected);
359 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
360 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(templateWithNetworkSetup.instanceTemplateFile, deviationFromExpected);
363 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(filePathOfExpected: string, deviationFromExpected: { path: PropertyPath; value: any }[]) {
364 cy.getDrawingBoardDeployBtn().click();
365 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
366 cy.readFile(filePathOfExpected).then((expectedResult) => {
367 convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
369 let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
370 setDeviationInExpected(expectedResult, deviationFromExpected);
371 cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
377 function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
378 cy.getDrawingBoardDeployBtn().click();
379 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
381 cy.readFile(templateWithVnfSetup.instanceTemplateSetWithoutModifyFile).then((expectedResult) => {
382 setDeviationInExpected(expectedResult, deviationFromExpected);
383 cy.deepCompare(xhr.request.body, expectedResult);
389 function bodyOf(xhr: Cypress.WaitXHR) {
390 return JSON.parse(JSON.stringify(xhr.request.body));
393 function setDeviationInExpected(expectedResult: any, deviations: { path: PropertyPath; value: any }[]) {
394 for (const deviation of deviations) {
395 _.set(expectedResult, deviation.path, deviation.value);
399 function findPathOfLatestVfModule(serviceInstanceElementFromRedux: any, vfModulesContainerPath: string[]) {
400 let latestVfModuleRandomlySelectedKey: string = _.last(_.keys(
401 _.get(serviceInstanceElementFromRedux, vfModulesContainerPath)
404 return [...vfModulesContainerPath, latestVfModuleRandomlySelectedKey];
407 //We use this function because the deployService() on drawing-board-header.component class
408 // changes rollbackOnFailure value from string type to boolean.
409 function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
410 expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
413 function removeIsDirtyFieldFromXhrRequestBody(xhr: any) {
414 let xhrTempBody = bodyOf(xhr);
415 delete xhrTempBody.isDirty;
419 function mockAsyncBulkResponse() {
421 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
425 }).as("expectedPostAsyncInstantiation");