Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 1 | describe('Drawing Board: Instantiation Templates', function () { |
| 2 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 3 | describe('Instantiation templates ', () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 4 | |
| 5 | beforeEach(() => { |
| 6 | cy.clearSessionStorage(); |
Ittay Stern | 4bfa2df | 2019-12-17 14:55:04 +0200 | [diff] [blame] | 7 | cy.setTestApiParamToGR(); |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 8 | cy.initAAIMock(); |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 9 | cy.initGetAAISubDetails(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 10 | cy.initVidMock(); |
| 11 | cy.initDrawingBoardUserPermission(); |
| 12 | cy.login(); |
| 13 | |
| 14 | mockAsyncBulkResponse(); |
| 15 | }); |
| 16 | |
| 17 | afterEach(() => { |
| 18 | cy.screenshot(); |
| 19 | }); |
| 20 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 21 | describe('Load Page and Deploy', () => { |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 22 | |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 23 | 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] | 24 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 25 | loadDrawingBoardWithRecreateMode(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 26 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 27 | // Then... |
| 28 | cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible'); |
| 29 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(); |
| 30 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 31 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 32 | 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] | 33 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 34 | loadDrawingBoardWithRecreateMode(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 35 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 36 | // Then... |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 37 | editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 38 | .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007') |
| 39 | .getElementByDataTestsId("productFamily").should('contain', 'Emanuel') |
| 40 | .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 41 | .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 42 | .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1') |
| 43 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 44 | .checkPlatformValue('xxx1') |
| 45 | .getElementByDataTestsId("cancelButton").click(); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 46 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 47 | 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] | 48 | .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01') |
| 49 | .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') |
| 50 | .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') |
| 51 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 52 | .getElementByDataTestsId("cancelButton").click(); |
| 53 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 54 | editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1") |
| 55 | .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01') |
| 56 | .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 57 | .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') |
| 58 | .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') |
| 59 | .getElementByDataTestsId("rollback").should('contain', 'Rollback') |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 60 | .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on') |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 61 | .getElementByDataTestsId("cancelButton").click(); |
| 62 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 63 | assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(); |
Alexey Sandler | f53a917 | 2019-12-05 17:04:45 +0200 | [diff] [blame] | 64 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 65 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 66 | 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] | 67 | |
| 68 | loadDrawingBoardWithRecreateMode(); |
| 69 | |
| 70 | cy.openServiceContextMenu() |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 71 | .getElementByDataTestsId("context-menu-header-edit-item").click() |
| 72 | .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI') |
| 73 | .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS') |
| 74 | .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA') |
| 75 | .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland') |
| 76 | .getElementByDataTestsId("project").should('contain', 'WATKINS') |
| 77 | .getElementByDataTestsId("rollback").should('contain', 'Rollback'); |
| 78 | |
Alexey Sandler | 12ceb44 | 2019-12-16 10:18:41 +0200 | [diff] [blame] | 79 | }); |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 80 | |
| 81 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 82 | it('Given a stored template - edit service vnf and vfmodule without changes - deploy request should be without changes', function () { |
| 83 | |
| 84 | loadDrawingBoardWithRecreateMode(); |
| 85 | |
| 86 | //open - set edit service |
| 87 | cy.openServiceContextMenu() |
| 88 | .getElementByDataTestsId("context-menu-header-edit-item").click() |
| 89 | .getElementByDataTestsId('form-set').click(); |
| 90 | |
| 91 | //open - set edit vnf |
| 92 | editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") |
| 93 | .getElementByDataTestsId('form-set').click(); |
| 94 | |
| 95 | //open - set edit vf |
| 96 | editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0") |
| 97 | .getElementByDataTestsId('form-set').click(); |
| 98 | |
| 99 | assertThatBodyFromDeployRequestEqualsToFile(); |
| 100 | }); |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 101 | |
Alexey Sandler | 4636353 | 2019-12-12 11:52:18 +0200 | [diff] [blame] | 102 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 103 | }); |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 104 | }); |
| 105 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 106 | function loadDrawingBoardWithRecreateMode() { |
| 107 | const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38'; |
| 108 | const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b"; |
| 109 | |
| 110 | const drawingBoardAction = `RECREATE`; |
| 111 | const templateTopologyEndpoint = "templateTopology"; |
| 112 | cy.route(`**/rest/models/services/${serviceModelId}`, |
| 113 | 'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json') |
| 114 | .as('serviceModel'); |
| 115 | |
| 116 | cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`, |
| 117 | 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json') |
| 118 | .as('templateTopology'); |
| 119 | |
| 120 | // When... |
| 121 | |
| 122 | cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` + |
| 123 | `?jobId=${templateUuid}` + |
| 124 | `&serviceModelId=${serviceModelId}`); |
| 125 | |
| 126 | cy.wait('@serviceModel'); |
| 127 | cy.wait('@templateTopology'); |
| 128 | } |
| 129 | |
Ittay Stern | 8f0f728 | 2019-12-16 20:07:50 +0200 | [diff] [blame] | 130 | function editNode(dataTestId: string) { |
| 131 | return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId) |
| 132 | .drawingBoardTreeClickOnContextMenuOptionByName('Edit') |
| 133 | } |
| 134 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 135 | function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() { |
| 136 | cy.getDrawingBoardDeployBtn().click(); |
| 137 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 138 | cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => { |
| 139 | convertRollbackOnFailureValueFromStringToBoolean(expectedResult); |
| 140 | |
| 141 | let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr); |
| 142 | cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult); |
| 143 | }); |
| 144 | }); |
| 145 | } |
| 146 | |
Sara Weiss | 19bfe44 | 2019-12-17 13:20:29 +0200 | [diff] [blame] | 147 | |
| 148 | function assertThatBodyFromDeployRequestEqualsToFile() { |
| 149 | cy.getDrawingBoardDeployBtn().click(); |
| 150 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 151 | |
| 152 | cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => { |
| 153 | cy.deepCompare(xhr.request.body, expectedResult); |
| 154 | }); |
| 155 | |
| 156 | }); |
| 157 | } |
| 158 | |
Alexey Sandler | b85a046 | 2019-12-04 17:48:06 +0200 | [diff] [blame] | 159 | //We use this function because the deployService() on drawing-board-header.component class |
| 160 | // changes rollbackOnFailure value from string type to boolean. |
| 161 | function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) { |
| 162 | expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure); |
| 163 | } |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 164 | |
Alexey Sandler | befd784 | 2019-12-11 10:06:31 +0200 | [diff] [blame] | 165 | function removeIsDirtyFieldFromXhrRequestBody(xhr : any) { |
| 166 | let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body)); |
| 167 | delete xhrTempBody.isDirty; |
| 168 | return xhrTempBody; |
| 169 | } |
| 170 | |
Ittay Stern | e888722 | 2019-12-01 19:38:32 +0200 | [diff] [blame] | 171 | function mockAsyncBulkResponse() { |
| 172 | cy.server().route({ |
| 173 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 174 | method: 'POST', |
| 175 | status: 200, |
| 176 | response: "[]", |
| 177 | }).as("expectedPostAsyncInstantiation"); |
| 178 | } |