summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts
blob: ac36f67716a9e18af6326de694b5bbbb810b61c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
///<reference path="../../../node_modules/cypress/types/index.d.ts"/> / <reference types="Cypress" />
import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
import {AaiServiceInstancesModel} from '../../support/jsonBuilders/models/serviceInstances.model';
import {AAISubViewEditModel} from '../../support/jsonBuilders/models/aaiSubViewEdit.model';

const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
const SUBSCRIBER_ID = "e433710f-9217-458d-a79d-1c7aff376d89";
const SERVICE_MODEL_ID: string = '6e59c5de-f052-46fa-aa7e-2fca9d674c44';

export const initServicePlanning = function (viewOrEdit: string, customModelFilePath?: string) {
  const SERVICE_TYPE: string = "TYLER SILVIA";
  const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
  if (Cypress._.isNil(customModelFilePath)) {
    customModelFilePath = '../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceInstance.json';
  }

  cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json').then((res) => {
    res.service.instantiationType = "A-La-Carte";
    res.service.vidNotions.instantiationType = "ALaCarte";
    jsonBuilderAndMock.basicJson(
      res,
      Cypress.config('baseUrl') + "/rest/models/services/6e59c5de-f052-46fa-aa7e-2fca9d674c44",
      200,
      0,
      "ServiceTreeWithMultipleChildren_serviceModel",
    )
  });

  cy.readFile(customModelFilePath).then((res) => {
    jsonBuilderAndMock.basicJson(
      res,
      Cypress.config('baseUrl') + "/aai_get_service_instance_topology/e433710f-9217-458d-a79d-1c7aff376d89/TYLER SILVIA/f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
      200, 0,
      "ServiceTreeWithMultipleChildren_serviceInstance",
    );
  });
  cy.openIframe(`app/ui/#/servicePlanning/${viewOrEdit}?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
};


describe('View Edit Page: Upgrade VFModule', function () {
  describe('basic UI tests', () => {
    let serviceUuid = SERVICE_MODEL_ID;
    let serviceInvariantId = "d27e42cf-087e-4d31-88ac-6c4b7585f800";

    let jsonBuilderAAIService: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
    let jsonBuilderAAISubViewEditModel: JsonBuilder<AAISubViewEditModel> = new JsonBuilder<AAISubViewEditModel>();
    let jsonBuilderAaiServiceInstances: JsonBuilder<AaiServiceInstancesModel> = new JsonBuilder<AaiServiceInstancesModel>();

    beforeEach(() => {
      cy.clearSessionStorage();
      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
        jsonBuilderAAIService.basicJson(
          res,
          Cypress.config('baseUrl') + "/rest/models/services/" + serviceUuid,
          200, 0,
          "service-complexService",
          changeServiceModel)
      });

      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubViewEditForComplexService.json').then((res) => {
        jsonBuilderAAISubViewEditModel.basicJson(
          res,
          Cypress.config('baseUrl') + "/aai_sub_viewedit/**/**/**/3f93c7cb-2fd0-4557-9514-e189b7b04f9d",
          200,
          0,
          "aai-sub-view-edit")
      });

      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiServiceInstances.json').then((res) => {
        jsonBuilderAaiServiceInstances.basicJson(
          res,
          Cypress.config('baseUrl') + "/search_service_instances**",
          200,
          0,
          "aai-get-service-instances")
      });

      mockAsyncBulkResponse();
      cy.initGetAAISubDetails();
      cy.initVidMock();
      cy.mockLatestVersionForService(serviceUuid, serviceInvariantId);
      cy.setReduxState();
      cy.permissionVidMock();
      cy.login();
    });

    afterEach(() => {
      cy.screenshot();
    });

    it(`should display the more actions button if user is permitted`, function () {
      let SERVICE_INSTANCE_ID="3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
      let SERVICE_TYPE="TYLER%20SILVIA";
      cy.visit(`/serviceModels.htm#/instantiate?subscriberId=${SUBSCRIBER_ID}&subscriberName=SILVIA%20ROBBINS&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&aaiModelVersionId=${serviceUuid}&isPermitted=true`);

      cy.get("[data-tests-id='service-instanceId-th-id']").should('contain', SERVICE_INSTANCE_ID);
      cy.getElementByDataTestsId("show-new-screen").should('be.visible').should('have.text', 'More actions').click();

      cy.url().should('contain',
        `servicePlanning/EDIT?serviceModelId=${serviceUuid}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
    });

    it(`Upgrade a VF Module`, function () {
      cy.initDrawingBoardUserPermission();
      initServicePlanning("EDIT",
        '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
      upgradeTheVFM('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1', true);
      assertVfModuleActionInRedux("None_Upgrade");
      undoUpgradeForVFM();
      assertVfModuleActionInRedux("None");
      upgradeTheVFM('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',true);
      cy.getDrawingBoardDeployBtn().click();
      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
        const requestBody = Object(xhr.request.body);
        const vfModuleRequest = requestBody.vnfs['VNF2_INSTANCE_ID'].vfModules['vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1']['2c1ca484-cbc2-408b-ab86-25a2c15ce280'];
        expect(requestBody.action).to.equal("None_Upgrade");
        expect(requestBody.vnfs['VNF2_INSTANCE_ID'].action).to.equal("None_Upgrade");
        expect(vfModuleRequest.action).to.equal("None_Upgrade");
      });
    });

    it(`Upgrade a VFModule, Negative - latest version doesn't exist, upgrade button shouldn't exist`, function () {
      setLatestVersionMockToEmptyResponse(serviceInvariantId);
      cy.initDrawingBoardUserPermission();
      initServicePlanning("EDIT",
        '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
      verifyMenuActionUpgradeDoesNotExist();
    });

  });

  describe('More UI test', () => {

    beforeEach(() => {
      cy.clearSessionStorage().then(() => {
        cy.setTestApiParamToGR();
        cy.initVidMock();
        cy.login();
      });
    });

    afterEach(() => {
      cy.screenshot();
    });

    it(`Delete not upgraded VFM and upgrade another in a single click`, () => {

      const serviceType = 'Emanuel';
      const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
      const serviceModelId = 'a243da28-c11e-45a8-9f26-0284a9a789bc';
      const serviceInstanceId = 'b153e8ce-2d00-4466-adc0-14bad70f150c';
      const serviceInvariantUuid = "dd5a69b7-c50c-4dde-adc2-966b79bb8fd6";

      cy.initDrawingBoardUserPermission();
      cy.route(`**/rest/models/services/${serviceModelId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/deleteVfModule/delete_vfmodule_model.json')
      .as('serviceModel2');

      cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/deleteVfModule/delete_vfmodule_service_instance.json')
      .as('serviceInstance2');

      cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`, {
          "modelVersionId": "a243da28-c11e-45a8-9f26-0284a9a789bc",
          "modelName": "CHARLOTTE 01222020 Svc",
          "modelVersion": "4.0",
          "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
          "resourceVersion": "1580246673596",
          "modelDescription": "test model for VF module replacement",
          "orchestrationType": null
        }
      ).as("newestModelVersion2");

      cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);

      deleteTheVfm(`node-c449aaf8-2467-41a9-9015-730ab48ca19b-mdns012220200..Mdns01222020..dns_az_01..module-1`);

      upgradeTheVFM(`node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0`, false);

      cy.getElementByDataTestsId('delete-status-type').contains('Delete');

      mockAsyncBulkResponse();
      cy.getDrawingBoardDeployBtn().click();

      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
                    cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/delete_vfmodule_expected_bulk.json').then((expectedResult) => {
                      cy.deepCompare(xhr.request.body, expectedResult);
                    });
                  });
    });

    it(`Upgrade a VFModule: another case e2e`, function () {

      const serviceType = 'Emanuel';
      const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
      const serviceModelId = '06c415d8-afc2-4bcb-a131-e4db4b8e96ce';
      const serviceInstanceId = '6196ab1f-2349-4b32-9b6c-cffeb0ccc79c';
      const serviceInvariantUuid = "b3a1a119-dede-4ed0-b077-2a617fa519a3";

      cy.initDrawingBoardUserPermission();

      cy.route(`**/rest/models/services/${serviceModelId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_model.json')
      .as('serviceModel2');

      cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json')
      .as('serviceInstance2');

      cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`,
        {
          "modelVersionId": "d9a5b318-187e-476d-97f7-a15687a927a9",
          "modelName": "xbi test module replace",
          "modelVersion": "2.0",
          "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
          "resourceVersion": "1571769586156",
          "modelDescription": "test module replacement feature",
          "orchestrationType": null
        }
      ).as("newestModelVersion2");

      cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);

      upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0', false);

      mockAsyncBulkResponse();
      cy.getDrawingBoardDeployBtn().click();

      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
        cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json').then((expectedResult) => {
          cy.deepCompare(xhr.request.body, expectedResult);
        });
      });

    });

    it(`Upgrade a VFModule: upgrade vfmodule when upgraded already service, vnf and brother vfmodule e2e`, function () {

      const serviceType = 'Emanuel';
      const subscriberId = 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb';
      const serviceModelId = 'a243da28-c11e-45a8-9f26-0284a9a789bc';
      const serviceInstanceId = 'b153e8ce-2d00-4466-adc0-14bad70f150c';
      const serviceInvariantUuid = "dd5a69b7-c50c-4dde-adc2-966b79bb8fd6";

      cy.initDrawingBoardUserPermission();

      cy.route(`**/rest/models/services/${serviceModelId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_when_service_vnf_and_brother_vfmodule_alredy_upgraded_e2e__service_model.json')
      .as('serviceModel2');

      cy.route(`**/aai_get_service_instance_topology/${subscriberId}/${serviceType}/${serviceInstanceId}`,
        'fixture:../support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_when_service_vnf_and_brother_vfmodule_alredy_upgraded_e2e__service_instance.json')
      .as('serviceInstance2');

      cy.route(`**/aai_get_newest_model_version_by_invariant/${serviceInvariantUuid}`, {
          "modelVersionId": "a243da28-c11e-45a8-9f26-0284a9a789bc",
          "modelName": "CHARLOTTE 01222020 Svc",
          "modelVersion": "3.0",
          "distributionStatus": "DISTRIBUTION_COMPLETE_OK",
          "resourceVersion": "1580246673596",
          "modelDescription": "test model for VF module replacement",
          "orchestrationType": null
        }
      ).as("newestModelVersion2");

      cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`);

      upgradeTheVFM('node-3412fe1f-e103-4777-90c0-f66d888f4bed-mdns012220200..Mdns01222020..dns_az_01..module-1', true);

      mockAsyncBulkResponse();
      cy.getDrawingBoardDeployBtn().click();

      cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
        cy.readFile('../vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_not_related_to_current_model_e2e__fe_input_cypress.json').then((expectedResult) => {
          cy.deepCompare(xhr.request.body, expectedResult);
        });
      });

    });

  });


  function mockAsyncBulkResponse() {
    cy.server().route({
      url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
      method: 'POST',
      status: 200,
      response: "[]",
    }).as("expectedPostAsyncInstantiation");
  }

  function verifyMenuActionUpgradeDoesNotExist() {
    cy.getElementByDataTestsId('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1-menu-btn').click().then(() => {
      cy.getElementByDataTestsId('context-menu-upgrade').should('not.exist');
    });
  }

  function setLatestVersionMockToEmptyResponse(serviceUuid: string) {
    cy.server().route({
      url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + serviceUuid,
      method: 'GET',
      status: 200,
      response: {},
    }).as("expectLatestServiceModelUpgradeVersion");
  }

  function deleteTheVfm(treeNodeId: string) {
    cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click()
    .drawingBoardTreeClickOnContextMenuOptionByName("Delete");
  }

  function upgradeTheVFM(treeNodeId: string, shouldVGCheckboxExist :boolean) {
    cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click()
    .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade");
    // The following is needed when enabling FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS

    cy.getElementByDataTestsId('retainAssignments').click();
    if (shouldVGCheckboxExist) {
      cy.getElementByDataTestsId('retainVolumeGroups').click();
    }
    else {
      cy.getElementByDataTestsId('retainVolumeGroups').should('not.exist');
    }
    cy.getElementByDataTestsId('sdncPreLoad').click();
    cy.screenshot();
    cy.getElementByDataTestsId('form-set').click();
  }

  function undoUpgradeForVFM() {
    cy.getElementByDataTestsId('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1-menu-btn').click()
    .drawingBoardTreeClickOnContextMenuOptionByName("Undo Upgrade");
  }

  function changeServiceModel(serviceModel: ServiceModel) {
    serviceModel.service.uuid = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
    return serviceModel;
  }

  function assertVfModuleActionInRedux(expectedState:string) {
    cy.getReduxState().then((state) => {
      const vfModule = state.service.serviceInstance['6e59c5de-f052-46fa-aa7e-2fca9d674c44']
        .vnfs["VNF2_INSTANCE_ID"]
        .vfModules["vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1"]["2c1ca484-cbc2-408b-ab86-25a2c15ce280"];
      expect(vfModule.action).to.equal(expectedState)
    });
  }
});