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([
67 {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect
71 it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`, function () {
73 loadDrawingBoardWithRecreateMode();
75 cy.openServiceContextMenu()
76 .getElementByDataTestsId("context-menu-header-edit-item").click()
77 .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI')
78 .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS')
79 .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA')
80 .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland')
81 .getElementByDataTestsId("project").should('contain', 'WATKINS')
82 .getElementByDataTestsId("rollback").should('contain', 'Rollback');
86 it(`Given a stored template - add one VfModule, edit its details, and deploy - deploy is added with the vfModule details`, () => {
87 loadDrawingBoardWithRecreateMode();
89 let newVfModuleName = "new.vfmodule.name";
90 let module1ModelId = "VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1";
91 let module1CustomizationId = `vprobe_nc_vnf0..${module1ModelId}`;
93 // Click target VNF on right tree
94 cy.getElementByDataTestsId('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0').click();
96 // Click [+] vfModule on left tree
97 cy.drawingBoardPressAddButtonByElementName(`node-${module1CustomizationId}`)
98 .click({force: true});
100 editNode(`node-c09e4530-8fd8-418f-9483-2f57ce927b05-${module1CustomizationId}`, 1);
101 cy.clearInput("instanceName");
102 cy.typeToInput("instanceName", newVfModuleName);
103 cy.selectDropdownOptionByText('lcpRegion', 'hvf6');
104 cy.selectDropdownOptionByText('tenant', 'DN5242-Nov21-T1');
105 cy.getElementByDataTestsId('form-set').click();
108 cy.getReduxState().then((state) => {
109 let vfModules_1Path = [
110 ...vnfPath, "vfModules", module1CustomizationId,
113 let serviceInstanceElementOnRedux = state.service.serviceInstance[serviceModelId];
114 let latestVfModule_1Path = findPathOfLatestVfModule(serviceInstanceElementOnRedux, vfModules_1Path);
116 // This is a funny merge, as values are already there, but that way ensures
117 // the values that selected are really deployed, while limiting the cost of
118 // maintenance, by taking other vfModule's fields as granted.
119 let latestVfModule_1ExpectedValue = _.merge(
120 _.get(serviceInstanceElementOnRedux, latestVfModule_1Path),
122 instanceName: newVfModuleName,
123 volumeGroupName: `${newVfModuleName}_vol`,
124 lcpCloudRegionId: "hvf6",
125 tenantId: "4914ab0ab3a743e58f0eefdacc1dde77",
129 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([
130 {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect
131 {path: ["existingNames", newVfModuleName], value: ""},
132 {path: ["existingNames", `${newVfModuleName}_vol`], value: ""},
133 {path: latestVfModule_1Path, value: latestVfModule_1ExpectedValue},
134 {path: ["validationCounter"], value: null}, // side-effect
141 {desc: "with changes", modifySomeValues: true},
142 {desc: "without changes", modifySomeValues: false},
143 ].forEach((testCase) => {
145 it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () {
147 loadDrawingBoardWithRecreateMode();
150 cy.openServiceContextMenu();
151 cy.getElementByDataTestsId("context-menu-header-edit-item").click();
152 if (testCase.modifySomeValues) {
153 cy.clearInput("instanceName");
154 cy.typeToInput("instanceName", "different.instance.name");
156 cy.getElementByDataTestsId('form-set').click();
159 editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0");
160 if (testCase.modifySomeValues) {
161 cy.selectPlatformValue('platform');
162 cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909");
164 cy.getElementByDataTestsId('form-set').click();
167 editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0");
168 if (testCase.modifySomeValues) {
169 cy.getElementByDataTestsId('sdncPreLoad').click();
171 cy.getElementByDataTestsId('form-set').click();
174 let vfModule_0Path = [
175 ...vnfPath, "vfModules",
176 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0",
177 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg",
180 assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [
181 {path: ["instanceName"], value: "different.instance.name"},
182 {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined},
183 {path: ["existingNames", "different.instance.name"], value: ""},
185 {path: [...vnfPath, "platformName"], value: "xxx1,platform"},
186 {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"},
188 {path: [...vfModule_0Path, "sdncPreLoad"], value: true},
198 const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
201 "vnfs", "vProbe_NC_VNF 0"
204 function loadDrawingBoardWithRecreateMode() {
205 const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
207 const drawingBoardAction = `RECREATE`;
208 const templateTopologyEndpoint = "templateTopology";
209 cy.route(`**/rest/models/services/${serviceModelId}`,
210 'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
213 cy.route(`**/instantiationTemplates/${templateTopologyEndpoint}/${templateUuid}`,
214 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
215 .as('templateTopology');
219 cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
220 `?jobId=${templateUuid}` +
221 `&serviceModelId=${serviceModelId}`);
223 cy.wait('@serviceModel');
224 cy.wait('@templateTopology');
227 function editNode(dataTestId: string, index ?: number) {
228 return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId, index)
229 .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
232 function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
233 cy.getDrawingBoardDeployBtn().click();
234 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
235 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
236 convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
238 let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
239 setDeviationInExpected(expectedResult, deviationFromExpected);
240 cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
246 function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
247 cy.getDrawingBoardDeployBtn().click();
248 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
250 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => {
251 setDeviationInExpected(expectedResult, deviationFromExpected);
252 cy.deepCompare(xhr.request.body, expectedResult);
258 function setDeviationInExpected(expectedResult: any, deviations: { path: PropertyPath; value: any }[]) {
259 for (const deviation of deviations) {
260 _.set(expectedResult, deviation.path, deviation.value);
264 function findPathOfLatestVfModule(serviceInstanceElementFromRedux: any, vfModulesContainerPath: string[]) {
265 let latestVfModuleRandomlySelectedKey: string = _.last(_.keys(
266 _.get(serviceInstanceElementFromRedux, vfModulesContainerPath)
269 return [...vfModulesContainerPath, latestVfModuleRandomlySelectedKey];
272 //We use this function because the deployService() on drawing-board-header.component class
273 // changes rollbackOnFailure value from string type to boolean.
274 function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
275 expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
278 function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
279 let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
280 delete xhrTempBody.isDirty;
284 function mockAsyncBulkResponse() {
286 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
290 }).as("expectedPostAsyncInstantiation");