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 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 28 | loadDrawingBoardWithRecreateMode(); |
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 | |
| 37 | loadDrawingBoardWithRecreateMode(); |
| 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', () => { |
| 50 | loadDrawingBoardWithRecreateMode(); |
| 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 |
| 69 | 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 | editNode('node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0', 0) |
| 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; |
| 80 | loadDrawingBoardWithRecreateMode(); |
| 81 | 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 => { |
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 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 92 | loadDrawingBoardWithRecreateMode(); |
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... |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 95 | 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') |
| 102 | .checkPlatformValue('xxx1') |
| 103 | .getElementByDataTestsId("cancelButton").click(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 104 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 105 | 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') |
| 107 | .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') |
| 108 | .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') |
| 109 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
| 110 | .getElementByDataTestsId("cancelButton").click(); |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 111 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 112 | 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] | 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(); |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 120 | |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 121 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([ |
| 122 | {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame^] | 123 | {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"}, |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 124 | ]); |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 125 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 126 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 127 | 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] | 128 | |
| 129 | loadDrawingBoardWithRecreateMode(); |
| 130 | |
| 131 | cy.openServiceContextMenu() |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 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'); |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 139 | |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 140 | }); |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 141 | |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 142 | it(`Given a stored template - add one VfModule, edit its details, and deploy - deploy is added with the vfModule details`, () => { |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 143 | loadDrawingBoardWithRecreateMode(); |
| 144 | |
| 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}`; |
| 148 | |
| 149 | // Click target VNF on right tree |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame^] | 150 | 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] | 151 | |
| 152 | // Click [+] vfModule on left tree |
| 153 | cy.drawingBoardPressAddButtonByElementName(`node-${module1CustomizationId}`) |
| 154 | .click({force: true}); |
| 155 | |
| 156 | editNode(`node-c09e4530-8fd8-418f-9483-2f57ce927b05-${module1CustomizationId}`, 1); |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 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(); |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 162 | |
| 163 | // Then... |
| 164 | cy.getReduxState().then((state) => { |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 165 | let vfModules_1Path = [ |
| 166 | ...vnfPath, "vfModules", module1CustomizationId, |
| 167 | ]; |
| 168 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 169 | let serviceInstanceElementOnRedux = state.service.serviceInstance[(templateWithVnfSetup.serviceModelId)]; |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 170 | let latestVfModule_1Path = findPathOfLatestVfModule(serviceInstanceElementOnRedux, vfModules_1Path); |
| 171 | |
| 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), |
| 177 | { |
| 178 | instanceName: newVfModuleName, |
| 179 | volumeGroupName: `${newVfModuleName}_vol`, |
| 180 | lcpCloudRegionId: "hvf6", |
| 181 | tenantId: "4914ab0ab3a743e58f0eefdacc1dde77", |
| 182 | } |
| 183 | ); |
| 184 | |
| 185 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([ |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 186 | {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame^] | 187 | {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"}, |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 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 |
| 192 | ]); |
| 193 | }); |
| 194 | |
| 195 | }); |
| 196 | |
Einat Vinouze | a79e4e0 | 2019-12-31 15:33:03 +0200 | [diff] [blame] | 197 | it('Given a template - User can remove existing vfmodule', function () { |
| 198 | |
| 199 | loadDrawingBoardWithRecreateMode(); |
| 200 | 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", |
| 204 | ]; |
| 205 | |
| 206 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([ |
| 207 | {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame^] | 208 | {path: [...vnfPath2, "vnfStoreKey"], value: "vProbe_NC_VNF 0_1"}, |
Einat Vinouze | a79e4e0 | 2019-12-31 15:33:03 +0200 | [diff] [blame] | 209 | {path: [...removed_vfModule_Path], value: undefined}, |
| 210 | ]); |
| 211 | }); |
| 212 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 213 | [ |
| 214 | {desc: "with changes", modifySomeValues: true}, |
| 215 | {desc: "without changes", modifySomeValues: false}, |
| 216 | ].forEach((testCase) => { |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 217 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 218 | 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] | 219 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 220 | loadDrawingBoardWithRecreateMode(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 221 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 222 | //edit service |
| 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"); |
| 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 vnf |
| 232 | 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"); |
| 236 | } |
| 237 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 238 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 239 | //edit vf module |
| 240 | 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(); |
| 243 | } |
| 244 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 245 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 246 | // Then... |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 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", |
| 251 | ]; |
| 252 | |
| 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: ""}, |
| 257 | |
| 258 | {path: [...vnfPath, "platformName"], value: "xxx1,platform"}, |
| 259 | {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"}, |
| 260 | |
| 261 | {path: [...vfModule_0Path, "sdncPreLoad"], value: true}, |
| 262 | ] : []); |
| 263 | }) |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 264 | |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 265 | }); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 266 | |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 267 | it(`Given a stored template of Network - - it is loaded`, () => { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 268 | |
| 269 | loadDrawingBoardWithRecreateModeNetwork(); |
| 270 | |
| 271 | // Then... |
| 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(); |
| 275 | }); |
| 276 | |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 277 | it(`Given a stored template of Network - User can remove existing network`, () => { |
Einat Vinouze | 6e55393 | 2020-01-01 13:40:56 +0200 | [diff] [blame] | 278 | |
| 279 | loadDrawingBoardWithRecreateModeNetwork(); |
| 280 | |
| 281 | 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", |
| 284 | ]; |
| 285 | |
| 286 | let removed_network_counter_Path = [ |
| 287 | "existingNetworksCounterMap", "f6b6d141-0d4c-427d-ad35-797f3d1abe71", |
| 288 | ]; |
| 289 | |
| 290 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network([ |
| 291 | {path: removed_network_Path, value: undefined}, |
| 292 | {path: removed_network_counter_Path, value: 0}, |
| 293 | ]); |
| 294 | }); |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 295 | |
Einat Vinouze | 83dceaa | 2020-01-02 10:42:19 +0200 | [diff] [blame] | 296 | it('Given a template - User can add a new network', () => { |
| 297 | |
| 298 | loadDrawingBoardWithRecreateModeNetwork(); |
| 299 | |
| 300 | // add new node |
| 301 | addNewNode('node-SR-IOV Provider 2-1-add-btn') |
Yoav Schneiderman | ac489f5 | 2020-01-12 13:24:46 +0200 | [diff] [blame] | 302 | .fillNetworkPopup() |
| 303 | .getDrawingBoardDeployBtn().click() |
| 304 | .wait('@expectedPostAsyncInstantiation').then(xhr => { |
Einat Vinouze | 83dceaa | 2020-01-02 10:42:19 +0200 | [diff] [blame] | 305 | const networkRequest = bodyOf(xhr).networks['SR-IOV Provider 2-1_1']; |
| 306 | |
| 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"); |
| 315 | }); |
| 316 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 317 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 318 | }); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 319 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 320 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 321 | let apiTestResources = '../vid-automation/src/test/resources/asyncInstantiation/'; |
| 322 | |
| 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', |
| 328 | }; |
| 329 | |
| 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', |
| 334 | }; |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 335 | |
Ittay Stern | 18c3ce8 | 2019-12-26 15:21:17 +0200 | [diff] [blame] | 336 | const vnfPath = [ |
| 337 | "vnfs", "vProbe_NC_VNF 0" |
| 338 | ]; |
| 339 | |
Eylon Malin | 284de1d | 2020-01-16 14:54:41 +0200 | [diff] [blame^] | 340 | const vnfPath2 = [ |
| 341 | "vnfs", "vProbe_NC_VNF 0_1" |
| 342 | ]; |
| 343 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 344 | function loadDrawingBoardWithRecreateMode() { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 345 | loadDrawingBoardWithRecreateModeInternal( |
| 346 | '../../' + templateWithVnfSetup.instanceTemplateFile, |
| 347 | templateWithVnfSetup.serviceModelId, |
| 348 | templateWithVnfSetup.serviceModelFile); |
| 349 | } |
| 350 | |
| 351 | function loadDrawingBoardWithRecreateModeNetwork() { |
| 352 | loadDrawingBoardWithRecreateModeInternal( |
| 353 | '../../' + templateWithNetworkSetup.instanceTemplateFile, |
| 354 | templateWithNetworkSetup.serviceModelId, |
| 355 | templateWithNetworkSetup.serviceModelFile); |
| 356 | } |
| 357 | |
| 358 | function loadDrawingBoardWithRecreateModeInternal(instanceTemplate: string, serviceModelIdToLoad: any, serviceModel: string) { |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 359 | const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b"; |
| 360 | |
| 361 | const drawingBoardAction = `RECREATE`; |
| 362 | const templateTopologyEndpoint = "templateTopology"; |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 363 | cy.route(`**/rest/models/services/${serviceModelIdToLoad}`, |
| 364 | 'fixture:' + serviceModel) |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 365 | .as('serviceModel'); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 366 | |
Einat Vinouze | dd171b4 | 2019-12-19 14:34:19 +0200 | [diff] [blame] | 367 | cy.route(`**/instantiationTemplates/${templateTopologyEndpoint}/${templateUuid}`, |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 368 | 'fixture:' + instanceTemplate) |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 369 | .as('templateTopology'); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 370 | |
| 371 | // When... |
| 372 | |
| 373 | cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` + |
| 374 | `?jobId=${templateUuid}` + |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 375 | `&serviceModelId=${serviceModelIdToLoad}`); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 376 | |
| 377 | cy.wait('@serviceModel'); |
| 378 | cy.wait('@templateTopology'); |
| 379 | } |
| 380 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 381 | function nodeAction(dataTestId: string, action: string, index ?: number) { |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 382 | return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId, index) |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 383 | .drawingBoardTreeClickOnContextMenuOptionByName(action) |
| 384 | } |
| 385 | |
| 386 | function editNode(dataTestId: string, index ?: number) { |
| 387 | return nodeAction(dataTestId, 'Edit', index); |
| 388 | } |
| 389 | |
| 390 | function addNewNode(dataTestId: string) { |
| 391 | return cy.getElementByDataTestsId(dataTestId).click({force: true}) |
| 392 | } |
| 393 | |
| 394 | function removeVNFWithVFModules(dataTestId: string) { |
| 395 | return nodeAction(dataTestId, 'Remove') |
| 396 | .getTagElementContainsText('button', 'Remove VNF').click() |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 397 | } |
| 398 | |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 399 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 400 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(templateWithVnfSetup.instanceTemplateFile, deviationFromExpected); |
| 401 | } |
| 402 | |
| 403 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
| 404 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(templateWithNetworkSetup.instanceTemplateFile, deviationFromExpected); |
| 405 | } |
| 406 | |
| 407 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEndInternal(filePathOfExpected: string, deviationFromExpected: { path: PropertyPath; value: any }[]) { |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 408 | cy.getDrawingBoardDeployBtn().click(); |
| 409 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 410 | cy.readFile(filePathOfExpected).then((expectedResult) => { |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 411 | convertRollbackOnFailureValueFromStringToBoolean(expectedResult); |
| 412 | |
| 413 | let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr); |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 414 | setDeviationInExpected(expectedResult, deviationFromExpected); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 415 | cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult); |
| 416 | }); |
| 417 | }); |
| 418 | } |
| 419 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 420 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 421 | function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 422 | cy.getDrawingBoardDeployBtn().click(); |
| 423 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 424 | |
Ittay Stern | a4b0a60 | 2019-12-31 15:01:27 +0200 | [diff] [blame] | 425 | cy.readFile(templateWithVnfSetup.instanceTemplateSetWithoutModifyFile).then((expectedResult) => { |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 426 | setDeviationInExpected(expectedResult, deviationFromExpected); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 427 | cy.deepCompare(xhr.request.body, expectedResult); |
| 428 | }); |
| 429 | |
| 430 | }); |
| 431 | } |
| 432 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 433 | function bodyOf(xhr: Cypress.WaitXHR) { |
| 434 | return JSON.parse(JSON.stringify(xhr.request.body)); |
| 435 | } |
| 436 | |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 437 | function setDeviationInExpected(expectedResult: any, deviations: { path: PropertyPath; value: any }[]) { |
| 438 | for (const deviation of deviations) { |
| 439 | _.set(expectedResult, deviation.path, deviation.value); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | |
Ittay Stern | 5887853 | 2019-12-26 14:15:05 +0200 | [diff] [blame] | 443 | function findPathOfLatestVfModule(serviceInstanceElementFromRedux: any, vfModulesContainerPath: string[]) { |
| 444 | let latestVfModuleRandomlySelectedKey: string = _.last(_.keys( |
| 445 | _.get(serviceInstanceElementFromRedux, vfModulesContainerPath) |
| 446 | )) as string; |
| 447 | |
| 448 | return [...vfModulesContainerPath, latestVfModuleRandomlySelectedKey]; |
| 449 | } |
| 450 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 451 | //We use this function because the deployService() on drawing-board-header.component class |
| 452 | // changes rollbackOnFailure value from string type to boolean. |
| 453 | function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) { |
| 454 | expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure); |
| 455 | } |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 456 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 457 | function removeIsDirtyFieldFromXhrRequestBody(xhr: any) { |
| 458 | let xhrTempBody = bodyOf(xhr); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 459 | delete xhrTempBody.isDirty; |
| 460 | return xhrTempBody; |
| 461 | } |
| 462 | |
Yoav Schneiderman | 7b10265 | 2019-12-30 16:27:14 +0200 | [diff] [blame] | 463 | function mockAsyncBulkResponse() { |
| 464 | cy.server().route({ |
| 465 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 466 | method: 'POST', |
| 467 | status: 200, |
| 468 | response: "[]", |
| 469 | }).as("expectedPostAsyncInstantiation"); |
| 470 | } |