Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 1 | import * as _ from "lodash"; |
| 2 | import {PropertyPath} from "lodash"; |
| 3 | |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 4 | describe('Drawing Board: Instantiation Templates', function () { |
| 5 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 6 | describe('Instantiation templates ', () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 7 | |
| 8 | beforeEach(() => { |
| 9 | cy.clearSessionStorage(); |
Ittay Stern | 4bfa2df | 2019-12-17 14:55:04 +0200 | [diff] [blame] | 10 | cy.setTestApiParamToGR(); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 11 | cy.initAAIMock(); |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 12 | cy.initGetAAISubDetails(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 13 | cy.initVidMock(); |
| 14 | cy.initDrawingBoardUserPermission(); |
| 15 | cy.login(); |
| 16 | |
| 17 | mockAsyncBulkResponse(); |
| 18 | }); |
| 19 | |
| 20 | afterEach(() => { |
| 21 | cy.screenshot(); |
| 22 | }); |
| 23 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 24 | describe('Load Page and Deploy', () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 25 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 26 | it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 27 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 28 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 29 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 30 | // Then... |
| 31 | cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible'); |
| 32 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(); |
| 33 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 34 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 35 | it('Given a template - User can remove existing VNF', () => { |
| 36 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 37 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 38 | |
| 39 | removeVNFWithVFModules('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0'); |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 40 | removeVNFWithVFModules('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0'); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 41 | |
| 42 | cy.getDrawingBoardDeployBtn().click(); |
| 43 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 44 | cy.deepCompare(bodyOf(xhr).vnfs, {}); |
| 45 | }); |
| 46 | |
| 47 | }); |
| 48 | |
| 49 | it('Given a template - User can add new VNF', () => { |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 50 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 51 | // add new node |
| 52 | addNewNode('node-vProbe_NC_VNF 0-add-btn') |
| 53 | .fillVnfPopup() |
| 54 | .getDrawingBoardDeployBtn().click() |
| 55 | .wait('@expectedPostAsyncInstantiation').then(xhr => { |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 56 | const vnfRequest = bodyOf(xhr).vnfs['vProbe_NC_VNF 0_2']; |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 57 | |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 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"); |
| 66 | |
| 67 | |
| 68 | // check instance name not change if empty |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 69 | cy.editNode('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 0) |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 70 | .clearInput('instanceName'); |
| 71 | cy.getElementByDataTestsId('form-set').click({force: true}).then((done) => { |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 72 | cy.editNode('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 0) |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 73 | .getElementByDataTestsId('instanceName').should('be.empty') |
| 74 | }); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 75 | }); |
| 76 | }); |
| 77 | |
| 78 | it('Given a template - User can Duplicate VNF', () => { |
| 79 | const numberOfDuplicate: number = 4; |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 80 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
| 81 | cy.nodeAction('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 'Duplicate') |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 82 | .getElementByDataTestsId('duplicate-amount-vfmodules').select(numberOfDuplicate.toString()) |
| 83 | .getTagElementContainsText('button', 'Duplicate').click() |
| 84 | .getDrawingBoardDeployBtn().click() |
| 85 | .wait('@expectedPostAsyncInstantiation').then(xhr => { |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 86 | expect(Object.keys(bodyOf(xhr).vnfs).length).equals(numberOfDuplicate + 2); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 87 | }); |
| 88 | }); |
| 89 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 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', () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 91 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 92 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 93 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 94 | // Then... |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 95 | cy.editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 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') |
Einat Vinouze | 06f5324 | 2020-03-16 19:08:22 +0200 | [diff] [blame] | 102 | cy.checkPlatformValue(`xxx1`) |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 103 | .getElementByDataTestsId("cancelButton").click(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 104 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 105 | cy.editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0") |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 106 | .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01') |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 107 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
| 108 | .getElementByDataTestsId("cancelButton").click(); |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 109 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 110 | cy.editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1") |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 111 | .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01') |
| 112 | .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol') |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 113 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
| 114 | .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on') |
| 115 | .getElementByDataTestsId("cancelButton").click(); |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 116 | |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 117 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([ |
| 118 | {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 119 | {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"}, |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 120 | ]); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 121 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 122 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 123 | it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`, function () { |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 124 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 125 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 126 | |
| 127 | cy.openServiceContextMenu() |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 128 | .getElementByDataTestsId("context-menu-header-edit-item").click() |
| 129 | .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI') |
| 130 | .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS') |
| 131 | .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA') |
| 132 | .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland') |
| 133 | .getElementByDataTestsId("project").should('contain', 'WATKINS') |
| 134 | .getElementByDataTestsId("rollback").should('contain', 'Rollback'); |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 135 | |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 136 | }); |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 137 | |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 138 | it(`Given a stored template - add one VfModule, edit its details, and deploy - deploy is added with the vfModule details`, () => { |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 139 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 140 | |
| 141 | let newVfModuleName = "new.vfmodule.name"; |
| 142 | let module1ModelId = "VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1"; |
| 143 | let module1CustomizationId = `vprobe_nc_vnf0..${module1ModelId}`; |
| 144 | |
| 145 | // Click target VNF on right tree |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 146 | cy.getElementByDataTestsId('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0').first().click(); |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 147 | |
| 148 | // Click [+] vfModule on left tree |
| 149 | cy.drawingBoardPressAddButtonByElementName(`node-${module1CustomizationId}`) |
| 150 | .click({force: true}); |
| 151 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 152 | cy.editNode(`node-c09e4530-8fd8-418f-9483-2f57ce927b05-${module1CustomizationId}`, 1); |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 153 | cy.clearInput("instanceName"); |
| 154 | cy.typeToInput("instanceName", newVfModuleName); |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 155 | cy.getElementByDataTestsId('form-set').click(); |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 156 | |
| 157 | // Then... |
| 158 | cy.getReduxState().then((state) => { |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 159 | let vfModules_1Path = [ |
| 160 | ...vnfPath, "vfModules", module1CustomizationId, |
| 161 | ]; |
| 162 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 163 | let serviceInstanceElementOnRedux = state.service.serviceInstance[(templateWithVnfSetup.serviceModelId)]; |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 164 | let latestVfModule_1Path = findPathOfLatestVfModule(serviceInstanceElementOnRedux, vfModules_1Path); |
| 165 | |
| 166 | // This is a funny merge, as values are already there, but that way ensures |
| 167 | // the values that selected are really deployed, while limiting the cost of |
| 168 | // maintenance, by taking other vfModule's fields as granted. |
| 169 | let latestVfModule_1ExpectedValue = _.merge( |
| 170 | _.get(serviceInstanceElementOnRedux, latestVfModule_1Path), |
| 171 | { |
| 172 | instanceName: newVfModuleName, |
| 173 | volumeGroupName: `${newVfModuleName}_vol`, |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 174 | } |
| 175 | ); |
| 176 | |
| 177 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([ |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 178 | {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 179 | {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"}, |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 180 | {path: ["existingNames", newVfModuleName], value: ""}, |
| 181 | {path: ["existingNames", `${newVfModuleName}_vol`], value: ""}, |
| 182 | {path: latestVfModule_1Path, value: latestVfModule_1ExpectedValue}, |
| 183 | {path: ["validationCounter"], value: null}, // side-effect |
| 184 | ]); |
| 185 | }); |
| 186 | |
| 187 | }); |
| 188 | |
Einat Vinouze | a79e4e0 | 2019-12-31 15:33:03 +0200 | [diff] [blame] | 189 | it('Given a template - User can remove existing vfmodule', function () { |
| 190 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 191 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
| 192 | cy.nodeAction('node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1', 'Remove'); |
Einat Vinouze | a79e4e0 | 2019-12-31 15:33:03 +0200 | [diff] [blame] | 193 | let removed_vfModule_Path = [ |
| 194 | ...vnfPath, "vfModules", |
| 195 | "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1", |
| 196 | ]; |
| 197 | |
| 198 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([ |
| 199 | {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 200 | {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"}, |
Einat Vinouze | a79e4e0 | 2019-12-31 15:33:03 +0200 | [diff] [blame] | 201 | {path: [...removed_vfModule_Path], value: undefined}, |
| 202 | ]); |
| 203 | }); |
| 204 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 205 | [ |
| 206 | {desc: "with changes", modifySomeValues: true}, |
| 207 | {desc: "without changes", modifySomeValues: false}, |
| 208 | ].forEach((testCase) => { |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 209 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 210 | it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () { |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 211 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 212 | cy.loadDrawingBoardWithRecreateMode(templateWithVnfSetup); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 213 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 214 | //edit service |
| 215 | cy.openServiceContextMenu(); |
| 216 | cy.getElementByDataTestsId("context-menu-header-edit-item").click(); |
| 217 | if (testCase.modifySomeValues) { |
| 218 | cy.clearInput("instanceName"); |
| 219 | cy.typeToInput("instanceName", "different.instance.name"); |
| 220 | } |
| 221 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 222 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 223 | // edit vnf |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 224 | cy.editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0"); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 225 | if (testCase.modifySomeValues) { |
Einat Vinouze | 06f5324 | 2020-03-16 19:08:22 +0200 | [diff] [blame] | 226 | cy.selectPlatformValue(`platform`); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 227 | cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909"); |
| 228 | } |
| 229 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 230 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 231 | //edit vf module |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 232 | cy.editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0"); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 233 | if (testCase.modifySomeValues) { |
| 234 | cy.getElementByDataTestsId('sdncPreLoad').click(); |
| 235 | } |
| 236 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 237 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 238 | // Then... |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 239 | let vfModule_0Path = [ |
| 240 | ...vnfPath, "vfModules", |
| 241 | "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0", |
| 242 | "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg", |
| 243 | ]; |
| 244 | |
| 245 | assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [ |
| 246 | {path: ["instanceName"], value: "different.instance.name"}, |
| 247 | {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined}, |
| 248 | {path: ["existingNames", "different.instance.name"], value: ""}, |
| 249 | |
| 250 | {path: [...vnfPath, "platformName"], value: "xxx1,platform"}, |
| 251 | {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"}, |
| 252 | |
| 253 | {path: [...vfModule_0Path, "sdncPreLoad"], value: true}, |
| 254 | ] : []); |
| 255 | }) |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 256 | |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 257 | }); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 258 | |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 259 | it(`Given a stored template of Network - - it is loaded`, () => { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 260 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 261 | cy.loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup); |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 262 | |
| 263 | // Then... |
| 264 | cy.getElementByDataTestsId("node-SR-IOV Provider 2-1").should('be.visible'); |
| 265 | cy.getElementByDataTestsId("node-SR-IOV Provider 2-2").should('be.visible'); |
| 266 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network(); |
| 267 | }); |
| 268 | |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 269 | it(`Given a stored template of Network - User can remove existing network`, () => { |
Einat Vinouze | 6e55393 | 2020-01-01 13:40:56 +0200 | [diff] [blame] | 270 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 271 | cy.loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup); |
Einat Vinouze | 6e55393 | 2020-01-01 13:40:56 +0200 | [diff] [blame] | 272 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 273 | cy.nodeAction('node-01f4c475-3f89-4f00-a2f4-39a873dba0ae-SR-IOV Provider 2-1', 'Remove'); |
Einat Vinouze | 6e55393 | 2020-01-01 13:40:56 +0200 | [diff] [blame] | 274 | let removed_network_Path = [ |
| 275 | "networks", "SR-IOV Provider 2-1", |
| 276 | ]; |
| 277 | |
| 278 | let removed_network_counter_Path = [ |
| 279 | "existingNetworksCounterMap", "f6b6d141-0d4c-427d-ad35-797f3d1abe71", |
| 280 | ]; |
| 281 | |
| 282 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network([ |
| 283 | {path: removed_network_Path, value: undefined}, |
| 284 | {path: removed_network_counter_Path, value: 0}, |
| 285 | ]); |
| 286 | }); |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 287 | |
Einat Vinouze | 83dceaa | 2020-01-02 10:42:19 +0200 | [diff] [blame] | 288 | it('Given a template - User can add a new network', () => { |
| 289 | |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 290 | cy.loadDrawingBoardWithRecreateModeNetwork(templateWithNetworkSetup); |
Einat Vinouze | 83dceaa | 2020-01-02 10:42:19 +0200 | [diff] [blame] | 291 | |
| 292 | // add new node |
| 293 | addNewNode('node-SR-IOV Provider 2-1-add-btn') |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 294 | .fillNetworkPopup() |
| 295 | .getDrawingBoardDeployBtn().click() |
| 296 | .wait('@expectedPostAsyncInstantiation').then(xhr => { |
Einat Vinouze | 83dceaa | 2020-01-02 10:42:19 +0200 | [diff] [blame] | 297 | const networkRequest = bodyOf(xhr).networks['SR-IOV Provider 2-1_1']; |
| 298 | |
| 299 | expect(networkRequest.action).equals("Create"); |
| 300 | expect(networkRequest.rollbackOnFailure).equals("true"); |
| 301 | expect(networkRequest.originalName).equals("SR-IOV Provider 2-1"); |
| 302 | expect(networkRequest.productFamilyId).equals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); |
| 303 | expect(networkRequest.lcpCloudRegionId).equals("hvf6"); |
| 304 | expect(networkRequest.lineOfBusiness).equals("zzz1"); |
| 305 | expect(networkRequest.platformName).equals("xxx1"); |
| 306 | expect(networkRequest.tenantId).equals("229bcdc6eaeb4ca59d55221141d01f8e"); |
| 307 | }); |
| 308 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 309 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 310 | }); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 311 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 312 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 313 | let apiTestResources = '../vid-automation/src/test/resources/asyncInstantiation/'; |
| 314 | |
| 315 | const templateWithVnfSetup = { |
| 316 | serviceModelId: '6cfeeb18-c2b0-49df-987a-da47493c8e38', |
| 317 | instanceTemplateFile: apiTestResources + 'templates__instance_template.json', |
| 318 | instanceTemplateSetWithoutModifyFile: apiTestResources + 'templates__instance_from_template__set_without_modify1.json', |
| 319 | serviceModelFile: '../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json', |
| 320 | }; |
| 321 | |
| 322 | const templateWithNetworkSetup = { |
| 323 | serviceModelId: 'a1a14610-ee40-4049-8007-0608a20dd1fa', |
| 324 | instanceTemplateFile: apiTestResources + 'templates__instance_template_network.json', |
| 325 | serviceModelFile: '../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model_network.json', |
| 326 | }; |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 327 | |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 328 | const vnfPath = [ |
| 329 | "vnfs", "vProbe_NC_VNF 0" |
| 330 | ]; |
| 331 | |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame] | 332 | const vnfPath2 = [ |
| 333 | "vnfs", "vProbe_NC_VNF 0_1" |
| 334 | ]; |
| 335 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 336 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 337 | |
| 338 | function addNewNode(dataTestId: string) { |
| 339 | return cy.getElementByDataTestsId(dataTestId).click({force: true}) |
| 340 | } |
| 341 | |
| 342 | function removeVNFWithVFModules(dataTestId: string) { |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 343 | return cy.nodeAction(dataTestId, 'Remove') |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 344 | .getTagElementContainsText('button', 'Remove VNF').click() |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 345 | } |
| 346 | |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 347 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 348 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(templateWithVnfSetup.instanceTemplateFile, deviationFromExpected); |
| 349 | } |
| 350 | |
| 351 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
| 352 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(templateWithNetworkSetup.instanceTemplateFile, deviationFromExpected); |
| 353 | } |
| 354 | |
| 355 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(filePathOfExpected: string, deviationFromExpected: { path: PropertyPath; value: any }[]) { |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 356 | cy.getDrawingBoardDeployBtn().click(); |
| 357 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 358 | cy.readFile(filePathOfExpected).then((expectedResult) => { |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 359 | convertRollbackOnFailureValueFromStringToBoolean(expectedResult); |
| 360 | |
| 361 | let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr); |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 362 | setDeviationInExpected(expectedResult, deviationFromExpected); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 363 | cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult); |
| 364 | }); |
| 365 | }); |
| 366 | } |
| 367 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 368 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 369 | function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 370 | cy.getDrawingBoardDeployBtn().click(); |
| 371 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 372 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 373 | cy.readFile(templateWithVnfSetup.instanceTemplateSetWithoutModifyFile).then((expectedResult) => { |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 374 | setDeviationInExpected(expectedResult, deviationFromExpected); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 375 | cy.deepCompare(xhr.request.body, expectedResult); |
| 376 | }); |
| 377 | |
| 378 | }); |
| 379 | } |
| 380 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 381 | function bodyOf(xhr: Cypress.WaitXHR) { |
| 382 | return JSON.parse(JSON.stringify(xhr.request.body)); |
| 383 | } |
| 384 | |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 385 | function setDeviationInExpected(expectedResult: any, deviations: { path: PropertyPath; value: any }[]) { |
| 386 | for (const deviation of deviations) { |
| 387 | _.set(expectedResult, deviation.path, deviation.value); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 391 | function findPathOfLatestVfModule(serviceInstanceElementFromRedux: any, vfModulesContainerPath: string[]) { |
| 392 | let latestVfModuleRandomlySelectedKey: string = _.last(_.keys( |
| 393 | _.get(serviceInstanceElementFromRedux, vfModulesContainerPath) |
| 394 | )) as string; |
| 395 | |
| 396 | return [...vfModulesContainerPath, latestVfModuleRandomlySelectedKey]; |
| 397 | } |
| 398 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 399 | //We use this function because the deployService() on drawing-board-header.component class |
| 400 | // changes rollbackOnFailure value from string type to boolean. |
| 401 | function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) { |
| 402 | expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure); |
| 403 | } |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 404 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 405 | function removeIsDirtyFieldFromXhrRequestBody(xhr: any) { |
| 406 | let xhrTempBody = bodyOf(xhr); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 407 | delete xhrTempBody.isDirty; |
| 408 | return xhrTempBody; |
| 409 | } |
| 410 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 411 | function mockAsyncBulkResponse() { |
| 412 | cy.server().route({ |
| 413 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 414 | method: 'POST', |
| 415 | status: 200, |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 416 | response: true, |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 417 | }).as("expectedPostAsyncInstantiation"); |
| 418 | } |
Yoav Schneiderman | 3f216a5 | 2020-01-22 11:07:00 +0200 | [diff] [blame] | 419 | |