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 | |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +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 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 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', () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 36 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 37 | loadDrawingBoardWithRecreateMode(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 38 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 39 | // Then... |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 40 | editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 41 | .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007') |
| 42 | .getElementByDataTestsId("productFamily").should('contain', 'Emanuel') |
| 43 | .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 44 | .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 45 | .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1') |
| 46 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 47 | .checkPlatformValue('xxx1') |
| 48 | .getElementByDataTestsId("cancelButton").click(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 49 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 50 | editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0") |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 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') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 55 | .getElementByDataTestsId("cancelButton").click(); |
| 56 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 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') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 60 | .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') |
| 61 | .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') |
| 62 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 63 | .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 64 | .getElementByDataTestsId("cancelButton").click(); |
| 65 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 66 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(); |
Alexey Sandler | f53a917 | 2019-12-05 17:04:45 +0200 | [diff] [blame] | 67 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 68 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 69 | 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] | 70 | |
| 71 | loadDrawingBoardWithRecreateMode(); |
| 72 | |
| 73 | cy.openServiceContextMenu() |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 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'); |
| 81 | |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 82 | }); |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 83 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 84 | [ |
| 85 | {desc: "with changes", modifySomeValues: true}, |
| 86 | {desc: "without changes", modifySomeValues: false}, |
| 87 | ].forEach((testCase) => { |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 88 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 89 | 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] | 90 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 91 | loadDrawingBoardWithRecreateMode(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 92 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 93 | //edit service |
| 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"); |
| 99 | } |
| 100 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 101 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 102 | // edit vnf |
| 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"); |
| 107 | } |
| 108 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 109 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 110 | //edit vf module |
| 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(); |
| 114 | } |
| 115 | cy.getElementByDataTestsId('form-set').click(); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 116 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 117 | // Then... |
| 118 | let vnfPath = [ |
| 119 | "vnfs", "vProbe_NC_VNF 0" |
| 120 | ]; |
| 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", |
| 125 | ]; |
| 126 | |
| 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: ""}, |
| 131 | |
| 132 | {path: [...vnfPath, "platformName"], value: "xxx1,platform"}, |
| 133 | {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"}, |
| 134 | |
| 135 | {path: [...vfModule_0Path, "sdncPreLoad"], value: true}, |
| 136 | ] : []); |
| 137 | }) |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 138 | |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 139 | }); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 140 | |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 141 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 142 | }); |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 143 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 144 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 145 | function loadDrawingBoardWithRecreateMode() { |
| 146 | const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38'; |
| 147 | const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b"; |
| 148 | |
| 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') |
| 153 | .as('serviceModel'); |
| 154 | |
| 155 | cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`, |
| 156 | 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json') |
| 157 | .as('templateTopology'); |
| 158 | |
| 159 | // When... |
| 160 | |
| 161 | cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` + |
| 162 | `?jobId=${templateUuid}` + |
| 163 | `&serviceModelId=${serviceModelId}`); |
| 164 | |
| 165 | cy.wait('@serviceModel'); |
| 166 | cy.wait('@templateTopology'); |
| 167 | } |
| 168 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 169 | function editNode(dataTestId: string) { |
| 170 | return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId) |
| 171 | .drawingBoardTreeClickOnContextMenuOptionByName('Edit') |
| 172 | } |
| 173 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 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); |
| 179 | |
| 180 | let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr); |
| 181 | cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult); |
| 182 | }); |
| 183 | }); |
| 184 | } |
| 185 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 186 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 187 | function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 188 | cy.getDrawingBoardDeployBtn().click(); |
| 189 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 190 | |
| 191 | cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => { |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 192 | setDeviationInExpected(expectedResult, deviationFromExpected); |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 193 | cy.deepCompare(xhr.request.body, expectedResult); |
| 194 | }); |
| 195 | |
| 196 | }); |
| 197 | } |
| 198 | |
Ittay Stern | b9d4788 | 2019-12-17 06:54:33 +0200 | [diff] [blame^] | 199 | function setDeviationInExpected(expectedResult: any, deviation: { path: PropertyPath; value: any }[]) { |
| 200 | for (const caveat of deviation) { |
| 201 | _.set(expectedResult, caveat.path, caveat.value); |
| 202 | } |
| 203 | } |
| 204 | |
Alexey Sandler | b85a046 | 2019-12-04 17:48:06 +0200 | [diff] [blame] | 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); |
| 209 | } |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 210 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 211 | function removeIsDirtyFieldFromXhrRequestBody(xhr : any) { |
| 212 | let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body)); |
| 213 | delete xhrTempBody.isDirty; |
| 214 | return xhrTempBody; |
| 215 | } |
| 216 | |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 217 | function mockAsyncBulkResponse() { |
| 218 | cy.server().route({ |
| 219 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 220 | method: 'POST', |
| 221 | status: 200, |
| 222 | response: "[]", |
| 223 | }).as("expectedPostAsyncInstantiation"); |
| 224 | } |