blob: f111189fc432027ef11059dfaab86500b14507e0 [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
103 it(`Upgrade a VFModule`, function () {
104 cy.initDrawingBoardUserPermission();
105 initServicePlanning("EDIT",
106 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
107 upgradeTheVFM();
108 undoUpgradeForVFM();
109 upgradeTheVFM();
110 cy.getDrawingBoardDeployBtn().click();
111 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
112 expect(Object(xhr.request.body).action).to.equal("None_Upgrade");
113 expect(Object(xhr.request.body).vnfs['VNF2_INSTANCE_ID'].action).to.equal("None_Upgrade");
114 expect(Object(xhr.request.body).vnfs['VNF2_INSTANCE_ID'].vfModules['dc229cd8-c132-4455-8517-5c1787c18b14']['3ef042c4-259f-45e0-9aba-0989bd8d1cc5'].action).to.equal("None_Upgrade");
115 });
116 });
117
118 it(`Upgrade a VFModule, Negative - latest version doesn't exist, upgrade button shouldn't exist`, function () {
119 setLatestVersionMockToEmptyResponse(serviceInvariantId);
120 cy.initDrawingBoardUserPermission();
121 initServicePlanning("EDIT",
122 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
123 verifyMenuActionUpgradeDoesNotExist();
124 });
125
126 });
127
Ittay Stern0b2078f2019-10-23 17:47:34 +0300128 describe('More UI tests', () => {
129
130 beforeEach(() => {
Ittay Stern32dbf802019-10-29 12:58:49 +0200131 cy.clearSessionStorage();
Ittay Stern0b2078f2019-10-23 17:47:34 +0300132 cy.setTestApiParamToVNF();
133 cy.initVidMock();
134 cy.login();
135 });
136
137 afterEach(() => {
138 cy.screenshot();
139 });
140
141 it(`Upgrade a VFModule: another case e2e`, function () {
142
143 const serviceType = 'Emanuel';
144 const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
145 const serviceModelId = '06c415d8-afc2-4bcb-a131-e4db4b8e96ce';
146 const serviceInstanceId = '6196ab1f-2349-4b32-9b6c-cffeb0ccc79c';
147 const serviceInvariantUuid = "b3a1a119-dede-4ed0-b077-2a617fa519a3";
148
149 cy.initDrawingBoardUserPermission();
150
151 cy.route(`**/rest/models/services/${serviceModelId}`,
152 'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json')
153 .as('serviceModel2');
154
155 cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
156 'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json')
157 .as('serviceInstance2');
158
159 cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`,
160 {
161 "modelVersionId": "d9a5b318-187e-476d-97f7-a15687a927a9",
162 "modelName": "xbi test module replace",
163 "modelVersion": "2.0",
164 "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
165 "resourceVersion": "1571769586156",
166 "modelDescription": "test module replacement feature",
167 "orchestrationType": null
168 }
169 ).as("newestModelVersion2");
170
171 cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);
172
173 upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0');
174
175 mockAsyncBulkResponse();
176 cy.getDrawingBoardDeployBtn().click();
177
178 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
179 cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json').then((expectedResult) => {
180 cy.deepCompare(xhr.request.body, expectedResult);
181 });
182 });
183
184 });
185
186 });
187
188
Ittay Stern567c9372019-10-23 17:47:34 +0300189 function mockAsyncBulkResponse() {
190 cy.server().route({
191 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
192 method: 'POST',
193 status: 200,
194 response: "[]",
195 }).as("expectedPostAsyncInstantiation");
196 }
197
198 function verifyMenuActionUpgradeDoesNotExist() {
199 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
200 .getElementByDataTestsId('context-menu-upgrade').should('not.exist');
201 }
202
203 function setLatestVersionMockToEmptyResponse(serviceUuid: string) {
204 cy.server().route({
205 url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + serviceUuid,
206 method: 'GET',
207 status: 200,
208 response: {},
209 }).as("expectLatestServiceModelUpgradeVersion")
210 }
211
Ittay Stern0b2078f2019-10-23 17:47:34 +0300212 function upgradeTheVFM(treeNodeId = 'node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14'): Chainable<any> {
213 return cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click()
Ittay Stern567c9372019-10-23 17:47:34 +0300214 .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade");
215 }
216
217 function undoUpgradeForVFM() {
218 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
219 .drawingBoardTreeClickOnContextMenuOptionByName("Undo Upgrade");
220 }
221
222 function changeServiceModel(serviceModel: ServiceModel) {
223 serviceModel.service.uuid = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
224 return serviceModel;
225 }
226});