blob: bea31fcf8a030f31520067b2abcc058550151916 [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();
82 cy.initVidMock({serviceUuid: serviceUuid, invariantId: serviceInvariantId});
83 cy.setReduxState();
84 cy.permissionVidMock();
85 cy.login();
86 });
87
88 afterEach(() => {
89 cy.screenshot();
90 });
91
92 it(`should display the more actions button if user is permitted`, function () {
93 let SERVICE_INSTANCE_ID="3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
94 let SERVICE_TYPE="VIRTUAL%20USP";
95 cy.visit(`/serviceModels.htm#/instantiate?subscriberId=${SUBSCRIBER_ID}&subscriberName=USP%20VOICE&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&aaiModelVersionId=${serviceUuid}&isPermitted=true`);
96
97 cy.get("[data-tests-id='service-instanceId-th-id']").should('contain', SERVICE_INSTANCE_ID);
98 cy.getElementByDataTestsId("show-new-screen").should('be.visible').should('have.text', 'More actions').click();
99
100 cy.url().should('contain',
101 `servicePlanning/EDIT?serviceModelId=${serviceUuid}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`);
102 });
103
104 it(`Upgrade a VFModule`, function () {
105 cy.initDrawingBoardUserPermission();
106 initServicePlanning("EDIT",
107 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
108 upgradeTheVFM();
109 undoUpgradeForVFM();
110 upgradeTheVFM();
111 cy.getDrawingBoardDeployBtn().click();
112 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
113 expect(Object(xhr.request.body).action).to.equal("None_Upgrade");
114 expect(Object(xhr.request.body).vnfs['VNF2_INSTANCE_ID'].action).to.equal("None_Upgrade");
115 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");
116 });
117 });
118
119 it(`Upgrade a VFModule, Negative - latest version doesn't exist, upgrade button shouldn't exist`, function () {
120 setLatestVersionMockToEmptyResponse(serviceInvariantId);
121 cy.initDrawingBoardUserPermission();
122 initServicePlanning("EDIT",
123 '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json');
124 verifyMenuActionUpgradeDoesNotExist();
125 });
126
127 });
128
129 function mockAsyncBulkResponse() {
130 cy.server().route({
131 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
132 method: 'POST',
133 status: 200,
134 response: "[]",
135 }).as("expectedPostAsyncInstantiation");
136 }
137
138 function verifyMenuActionUpgradeDoesNotExist() {
139 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
140 .getElementByDataTestsId('context-menu-upgrade').should('not.exist');
141 }
142
143 function setLatestVersionMockToEmptyResponse(serviceUuid: string) {
144 cy.server().route({
145 url: Cypress.config('baseUrl') + '/aai_get_newest_model_version_by_invariant/' + serviceUuid,
146 method: 'GET',
147 status: 200,
148 response: {},
149 }).as("expectLatestServiceModelUpgradeVersion")
150 }
151
152 function upgradeTheVFM(): Chainable<any> {
153 return cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
154 .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade");
155 }
156
157 function undoUpgradeForVFM() {
158 cy.getElementByDataTestsId('node-undefined-dc229cd8-c132-4455-8517-5c1787c18b14-menu-btn').click()
159 .drawingBoardTreeClickOnContextMenuOptionByName("Undo Upgrade");
160 }
161
162 function changeServiceModel(serviceModel: ServiceModel) {
163 serviceModel.service.uuid = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
164 return serviceModel;
165 }
166});