blob: 09734472cb1b0d428e0ec3bc8b2e7d50ca58cdae [file] [log] [blame]
Ittay Stern567c9372019-10-23 17:47:34 +03001///<reference path="../../../node_modules/cypress/types/index.d.ts"/> / <reference types="Cypress" />
2import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
3import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
4import {AaiServiceInstancesModel} from '../../support/jsonBuilders/models/serviceInstances.model';
5import {AAISubViewEditModel} from '../../support/jsonBuilders/models/aaiSubViewEdit.model';
6
7const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
8const SUBSCRIBER_ID = "e433710f-9217-458d-a79d-1c7aff376d89";
9const SERVICE_MODEL_ID: string = '6e59c5de-f052-46fa-aa7e-2fca9d674c44';
10
11export const initServicePlanning = function (viewOrEdit: string, customModelFilePath?: string) {
12 const SERVICE_TYPE: string = "TYLER SILVIA";
13 const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
14 if (Cypress._.isNil(customModelFilePath)) {
15 customModelFilePath = '../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json';
16 }
17
18 cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json').then((res) => {
19 jsonBuilderAndMock.basicJson(
20 res,
21 Cypress.config('baseUrl') + "/rest/models/services/6e59c5de-f052-46fa-aa7e-2fca9d674c44",
22 200,
23 0,
24 "ServiceTreeWithMultipleChildren_serviceModel",
25 )
26 });
27
28 cy.readFile(customModelFilePath).then((res) => {
29 jsonBuilderAndMock.basicJson(
30 res,
31 Cypress.config('baseUrl') + "/aai_get_service_instance_topology/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
32 200, 0,
33 "ServiceTreeWithMultipleChildren_serviceInstance",
34 );
35 });
36 cy.openIframe(`app/ui/#/servicePlanning/${viewOrEdit}?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
37};
38
39
40describe('View Edit Page: Upgrade VFModule', function () {
41 describe('basic UI tests', () => {
42 let serviceUuid = SERVICE_MODEL_ID;
43 let serviceInvariantId = "d27e42cf-087e-4d31-88ac-6c4b7585f800";
44
45 let jsonBuilderAAIService: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
46 let jsonBuilderAAISubViewEditModel: JsonBuilder<AAISubViewEditModel> = new JsonBuilder<AAISubViewEditModel>();
47 let jsonBuilderAaiServiceInstances: JsonBuilder<AaiServiceInstancesModel> = new JsonBuilder<AaiServiceInstancesModel>();
48
49 beforeEach(() => {
Ittay Stern32dbf802019-10-29 12:58:49 +020050 cy.clearSessionStorage();
Ittay Stern567c9372019-10-23 17:47:34 +030051 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
52 jsonBuilderAAIService.basicJson(
53 res,
54 Cypress.config('baseUrl') + "/rest/models/services/" + serviceUuid,
55 200, 0,
56 "service-complexService",
57 changeServiceModel)
58 });
59
60 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubViewEditForComplexService.json').then((res) => {
61 jsonBuilderAAISubViewEditModel.basicJson(
62 res,
63 Cypress.config('baseUrl') + "/aai_sub_viewedit/**/**/**/3f93c7cb-2fd0-4557-9514-e189b7b04f9d",
64 200,
65 0,
66 "aai-sub-view-edit")
67 });
68
69 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiServiceInstances.json').then((res) => {
70 jsonBuilderAaiServiceInstances.basicJson(
71 res,
72 Cypress.config('baseUrl') + "/search_service_instances**",
73 200,
74 0,
75 "aai-get-service-instances")
76 });
77
78 mockAsyncBulkResponse();
79 cy.initGetAAISubDetails();
Ittay Stern0b2078f2019-10-23 17:47:34 +030080 cy.initVidMock();
81 cy.mockLatestVersionForService(serviceUuid, serviceInvariantId);
Ittay Stern567c9372019-10-23 17:47:34 +030082 cy.setReduxState();
83 cy.permissionVidMock();
84 cy.login();
85 });
86
87 afterEach(() => {
88 cy.screenshot();
89 });
90
91 it(`should display the more actions button if user is permitted`, function () {
92 let SERVICE_INSTANCE_ID="3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
Ittay Stern0b2078f2019-10-23 17:47:34 +030093 let SERVICE_TYPE="TYLER%20SILVIA";
94 cy.visit(`/serviceModels.htm#/instantiate?subscriberId=${SUBSCRIBER_ID}&subscriberName=SILVIA%20ROBBINS&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&aaiModelVersionId=${serviceUuid}&isPermitted=true`);
Ittay Stern567c9372019-10-23 17:47:34 +030095
96 cy.get("[data-tests-id='service-instanceId-th-id']").should('contain', SERVICE_INSTANCE_ID);
97 cy.getElementByDataTestsId("show-new-screen").should('be.visible').should('have.text', 'More actions').click();
98
99 cy.url().should('contain',
100 `servicePlanning/EDIT?serviceModelId=${serviceUuid}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
101 });
102
Amir Skalka8d17bc32019-12-10 16:47:11 +0200103 it(`Upgrade a VF Module`, function () {
Ittay Stern567c9372019-10-23 17:47:34 +0300104 cy.initDrawingBoardUserPermission();
105 initServicePlanning("EDIT",
106 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
Amir Skalka8d17bc32019-12-10 16:47:11 +0200107 upgradeTheVFM('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1', true);
Eylon Malin590738f2019-11-25 14:07:15 +0200108 assertVfModuleActionInRedux("None_Upgrade");
Ittay Stern567c9372019-10-23 17:47:34 +0300109 undoUpgradeForVFM();
Eylon Malin590738f2019-11-25 14:07:15 +0200110 assertVfModuleActionInRedux("None");
Amir Skalka8d17bc32019-12-10 16:47:11 +0200111 upgradeTheVFM('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',true);
Ittay Stern567c9372019-10-23 17:47:34 +0300112 cy.getDrawingBoardDeployBtn().click();
113 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
Yoav Schneidermanbda996b2019-11-21 16:17:55 +0200114 const requestBody = Object(xhr.request.body);
115 const vfModuleRequest = requestBody.vnfs['VNF2_INSTANCE_ID'].vfModules['vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1']['2c1ca484-cbc2-408b-ab86-25a2c15ce280'];
Amir Skalka8d17bc32019-12-10 16:47:11 +0200116 expect(requestBody.action).to.equal("None_Upgrade");
Yoav Schneidermanbda996b2019-11-21 16:17:55 +0200117 expect(requestBody.vnfs['VNF2_INSTANCE_ID'].action).to.equal("None_Upgrade");
118 expect(vfModuleRequest.action).to.equal("None_Upgrade");
Ittay Stern567c9372019-10-23 17:47:34 +0300119 });
120 });
121
122 it(`Upgrade a VFModule, Negative - latest version doesn't exist, upgrade button shouldn't exist`, function () {
123 setLatestVersionMockToEmptyResponse(serviceInvariantId);
124 cy.initDrawingBoardUserPermission();
125 initServicePlanning("EDIT",
126 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
127 verifyMenuActionUpgradeDoesNotExist();
128 });
129
130 });
131
Amir Skalka8d17bc32019-12-10 16:47:11 +0200132 describe('More UI test', () => {
Ittay Stern0b2078f2019-10-23 17:47:34 +0300133
134 beforeEach(() => {
Ittay Stern32dbf802019-10-29 12:58:49 +0200135 cy.clearSessionStorage();
Ittay Stern0b2078f2019-10-23 17:47:34 +0300136 cy.setTestApiParamToVNF();
137 cy.initVidMock();
138 cy.login();
139 });
140
141 afterEach(() => {
142 cy.screenshot();
143 });
144
145 it(`Upgrade a VFModule: another case e2e`, function () {
146
147 const serviceType = 'Emanuel';
148 const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
149 const serviceModelId = '06c415d8-afc2-4bcb-a131-e4db4b8e96ce';
150 const serviceInstanceId = '6196ab1f-2349-4b32-9b6c-cffeb0ccc79c';
151 const serviceInvariantUuid = "b3a1a119-dede-4ed0-b077-2a617fa519a3";
152
153 cy.initDrawingBoardUserPermission();
154
155 cy.route(`**/rest/models/services/${serviceModelId}`,
156 'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json')
157 .as('serviceModel2');
158
159 cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
160 'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json')
161 .as('serviceInstance2');
162
163 cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`,
164 {
165 "modelVersionId": "d9a5b318-187e-476d-97f7-a15687a927a9",
166 "modelName": "xbi test module replace",
167 "modelVersion": "2.0",
168 "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
169 "resourceVersion": "1571769586156",
170 "modelDescription": "test module replacement feature",
171 "orchestrationType": null
172 }
173 ).as("newestModelVersion2");
174
175 cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);
176
Amir Skalka8d17bc32019-12-10 16:47:11 +0200177 upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0', false);
Ittay Stern0b2078f2019-10-23 17:47:34 +0300178
179 mockAsyncBulkResponse();
180 cy.getDrawingBoardDeployBtn().click();
181
182 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
183 cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json').then((expectedResult) => {
184 cy.deepCompare(xhr.request.body, expectedResult);
185 });
186 });
187
188 });
189
190 });
191
192
Ittay Stern567c9372019-10-23 17:47:34 +0300193 function mockAsyncBulkResponse() {
194 cy.server().route({
195 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
196 method: 'POST',
197 status: 200,
198 response: "[]",
199 }).as("expectedPostAsyncInstantiation");
200 }
201
202 function verifyMenuActionUpgradeDoesNotExist() {
203 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
204 .getElementByDataTestsId('context-menu-upgrade').should('not.exist');
205 }
206
207 function setLatestVersionMockToEmptyResponse(serviceUuid: string) {
208 cy.server().route({
209 url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + serviceUuid,
210 method: 'GET',
211 status: 200,
212 response: {},
Sara Weisseed69432019-11-20 14:50:33 +0200213 }).as("expectLatestServiceModelUpgradeVersion");
Ittay Stern567c9372019-10-23 17:47:34 +0300214 }
215
Amir Skalka8d17bc32019-12-10 16:47:11 +0200216 function upgradeTheVFM(treeNodeId: string, shouldVGCheckboxExist :boolean) {
Sara Weisseed69432019-11-20 14:50:33 +0200217 cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click()
Ittay Stern567c9372019-10-23 17:47:34 +0300218 .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade");
Sara Weisseed69432019-11-20 14:50:33 +0200219 // The following is needed when enabling FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS
Yoav Schneidermanbda996b2019-11-21 16:17:55 +0200220
221 cy.getElementByDataTestsId('retainAssignments').click();
Amir Skalka8d17bc32019-12-10 16:47:11 +0200222 if (shouldVGCheckboxExist) {
223 cy.getElementByDataTestsId('retainVolumeGroups').click();
224 }
225 else {
226 cy.getElementByDataTestsId('retainVolumeGroups').should('not.exist');
227 }
Alexey Sandlerabb59852019-11-26 21:44:18 +0200228 cy.getElementByDataTestsId('sdncPreLoad').click();
Yoav Schneiderman35b6e052019-11-25 13:47:12 +0200229 cy.screenshot();
Sara Weisseed69432019-11-20 14:50:33 +0200230 cy.getElementByDataTestsId('form-set').click();
Ittay Stern567c9372019-10-23 17:47:34 +0300231 }
232
233 function undoUpgradeForVFM() {
Sara Weisseed69432019-11-20 14:50:33 +0200234 cy.getElementByDataTestsId('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1-menu-btn').click()
Ittay Stern567c9372019-10-23 17:47:34 +0300235 .drawingBoardTreeClickOnContextMenuOptionByName("Undo Upgrade");
236 }
237
238 function changeServiceModel(serviceModel: ServiceModel) {
239 serviceModel.service.uuid = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
240 return serviceModel;
241 }
Eylon Malin590738f2019-11-25 14:07:15 +0200242
243 function assertVfModuleActionInRedux(expectedState:string) {
244 cy.getReduxState().then((state) => {
245 const vfModule = state.service.serviceInstance['6e59c5de-f052-46fa-aa7e-2fca9d674c44']
246 .vnfs["VNF2_INSTANCE_ID"]
247 .vfModules["vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1"]["2c1ca484-cbc2-408b-ab86-25a2c15ce280"];
248 expect(vfModule.action).to.equal(expectedState)
249 });
250 }
Ittay Stern567c9372019-10-23 17:47:34 +0300251});