Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | ///<reference path="../../../node_modules/cypress/types/index.d.ts"/> |
| 2 | import {ServiceModel} from '../../support/jsonBuilders/models/service.model'; |
| 3 | import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder'; |
| 4 | |
| 5 | describe('Vnf Groups', function () { |
| 6 | var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>(); |
| 7 | |
| 8 | beforeEach(() => { |
Ittay Stern | 32dbf80 | 2019-10-29 12:58:49 +0200 | [diff] [blame] | 9 | cy.clearSessionStorage(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 10 | cy.setReduxState(); |
| 11 | cy.preventErrorsOnLoading(); |
| 12 | cy.initAAIMock(); |
| 13 | cy.initVidMock(); |
| 14 | cy.permissionVidMock(); |
| 15 | cy.setTestApiParamToVNF(); |
| 16 | cy.login(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 17 | }); |
| 18 | |
| 19 | afterEach(() => { |
| 20 | cy.screenshot(); |
| 21 | }); |
| 22 | |
| 23 | describe('Vnf Group model basic view', function () { |
| 24 | |
| 25 | it('Vnf group open new view edit', function () { |
| 26 | const instanceName: string = 'ABC'; |
| 27 | const groupName = 'groupingservicefortest..ResourceInstanceGroup..0'; |
| 28 | const nodeId = 'daeb6568-cef8-417f-9075-ed259ce59f48'; |
| 29 | const serviceId = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 30 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 31 | jsonBuilderAndMock.basicJson( |
| 32 | res, |
| 33 | Cypress.config('baseUrl') + "/rest/models/services/" + serviceId, |
| 34 | 200, |
| 35 | 0, |
| 36 | "ServiceWithVnfGroup", |
| 37 | ); |
| 38 | |
| 39 | cy.buildReduxStateWithServiceRespone(res, serviceId, false); |
| 40 | cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + serviceId); |
| 41 | cy.getElementByDataTestsId('node-' + groupName).find(`[data-tests-id='node-type-indicator']`).contains('G'); |
| 42 | cy.getElementByDataTestsId('node-' + groupName).contains('' + groupName); |
| 43 | cy.getElementByDataTestsId('node-' + groupName + '-add-btn').get('i').should('have.class', 'fa-plus-circle'); |
| 44 | cy.getElementByDataTestsId('node-' + groupName + '-add-btn').click({force: true}); |
| 45 | cy.getElementByDataTestsId('instanceName').clear(); |
| 46 | cy.typeToInput('instanceName', instanceName); |
| 47 | cy.getElementByDataTestsId('form-set').click({force: true}).then(() => { |
| 48 | cy.getElementByDataTestsId('numberButton').contains('1'); |
| 49 | cy.getElementByDataTestsId('node-' + nodeId + '-' + groupName).contains(instanceName); |
| 50 | cy.getElementByDataTestsId('node-' + nodeId + '-' + groupName + '-menu-btn') |
| 51 | .click({force: true}); |
| 52 | cy.getElementByDataTestsId('context-menu-edit').click(); |
| 53 | cy.getElementByDataTestsId('instanceName').clear(); |
| 54 | cy.typeToInput('instanceName', instanceName + instanceName); |
| 55 | cy.getElementByDataTestsId('form-set').click({force: true}).then(() => { |
| 56 | cy.getElementByDataTestsId('node-' + nodeId + '-' + groupName + '-menu-btn').click({force: true}) |
| 57 | .getElementByDataTestsId('context-menu-remove').click(); |
| 58 | }); |
| 59 | }); |
| 60 | }); |
| 61 | }); |
| 62 | |
| 63 | it('Create new service with vnf group', () => { |
| 64 | |
| 65 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 66 | const GROUP_NAME_TO_DEPLOY = 'groupingservicefortest..ResourceInstanceGroup..1'; |
| 67 | const NODE_ID = 'c2b300e6-45de-4e5e-abda-3032bee2de56'; |
| 68 | let serviceModel: JSON; |
| 69 | let basicServiceInstance: JSON; |
| 70 | |
| 71 | cy.server().route({ |
| 72 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 73 | method: 'POST', |
| 74 | status: 200, |
| 75 | response: "[]", |
| 76 | }).as("expectedPostAsyncInstantiation"); |
| 77 | |
| 78 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 79 | serviceModel = res; |
| 80 | }); |
| 81 | |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 82 | cy.readFile('cypress/support/jsonBuilders/mocks/jsons/vnfGroupBasicServiceInstance.json').then((res) => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 83 | basicServiceInstance = res; |
| 84 | }); |
| 85 | |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 86 | cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((reduxRes) => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 87 | |
| 88 | reduxRes.service.serviceHierarchy[SERVICE_MODEL_ID] = serviceModel; |
| 89 | reduxRes.service.serviceInstance[SERVICE_MODEL_ID] = basicServiceInstance; |
| 90 | |
| 91 | cy.setReduxState(<any>reduxRes); |
| 92 | |
| 93 | cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + SERVICE_MODEL_ID); |
| 94 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).find(`[data-tests-id='node-type-indicator']`).contains('G'); |
| 95 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).contains('' + GROUP_NAME_TO_DEPLOY); |
| 96 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').get('i').should('have.class', 'fa-plus-circle'); |
| 97 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').click({force: true}); |
| 98 | cy.getElementByDataTestsId('node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY + '-menu-btn') |
| 99 | .click({force: true}); |
| 100 | cy.getElementByDataTestsId('context-menu-edit').click(); |
| 101 | cy.getElementByDataTestsId('instanceName').clear(); |
| 102 | cy.typeToInput('instanceName', "ABC"); |
| 103 | cy.getElementByDataTestsId('form-set').click({force: true}); |
| 104 | cy.getElementByDataTestsId('deployBtn').should('have.text', 'DEPLOY').click(); |
| 105 | cy.getElementByDataTestsId('isViewOnly-status-test').contains('IN DESIGN'); |
| 106 | cy.getReduxState().then((state) => { |
| 107 | const vnfGroup = state.service.serviceInstance[SERVICE_MODEL_ID].vnfGroups[GROUP_NAME_TO_DEPLOY]; |
| 108 | |
| 109 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 110 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupCreateRequest.json').then((expectedResult) => { |
| 111 | expectedResult.vnfGroups[GROUP_NAME_TO_DEPLOY].trackById = vnfGroup.trackById; |
| 112 | cy.deepCompare(xhr.request.body, expectedResult); |
| 113 | }); |
| 114 | }); |
| 115 | }); |
| 116 | |
| 117 | }); |
| 118 | |
| 119 | }); |
| 120 | |
| 121 | it('Delete vnf group with members', () => { |
| 122 | cy.initSearchVNFMemebers(); |
| 123 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 124 | let serviceModel: JSON; |
| 125 | let basicServiceInstance: JSON; |
| 126 | |
| 127 | cy.server().route({ |
| 128 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 129 | method: 'POST', |
| 130 | status: 200, |
| 131 | response: "[]", |
| 132 | }).as("expectedPostAsyncInstantiation"); |
| 133 | |
| 134 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 135 | serviceModel = res; |
| 136 | }); |
| 137 | |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 138 | cy.readFile('cypress/support/jsonBuilders/mocks/jsons/vnfGroupBasicServiceInstance.json').then((res) => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 139 | basicServiceInstance = res; |
| 140 | }); |
| 141 | |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 142 | cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((reduxRes) => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 143 | |
| 144 | reduxRes.service.serviceHierarchy[SERVICE_MODEL_ID] = serviceModel; |
| 145 | reduxRes.service.serviceInstance[SERVICE_MODEL_ID] = basicServiceInstance; |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 146 | reduxRes.global.genericModalHelper = {}; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 147 | |
| 148 | cy.setReduxState(<any>reduxRes); |
| 149 | |
| 150 | cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + SERVICE_MODEL_ID); |
| 151 | cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..0-add-btn').click({force: true}); |
| 152 | removeVnfGroup(); |
| 153 | cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..0-add-btn').click({force: true}); |
| 154 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn') |
| 155 | .click({force: true}); |
| 156 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
| 157 | cy.get('.allCheckboxAreSelected input').click({force: true}); |
| 158 | cy.getElementByDataTestsId('setMembersBtn').click({force: true}) |
| 159 | }); |
| 160 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0').click({force: true}); |
| 161 | removeVnfGroup(); |
| 162 | cy.getElementByDataTestsId('button-remove-group').click({force: true}); |
| 163 | cy.get('#model-actions').should('not.exist'); |
| 164 | |
| 165 | }); |
| 166 | |
| 167 | }); |
| 168 | |
| 169 | it('Vnf group edit mode delete empty service instance', () => { |
| 170 | const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89"; |
| 171 | const SERVICE_TYPE: string = "TYLER SILVIA"; |
| 172 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 173 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 174 | let expectedResult: JSON; |
| 175 | |
| 176 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 177 | jsonBuilderAndMock.basicJson( |
| 178 | res, |
| 179 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 180 | 200, |
| 181 | 0, |
| 182 | "ServiceWithVnfGrouping_serviceModel", |
| 183 | ); |
| 184 | }); |
| 185 | |
| 186 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroping_serviceInstance.json').then((res) => { |
| 187 | jsonBuilderAndMock.basicJson( |
| 188 | res, |
| 189 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 190 | 200, 0, |
| 191 | "serviceWithVnfGroping_serviceInstance", |
| 192 | ) |
| 193 | }); |
| 194 | |
| 195 | cy.server().route({ |
| 196 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 197 | method: 'POST', |
| 198 | status: 200, |
| 199 | response: "[]", |
| 200 | }).as("expectedPostAsyncInstantiation"); |
| 201 | |
| 202 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/ServiceWithVnfGroupsDeleteRequest.json').then((res) => { |
| 203 | expectedResult = res; |
| 204 | }); |
| 205 | |
| 206 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 207 | cy.getElementByDataTestsId('orchStatusValue').should('not.have.class', 'tag-status-value'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 208 | cy.getElementByDataTestsId('openMenuBtn').click(); |
| 209 | cy.getElementByDataTestsId('context-menu-header-delete-item').should('have.text', 'Delete'); |
| 210 | cy.getElementByDataTestsId('context-menu-header-delete-item').click(); |
| 211 | cy.getElementByDataTestsId('serviceName').should('have.css', 'text-decoration'); |
| 212 | cy.getElementByDataTestsId('openMenuBtn').click(); |
| 213 | cy.getElementByDataTestsId('context-menu-header-delete-item').should('have.text', 'Undo delete'); |
| 214 | cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click(); |
| 215 | |
| 216 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 217 | cy.deepCompare(xhr.request.body, expectedResult); |
| 218 | |
| 219 | }); |
| 220 | }); |
| 221 | |
| 222 | it('Delete service with two vnf groups', () => { |
| 223 | const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89"; |
| 224 | const SERVICE_TYPE: string = "TYLER SILVIA"; |
| 225 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 226 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 227 | let expectedResult: JSON; |
| 228 | |
| 229 | cy.server().route({ |
| 230 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 231 | method: 'POST', |
| 232 | status: 200, |
| 233 | response: "[]", |
| 234 | }).as("expectedPostAsyncInstantiation"); |
| 235 | |
| 236 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 237 | jsonBuilderAndMock.basicJson( |
| 238 | res, |
| 239 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 240 | 200, 0, |
| 241 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 242 | ) |
| 243 | }); |
| 244 | |
| 245 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 246 | jsonBuilderAndMock.basicJson( |
| 247 | res, |
| 248 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 249 | 200, |
| 250 | 0, |
| 251 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 252 | ) |
| 253 | }); |
| 254 | |
| 255 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/deleteServiceWith2VnfGroupsRequest_AndThreeGroupMembers.json').then((expectedResult) => { |
| 256 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`); |
| 257 | cy.getElementByDataTestsId('openMenuBtn').click(); |
| 258 | cy.getElementByDataTestsId('context-menu-header-delete-item').should('have.text', 'Delete').click(); |
| 259 | cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click(); |
| 260 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 261 | cy.deepCompare(xhr.request.body, expectedResult); |
| 262 | }); |
| 263 | }); |
| 264 | }); |
| 265 | |
| 266 | it(`when open service with group in EDIT mode, service instance is shown as expected - e2e with input and output API's tests"`, function () { |
| 267 | const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89"; |
| 268 | const SERVICE_TYPE: string = "TYLER SILVIA"; |
| 269 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 270 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 271 | |
| 272 | cy.server().route({ |
| 273 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 274 | method: 'POST', |
| 275 | status: 200, |
| 276 | response: "[]", |
| 277 | }).as("expectedPostAsyncInstantiation"); |
| 278 | |
| 279 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 280 | jsonBuilderAndMock.basicJson( |
| 281 | res, |
| 282 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 283 | 200, |
| 284 | 0, |
| 285 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 286 | ) |
| 287 | }); |
| 288 | |
| 289 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 290 | jsonBuilderAndMock.basicJson( |
| 291 | res, |
| 292 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 293 | 200, 0, |
| 294 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 295 | ) |
| 296 | }); |
| 297 | |
| 298 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`); |
| 299 | |
| 300 | /* |
| 301 | 0. title area -> generic stuff |
| 302 | instance name |
| 303 | orch status |
| 304 | service name |
| 305 | */ |
| 306 | cy.getElementByDataTestsId("serviceInstance").should('have.text', 'Service instance:'); |
| 307 | cy.getElementByDataTestsId("orchStatusLabel").should('have.text', 'Orch Status:'); |
| 308 | // ERROR! cy.getElementByDataTestsId("quantityLabel").should('not.be.visible'); |
| 309 | // ERROR! cy.getElementByDataTestsId("servicesQuantity").should('not.be.visible'); |
| 310 | |
| 311 | // specific |
| 312 | cy.getElementByDataTestsId("serviceName").should('have.text', 'SERVICE_INSTANCE_NAME'); |
| 313 | cy.getElementByDataTestsId("orchStatusValue").should('have.text', 'GARBAGE DATA'); |
| 314 | cy.get('span#service-model-name').contains('Grouping Service for Test'); |
| 315 | |
| 316 | // no need to expand anything |
| 317 | cy.get('available-models-tree').find('.toggle-children').should('not.exist'); |
| 318 | |
| 319 | /* |
| 320 | 1. Left tree |
| 321 | */ |
| 322 | const leftShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = { |
| 323 | 'node-groupingservicefortest..ResourceInstanceGroup..0': { |
| 324 | 'node-type-indicator': 'G', |
| 325 | 'node-name': 'groupingservicefortest..ResourceInstanceGroup..0', |
| 326 | 'numberButton': '2', |
| 327 | }, |
| 328 | 'node-groupingservicefortest..ResourceInstanceGroup..1': { |
| 329 | 'node-type-indicator': 'G', |
| 330 | 'node-name': 'groupingservicefortest..ResourceInstanceGroup..1', |
| 331 | 'numberButton': '', |
| 332 | }, |
| 333 | }; |
| 334 | cy.getElementByDataTestsId('search-left-tree-input').type('group'); |
| 335 | for (let node in leftShouldHaves) { |
| 336 | cy.getElementByDataTestsId(node).find(`[data-tests-id= '${'node-name'}']`).find('.highlight').eq(0).should('have.text', 'group'); |
| 337 | |
| 338 | for (let span in leftShouldHaves[node]) { |
| 339 | const expected = leftShouldHaves[node][span]; |
| 340 | cy.getElementByDataTestsId(node).find(`[data-tests-id='${span}']`).should(expected ? 'have.text' : 'not.exist', expected); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | |
| 345 | /* |
| 346 | 2. Right tree |
| 347 | */ |
| 348 | const rightShouldHaves: { [dataTestId: string]: { [dataTestId: string]: string; }; } = { |
| 349 | 'node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0:0': { |
| 350 | 'node-type-indicator': 'G', |
| 351 | 'node-name': 'VNF_GROUP1_INSTANCE_NAME', |
| 352 | 'status-property-orchStatus': '', |
| 353 | 'status-property-provStatus': '', |
| 354 | // 'status-property-inMaint': '', not exists for false in maint |
| 355 | }, |
| 356 | 'node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0:1': { |
| 357 | 'node-type-indicator': 'G', |
| 358 | 'node-name': 'VNF_GROUP2_INSTANCE_NAME', |
| 359 | 'status-property-orchStatus': '', |
| 360 | 'status-property-provStatus': '', |
| 361 | // 'status-property-inMaint': 'false', |
| 362 | }, |
| 363 | }; |
| 364 | cy.getElementByDataTestsId('search-right-tree-input').type('vnf'); |
| 365 | |
| 366 | for (let node in rightShouldHaves) { |
| 367 | var [nodeName, nodeEq] = node.split(":"); |
| 368 | for (let span in rightShouldHaves[node]) { |
| 369 | cy.getElementByDataTestsId(nodeName).eq(+nodeEq).find(`[data-tests-id='${span}']`).should('have.text', rightShouldHaves[node][span]); |
| 370 | cy.getElementByDataTestsId(nodeName).eq(+nodeEq).find(`[data-tests-id= '${'node-name'}']`).find('.highlight').eq(0).should('have.text', 'VNF'); |
| 371 | |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | /* |
| 376 | 3. Left to right connections |
| 377 | */ |
| 378 | const leftShouldHighlight: { [text: string]: string[] } = { |
| 379 | 'groupingservicefortest..ResourceInstanceGroup..0': ['VNF_GROUP1_INSTANCE_NAME', 'VNF_GROUP2_INSTANCE_NAME'], |
| 380 | 'groupingservicefortest..ResourceInstanceGroup..1': [], |
| 381 | }; |
| 382 | |
| 383 | for (let text in leftShouldHighlight) { |
| 384 | cy.get('available-models-tree').contains(text).click(); |
| 385 | cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', text + leftShouldHighlight[text].join('')); |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | 4. Right to left connections |
| 390 | */ |
| 391 | const rightShouldHighlight: { [text: string]: string[] } = { |
| 392 | 'VNF_GROUP1_INSTANCE_NAME': ['groupingservicefortest..ResourceInstanceGroup..0'], |
| 393 | 'VNF_GROUP2_INSTANCE_NAME': ['groupingservicefortest..ResourceInstanceGroup..0'], |
| 394 | }; |
| 395 | |
| 396 | for (let node in rightShouldHighlight) { |
| 397 | cy.get('drawing-board-tree').contains(node).click(); |
| 398 | cy.get('.node-content-wrapper-active').find(`[data-tests-id='node-name']`).should('have.text', rightShouldHighlight[node].join('') + node); |
| 399 | } |
| 400 | |
| 401 | /* |
| 402 | Menus |
| 403 | */ |
| 404 | // SETUP: delete one group on the right; add one group from the left |
| 405 | const myNode = 'node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0'; |
| 406 | |
| 407 | cy.getElementByDataTestsId(`${myNode}-menu-btn`).eq(0).click({force: true}) |
| 408 | .getElementByDataTestsId('context-menu-delete').click(); |
| 409 | |
| 410 | cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..0-add-btn').click({force: true}); |
| 411 | cy.getElementByDataTestsId(`${myNode}-menu-btn`).eq(2).click({force: true}) |
| 412 | .getElementByDataTestsId('context-menu-edit').click(); |
| 413 | cy.getElementByDataTestsId('instanceName').clear(); |
| 414 | cy.typeToInput('instanceName', 'VNF_GROUP3_INSTANCE_NAME'); |
| 415 | cy.getElementByDataTestsId('form-set').click({force: true}); |
| 416 | |
| 417 | // TEST: |
| 418 | // #2 is just added |
| 419 | // #1 is from AAI |
| 420 | // #0 is deleted |
| 421 | const menuShouldHave: { [text: string]: string[] } = { |
| 422 | [`${myNode}-menu-btn:2`]: ['remove', 'addGroupMember'], |
| 423 | [`${myNode}-menu-btn:1`]: ['showAuditInfo', 'addGroupMember', 'delete'], |
| 424 | [`${myNode}-menu-btn:0`]: ['showAuditInfo', 'undoDelete'], |
| 425 | }; |
| 426 | |
| 427 | for (let node in menuShouldHave) { |
| 428 | const [nodeName, nodeEq] = node.split(":"); |
| 429 | let enabledActions:string[] = menuShouldHave[node]; |
| 430 | cy.assertMenuItemsForNode(enabledActions, nodeName, +nodeEq); |
| 431 | } |
| 432 | |
| 433 | const GROUP_NAME_TO_DEPLOY: string = 'groupingservicefortest..ResourceInstanceGroup..0'; |
| 434 | cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click(); |
| 435 | |
| 436 | cy.getReduxState().then((state) => { |
| 437 | const addedVnfGroup = state.service.serviceInstance[SERVICE_MODEL_ID].vnfGroups[GROUP_NAME_TO_DEPLOY]; |
| 438 | |
| 439 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 440 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/VnfGroupCreate1Delete1None1Request.json').then((expectedResult) => { |
| 441 | expectedResult.vnfGroups[GROUP_NAME_TO_DEPLOY].trackById = addedVnfGroup.trackById; |
| 442 | cy.deepCompare(xhr.request.body, expectedResult); |
| 443 | }); |
| 444 | }); |
| 445 | }); |
| 446 | }); |
| 447 | |
| 448 | it(`vnf group with vnf members should display correctly and should have delete option"`, function () { |
| 449 | const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89"; |
| 450 | const SERVICE_TYPE: string = "TYLER SILVIA"; |
| 451 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 452 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 453 | |
| 454 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 455 | jsonBuilderAndMock.basicJson( |
| 456 | res, |
| 457 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 458 | 200, |
| 459 | 0, |
| 460 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 461 | ) |
| 462 | }); |
| 463 | |
| 464 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 465 | jsonBuilderAndMock.basicJson( |
| 466 | res, |
| 467 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 468 | 200, 0, |
| 469 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 470 | ) |
| 471 | }); |
| 472 | |
| 473 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`); |
| 474 | cy.getElementByDataTestsId('deployBtn').should('have.attr', 'disabled'); |
| 475 | cy.get('#VnfGroup_VNF .icon-browse').eq(0).click({force: true}).then(() => { |
| 476 | cy.getElementByDataTestsId('context-menu-delete').click({force: true}); |
| 477 | cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled'); |
| 478 | |
| 479 | cy.get('#VnfGroup_VNF .icon-browse').eq(0).click({force: true}).then(() => { |
| 480 | cy.getElementByDataTestsId('context-menu-undoDelete').click({force: true}); |
| 481 | cy.getElementByDataTestsId('deployBtn').should('have.attr', 'disabled'); |
| 482 | }); |
| 483 | }); |
| 484 | |
| 485 | |
| 486 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn') |
| 487 | .eq(0).click({force: true}).then(() => { |
| 488 | cy.getElementByDataTestsId('context-menu-delete').click({force: true}); |
| 489 | cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled'); |
| 490 | }) |
| 491 | }); |
| 492 | |
| 493 | it('Delete 2 from 3 VNF members and check request body of deploy', function () { |
| 494 | const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89"; |
| 495 | const SERVICE_TYPE: string = "TYLER SILVIA"; |
| 496 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 497 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 498 | |
| 499 | cy.server().route({ |
| 500 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 501 | method: 'POST', |
| 502 | status: 200, |
| 503 | response: "[]", |
| 504 | }).as("expectedPostAsyncInstantiation"); |
| 505 | |
| 506 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 507 | jsonBuilderAndMock.basicJson( |
| 508 | res, |
| 509 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 510 | 200, |
| 511 | 0, |
| 512 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 513 | ) |
| 514 | }); |
| 515 | |
| 516 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 517 | |
| 518 | jsonBuilderAndMock.basicJson( |
| 519 | res, |
| 520 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 521 | 200, 0, |
| 522 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 523 | ) |
| 524 | }); |
| 525 | |
| 526 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`); |
| 527 | cy.getElementByDataTestsId('deployBtn').should('have.attr', 'disabled'); |
| 528 | |
| 529 | for (let index = 0; index < 2; index++) { |
| 530 | cy.get('#VnfGroup_VNF .icon-browse').eq(index).click({force: true}).then(() => { |
| 531 | cy.getElementByDataTestsId('context-menu-delete').click({force: true}); |
| 532 | cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled'); |
| 533 | }); |
| 534 | } |
| 535 | |
| 536 | cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click(); |
| 537 | |
| 538 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 539 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/payloadTemplate1VnfGroupWith3MembersRequest.json').then((expectedResult) => { |
| 540 | expectedResult.vnfGroups.VNF_GROUP1_INSTANCE_ID.action = 'None'; |
| 541 | expectedResult.vnfGroups.VNF_GROUP1_INSTANCE_ID.vnfs.RELATED_VNF1_INSTANCE_ID.action = 'None_Delete'; |
| 542 | expectedResult.vnfGroups.VNF_GROUP1_INSTANCE_ID.vnfs.RELATED_VNF2_INSTANCE_ID.action = 'None_Delete'; |
| 543 | cy.deepCompare(xhr.request.body, expectedResult); |
| 544 | }); |
| 545 | }); |
| 546 | }); |
| 547 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 548 | it(`vnf group with vnf members, add group members option open modal`, () => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 549 | const SUBSCRIBER_ID: string = "global-customer-id"; |
| 550 | const SERVICE_TYPE: string = "service-instance-type"; |
| 551 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 552 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 553 | const SERVICE_INVARIANT_ID: string = '24632e6b-584b-4f45-80d4-fefd75fd9f14'; |
| 554 | const GROUP_ROLE: string = 'SERVICE-ACCESS'; |
| 555 | const GROUP_TYPE: string = 'LOAD-GROUP'; |
| 556 | |
| 557 | cy.server().route({ |
| 558 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 559 | method: 'POST', |
| 560 | status: 200, |
| 561 | response: "[]", |
| 562 | }).as("expectedPostAsyncInstantiation"); |
| 563 | |
| 564 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 565 | jsonBuilderAndMock.basicJson( |
| 566 | res, |
| 567 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 568 | 200, |
| 569 | 0, |
| 570 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 571 | ) |
| 572 | }); |
| 573 | |
| 574 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 575 | |
| 576 | jsonBuilderAndMock.basicJson( |
| 577 | res, |
| 578 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 579 | 200, 0, |
| 580 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 581 | ) |
| 582 | }); |
| 583 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => { |
| 584 | |
| 585 | jsonBuilderAndMock.basicJson( |
| 586 | res, |
| 587 | Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`, |
| 588 | 200, 0, |
| 589 | "VnfGroup_searchMembersResponse", |
| 590 | ) |
| 591 | }); |
| 592 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`); |
| 593 | |
| 594 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn') |
| 595 | .eq(0).click({force: true}).then(() => { |
| 596 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 597 | cy.getElementByDataTestsId('sourceModelName').contains("vDOROTHEA_Svc_vPRS"); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 598 | cy.getElementByDataTestsId('sourceModelInvariant').contains("24632e6b-584b-4f45-80d4-fefd75fd9f14"); |
| 599 | cy.get('#vnfName').eq(0).get('#VNF1_INSTANCE_NAME').contains('VNF1_INSTANCE_NAME'); |
| 600 | cy.get('#vnfName').eq(0).get('#VNF1_INSTANCE_ID').contains('VNF1_INSTANCE_ID'); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 601 | cy.getElementByDataTestsId('total-amount').should('have.text', '4 VNFs match your criteria |'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 602 | cy.getElementByDataTestsId('total-selected').should('have.text', '0 VNF selected'); |
| 603 | cy.getElementByDataTestsId('setMembersBtn').should('have.attr', 'disabled'); |
| 604 | testCheckbox(); |
| 605 | testResetAddMemberModal(); |
| 606 | testUpdateBtn(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 607 | }); |
| 608 | }); |
| 609 | }); |
| 610 | |
| 611 | it(`vnf group add member get optional members return empty table"`, () => { |
| 612 | const SUBSCRIBER_ID: string = "global-customer-id"; |
| 613 | const SERVICE_TYPE: string = "service-instance-type"; |
| 614 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 615 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 616 | const SERVICE_INVARIANT_ID: string = '24632e6b-584b-4f45-80d4-fefd75fd9f14'; |
| 617 | const GROUP_ROLE: string = 'SERVICE-ACCESS'; |
| 618 | const GROUP_TYPE: string = 'LOAD-GROUP'; |
| 619 | |
| 620 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 621 | jsonBuilderAndMock.basicJson( |
| 622 | res, |
| 623 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 624 | 200, |
| 625 | 0, |
| 626 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 627 | ) |
| 628 | }); |
| 629 | |
| 630 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 631 | |
| 632 | jsonBuilderAndMock.basicJson( |
| 633 | res, |
| 634 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 635 | 200, 0, |
| 636 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 637 | ) |
| 638 | }); |
| 639 | cy.server() |
| 640 | .route({ |
| 641 | method: 'GET', |
| 642 | status: 200, |
| 643 | url: Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`, |
| 644 | response: [] |
| 645 | }).as('VnfGroup_searchMembersResponse'); |
| 646 | |
| 647 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`); |
| 648 | |
| 649 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn') |
| 650 | .eq(0).click({force: true}).then(() => { |
| 651 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 652 | cy.getElementByDataTestsId('total-amount').should('have.text', '0 VNFs match your criteria |'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 653 | cy.getElementByDataTestsId('total-selected').should('have.text', '0 VNF selected'); |
| 654 | cy.get('.no-result').should('have.text', 'No VNFs were found that can belong to this group.'); |
| 655 | }); |
| 656 | }) |
| 657 | }); |
| 658 | |
| 659 | it('Check scaling policy - in Create new service mode', () => { |
| 660 | const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89"; |
| 661 | const SERVICE_TYPE: string = "TYLER SILVIA"; |
| 662 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 663 | const SERVICE_INVARIANT_ID: string = 'c989ab9a-33c7-46ec-b521-1b2daef5f047'; |
| 664 | const GROUP_ROLE: string = 'SERVICE-ACCESS'; |
| 665 | const GROUP_TYPE: string = 'LOAD-GROUP'; |
| 666 | const GROUP_NAME_TO_DEPLOY = 'groupingservicefortest..ResourceInstanceGroup..1'; |
| 667 | const NODE_ID = 'c2b300e6-45de-4e5e-abda-3032bee2de56'; |
| 668 | const FULL_GROUP_NAME = 'node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY; |
| 669 | let serviceModel: JSON; |
| 670 | let basicServiceInstance: JSON; |
| 671 | |
| 672 | cy.server().route({ |
| 673 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 674 | method: 'POST', |
| 675 | status: 200, |
| 676 | response: "[]", |
| 677 | }).as("expectedPostAsyncInstantiation"); |
| 678 | |
| 679 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 680 | serviceModel = res; |
| 681 | }); |
| 682 | |
| 683 | cy.readFile('./cypress/support/jsonBuilders/mocks/jsons/vnfGroupBasicServiceInstance.json').then((res) => { |
| 684 | res.optionalGroupMembersMap = {}; |
| 685 | basicServiceInstance = res; |
| 686 | }); |
| 687 | |
| 688 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => { |
| 689 | jsonBuilderAndMock.basicJson( |
| 690 | res, |
| 691 | Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`, |
| 692 | 200, 0, |
| 693 | "VnfGroup_searchMembersResponse", |
| 694 | ) |
| 695 | }); |
| 696 | |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 697 | cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((reduxRes) => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 698 | |
| 699 | reduxRes.service.serviceHierarchy[SERVICE_MODEL_ID] = serviceModel; |
| 700 | |
| 701 | reduxRes.service.serviceInstance[SERVICE_MODEL_ID] = basicServiceInstance; |
| 702 | |
| 703 | cy.setReduxState(<any>reduxRes); |
| 704 | |
| 705 | cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + SERVICE_MODEL_ID); |
| 706 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).find(`[data-tests-id='node-type-indicator']`).contains('G'); |
| 707 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY).contains('' + GROUP_NAME_TO_DEPLOY); |
| 708 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').get('i').should('have.class', 'fa-plus-circle'); |
| 709 | |
| 710 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').click({force: true}); |
| 711 | cy.getElementByDataTestsId('node-' + GROUP_NAME_TO_DEPLOY + '-add-btn').click({force: true}); |
| 712 | |
| 713 | cy.getElementByDataTestsId('node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY + '-menu-btn').each((row, index) => { |
| 714 | cy.wrap(row).click({force: true}).then(() => { |
| 715 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 716 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 717 | }); |
| 718 | }); |
| 719 | }); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 720 | }); |
| 721 | }); |
| 722 | |
| 723 | it(`Check scaling policy in Edit mode`, () => { |
| 724 | const SUBSCRIBER_ID: string = "global-customer-id"; |
| 725 | const SERVICE_TYPE: string = "service-instance-type"; |
| 726 | const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb"; |
| 727 | const SERVICE_MODEL_ID: string = '4117a0b6-e234-467d-b5b9-fe2f68c8b0fc'; |
| 728 | const SERVICE_INVARIANT_ID: string = '24632e6b-584b-4f45-80d4-fefd75fd9f14'; |
| 729 | const GROUP_ROLE: string = 'SERVICE-ACCESS'; |
| 730 | const GROUP_TYPE: string = 'LOAD-GROUP'; |
| 731 | const NODE_ID = 'daeb6568-cef8-417f-9075-ed259ce59f48'; |
| 732 | const GROUP_NAME_TO_DEPLOY = 'groupingservicefortest..ResourceInstanceGroup..0'; |
| 733 | const FULL_GROUP_NAME = 'node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY; |
| 734 | |
| 735 | cy.server().route({ |
| 736 | url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk', |
| 737 | method: 'POST', |
| 738 | status: 200, |
| 739 | response: "[]", |
| 740 | }).as("expectedPostAsyncInstantiation"); |
| 741 | |
| 742 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/groupingServiceRoleResponse.json').then((res) => { |
| 743 | jsonBuilderAndMock.basicJson( |
| 744 | res, |
| 745 | Cypress.config('baseUrl') + `/rest/models/services/${SERVICE_MODEL_ID}`, |
| 746 | 200, |
| 747 | 0, |
| 748 | "ServiceTreeWithMultipleChildren_serviceModel", |
| 749 | ) |
| 750 | }); |
| 751 | |
| 752 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/serviceWithVnfGroupsChildren_serviceInstance.json').then((res) => { |
| 753 | |
| 754 | jsonBuilderAndMock.basicJson( |
| 755 | res, |
| 756 | Cypress.config('baseUrl') + `/aai_get_service_instance_topology/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INSTANCE_ID}`, |
| 757 | 200, 0, |
| 758 | "serviceWithVnfGroupsChildren_serviceInstance", |
| 759 | ) |
| 760 | }); |
| 761 | |
| 762 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => { |
| 763 | |
| 764 | jsonBuilderAndMock.basicJson( |
| 765 | res, |
| 766 | Cypress.config('baseUrl') + `/aai_search_group_members/${SUBSCRIBER_ID}/${SERVICE_TYPE}/${SERVICE_INVARIANT_ID}/${GROUP_TYPE}/${GROUP_ROLE}`, |
| 767 | 200, 0, |
| 768 | "VnfGroup_searchMembersResponse", |
| 769 | ) |
| 770 | }); |
| 771 | |
| 772 | cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&mode=EDIT`); |
| 773 | cy.getElementByDataTestsId('node-' + NODE_ID + '-' + GROUP_NAME_TO_DEPLOY + '-menu-btn') |
| 774 | .eq(0).click({force: true}).then(() => { |
| 775 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 776 | cy.getElementByDataTestsId('total-amount').should('have.text', '4 VNFs match your criteria |'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 777 | cy.get('.allCheckboxAreSelected input').click({force: true}); |
| 778 | cy.getElementByDataTestsId('setMembersBtn').click({force: true}).then(() => { |
| 779 | checkIsErrorAppear(true, FULL_GROUP_NAME, 4, 0); |
| 780 | |
| 781 | clickOnVnfMemberAndAssertScaling(6, 'context-menu-remove', true, FULL_GROUP_NAME, 4, 0); |
| 782 | clickOnVnfMemberAndAssertScaling(5, 'context-menu-remove', true, FULL_GROUP_NAME, 4, 0); |
| 783 | clickOnVnfMemberAndAssertScaling(0, 'context-menu-delete', false, FULL_GROUP_NAME, 4, 0); |
| 784 | clickOnVnfMemberAndAssertScaling(0, 'context-menu-undoDelete', true, FULL_GROUP_NAME, 4, 0); |
| 785 | clickOnVnfMemberAndAssertScaling(4, 'context-menu-remove', false, FULL_GROUP_NAME, 4, 0); |
| 786 | testResetAddMemberModal(); |
| 787 | testUpdateBtn(); |
| 788 | }) |
| 789 | }); |
| 790 | }); |
| 791 | }); |
| 792 | |
| 793 | function removeVnfGroup() { |
| 794 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn') |
| 795 | .click({force: true}); |
| 796 | cy.getElementByDataTestsId('context-menu-remove').click({force: true}); |
| 797 | } |
| 798 | |
| 799 | function testUpdateBtn() { |
| 800 | cy.getElementByDataTestsId('deployBtn').should('have.text', 'UPDATE').click(); |
| 801 | cy.getReduxState().then((state) => { |
| 802 | cy.wait('@expectedPostAsyncInstantiation').then(xhr => { |
| 803 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/vnfGroupWithExistingAndNewVnfMembers.json').then((expectedResult) => { |
| 804 | cy.deepCompare(xhr.request.body, expectedResult); |
| 805 | }); |
| 806 | }); |
| 807 | }); |
| 808 | } |
| 809 | |
| 810 | function testCheckbox() { |
| 811 | let totalNumber = 4; |
| 812 | cy.get('.allCheckboxAreSelected input').click({force: true}); |
| 813 | cy.getElementByDataTestsId('setMembersBtn').should('not.have.attr', 'disabled'); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 814 | cy.getElementByDataTestsId('numberOfNotHideRows').contains(totalNumber); |
| 815 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(totalNumber); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 816 | cy.get('.sdcCheckboxMember input').eq(0).click({force: true}); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 817 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(totalNumber - 1); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 818 | cy.get('.sdcCheckboxMember input').eq(1).click({force: true}); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 819 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(totalNumber - 2); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 820 | cy.get('.allCheckboxAreSelected input').click({force: true}); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 821 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(totalNumber); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 822 | cy.get('.allCheckboxAreSelected input').click({force: true}); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 823 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(0); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 824 | |
| 825 | cy.getElementByDataTestsId("vnf-members-search").find('input').type("2.0"); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 826 | cy.getElementByDataTestsId('numberOfNotHideRows').contains(1); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 827 | cy.getElementByDataTestsId("vnf-members-search").find('input').clear().type("vnf1"); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 828 | cy.getElementByDataTestsId('numberOfNotHideRows').contains(1); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 829 | cy.get('.allCheckboxAreSelected input').click({force: true}); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 830 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(1); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 831 | cy.getElementByDataTestsId("vnf-members-search").find('input').clear(); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 832 | cy.getElementByDataTestsId('numberOfSelectedRows').contains(1); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 833 | |
| 834 | cy.getElementByDataTestsId('setMembersBtn').click({force: true}); |
| 835 | //check second time behavior (selected VNFs should be filtered) |
| 836 | cy.getElementByDataTestsId('node-daeb6568-cef8-417f-9075-ed259ce59f48-groupingservicefortest..ResourceInstanceGroup..0-menu-btn') |
| 837 | .eq(1).click({force: true}).then(() => { |
| 838 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 839 | cy.getElementByDataTestsId('numberOfNotHideRows').contains(totalNumber - 1); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 840 | cy.getElementByDataTestsId('cancelBtn').click({force: true}); |
| 841 | }); |
| 842 | }); |
| 843 | |
| 844 | } |
| 845 | function testResetAddMemberModal(): void{ |
| 846 | cy.getElementByDataTestsId('node-groupingservicefortest..ResourceInstanceGroup..1-add-btn').click({force: true}) |
| 847 | .getElementByDataTestsId('node-c2b300e6-45de-4e5e-abda-3032bee2de56-groupingservicefortest..ResourceInstanceGroup..1-menu-btn').eq(0).click({force: true}).then(() => { |
| 848 | cy.getElementByDataTestsId('context-menu-addGroupMember').click({force: true}).then(() => { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 849 | cy.getElementByDataTestsId('numberOfNotHideRows').contains(0); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 850 | cy.getElementByDataTestsId('cancelBtn').click({force: true}); |
| 851 | }); |
| 852 | cy.getElementByDataTestsId('node-c2b300e6-45de-4e5e-abda-3032bee2de56-groupingservicefortest..ResourceInstanceGroup..1-menu-btn').eq(0).click({force: true}).then(() => { |
| 853 | cy.getElementByDataTestsId('context-menu-remove').click({force: true}); |
| 854 | }); |
| 855 | }); |
| 856 | } |
| 857 | function checkIsErrorAppear(isError: boolean, groupRowId: string, limit: number, index: number) { |
| 858 | const isErrorPrefix = isError ? '' : 'not.'; |
| 859 | cy.getElementByDataTestsId('error-msg-wrapper').should(isErrorPrefix + 'exist'); |
| 860 | cy.getElementByDataTestsId('deployBtn').should(isErrorPrefix + 'have.attr', 'disabled'); |
| 861 | cy.getElementByDataTestsId(groupRowId).eq(index).find("[data-tests-id='scaling-policy']").should(isErrorPrefix + 'have.text', 'Limit' + limit); |
| 862 | cy.getElementByDataTestsId('error-msg-title').should(isErrorPrefix + 'exist'); |
| 863 | cy.getElementByDataTestsId('error-msg-sub-title').should(isErrorPrefix + 'exist'); |
| 864 | cy.getElementByDataTestsId('error-msg-description').should(isErrorPrefix + 'exist'); |
| 865 | } |
| 866 | |
| 867 | function clickOnVnfMemberAndAssertScaling(childIndex: number, menuItemTestId: string, isError: boolean, groupRowId: string, limit: number, index: number) { |
| 868 | cy.get('.tree-children').find('.node-wrapper').eq(childIndex).find('.icon-browse').click({force: true}) |
| 869 | .getElementByDataTestsId(menuItemTestId).click({force: true}).then(() => { |
| 870 | checkIsErrorAppear(isError, groupRowId, limit, index); |
| 871 | }); |
| 872 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 873 | } |
| 874 | ); |
| 875 | }); |