blob: 0d94e600c9833d999b5d22460911529ba3906ead [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(() => {
50 cy.window().then((win) => {
51 win.sessionStorage.clear();
52 });
53 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
54 jsonBuilderAAIService.basicJson(
55 res,
56 Cypress.config('baseUrl') + "/rest/models/services/" + serviceUuid,
57 200, 0,
58 "service-complexService",
59 changeServiceModel)
60 });
61
62 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubViewEditForComplexService.json').then((res) => {
63 jsonBuilderAAISubViewEditModel.basicJson(
64 res,
65 Cypress.config('baseUrl') + "/aai_sub_viewedit/**/**/**/3f93c7cb-2fd0-4557-9514-e189b7b04f9d",
66 200,
67 0,
68 "aai-sub-view-edit")
69 });
70
71 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiServiceInstances.json').then((res) => {
72 jsonBuilderAaiServiceInstances.basicJson(
73 res,
74 Cypress.config('baseUrl') + "/search_service_instances**",
75 200,
76 0,
77 "aai-get-service-instances")
78 });
79
80 mockAsyncBulkResponse();
81 cy.initGetAAISubDetails();
Ittay Stern0b2078f2019-10-23 17:47:34 +030082 cy.initVidMock();
83 cy.mockLatestVersionForService(serviceUuid, serviceInvariantId);
Ittay Stern567c9372019-10-23 17:47:34 +030084 cy.setReduxState();
85 cy.permissionVidMock();
86 cy.login();
87 });
88
89 afterEach(() => {
90 cy.screenshot();
91 });
92
93 it(`should display the more actions button if user is permitted`, function () {
94 let SERVICE_INSTANCE_ID="3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
Ittay Stern0b2078f2019-10-23 17:47:34 +030095 let SERVICE_TYPE="TYLER%20SILVIA";
96 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 +030097
98 cy.get("[data-tests-id='service-instanceId-th-id']").should('contain', SERVICE_INSTANCE_ID);
99 cy.getElementByDataTestsId("show-new-screen").should('be.visible').should('have.text', 'More actions').click();
100
101 cy.url().should('contain',
102 `servicePlanning/EDIT?serviceModelId=${serviceUuid}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
103 });
104
105 it(`Upgrade a VFModule`, function () {
106 cy.initDrawingBoardUserPermission();
107 initServicePlanning("EDIT",
108 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
109 upgradeTheVFM();
110 undoUpgradeForVFM();
111 upgradeTheVFM();
112 cy.getDrawingBoardDeployBtn().click();
113 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
114 expect(Object(xhr.request.body).action).to.equal("None_Upgrade");
115 expect(Object(xhr.request.body).vnfs['VNF2_INSTANCE_ID'].action).to.equal("None_Upgrade");
116 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");
117 });
118 });
119
120 it(`Upgrade a VFModule, Negative - latest version doesn't exist, upgrade button shouldn't exist`, function () {
121 setLatestVersionMockToEmptyResponse(serviceInvariantId);
122 cy.initDrawingBoardUserPermission();
123 initServicePlanning("EDIT",
124 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
125 verifyMenuActionUpgradeDoesNotExist();
126 });
127
128 });
129
Ittay Stern0b2078f2019-10-23 17:47:34 +0300130 describe('More UI tests', () => {
131
132 beforeEach(() => {
133 cy.window().then((win) => {win.sessionStorage.clear();});
134 cy.setTestApiParamToVNF();
135 cy.initVidMock();
136 cy.login();
137 });
138
139 afterEach(() => {
140 cy.screenshot();
141 });
142
143 it(`Upgrade a VFModule: another case e2e`, function () {
144
145 const serviceType = 'Emanuel';
146 const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
147 const serviceModelId = '06c415d8-afc2-4bcb-a131-e4db4b8e96ce';
148 const serviceInstanceId = '6196ab1f-2349-4b32-9b6c-cffeb0ccc79c';
149 const serviceInvariantUuid = "b3a1a119-dede-4ed0-b077-2a617fa519a3";
150
151 cy.initDrawingBoardUserPermission();
152
153 cy.route(`**/rest/models/services/${serviceModelId}`,
154 'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json')
155 .as('serviceModel2');
156
157 cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
158 'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json')
159 .as('serviceInstance2');
160
161 cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`,
162 {
163 "modelVersionId": "d9a5b318-187e-476d-97f7-a15687a927a9",
164 "modelName": "xbi test module replace",
165 "modelVersion": "2.0",
166 "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
167 "resourceVersion": "1571769586156",
168 "modelDescription": "test module replacement feature",
169 "orchestrationType": null
170 }
171 ).as("newestModelVersion2");
172
173 cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);
174
175 upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0');
176
177 mockAsyncBulkResponse();
178 cy.getDrawingBoardDeployBtn().click();
179
180 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
181 cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json').then((expectedResult) => {
182 cy.deepCompare(xhr.request.body, expectedResult);
183 });
184 });
185
186 });
187
188 });
189
190
Ittay Stern567c9372019-10-23 17:47:34 +0300191 function mockAsyncBulkResponse() {
192 cy.server().route({
193 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
194 method: 'POST',
195 status: 200,
196 response: "[]",
197 }).as("expectedPostAsyncInstantiation");
198 }
199
200 function verifyMenuActionUpgradeDoesNotExist() {
201 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
202 .getElementByDataTestsId('context-menu-upgrade').should('not.exist');
203 }
204
205 function setLatestVersionMockToEmptyResponse(serviceUuid: string) {
206 cy.server().route({
207 url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + serviceUuid,
208 method: 'GET',
209 status: 200,
210 response: {},
211 }).as("expectLatestServiceModelUpgradeVersion")
212 }
213
Ittay Stern0b2078f2019-10-23 17:47:34 +0300214 function upgradeTheVFM(treeNodeId = 'node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14'): Chainable<any> {
215 return cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click()
Ittay Stern567c9372019-10-23 17:47:34 +0300216 .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade");
217 }
218
219 function undoUpgradeForVFM() {
220 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
221 .drawingBoardTreeClickOnContextMenuOptionByName("Undo Upgrade");
222 }
223
224 function changeServiceModel(serviceModel: ServiceModel) {
225 serviceModel.service.uuid = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
226 return serviceModel;
227 }
228});