blob: 0075dc240dbe2f934101ce1c2d27ec051abc0dbb [file] [log] [blame]
Ittay Sternb9d47882019-12-17 06:54:33 +02001import * as _ from "lodash";
2import {PropertyPath} from "lodash";
3
Ittay Sterne8887222019-12-01 19:38:32 +02004describe('Drawing Board: Instantiation Templates', function () {
5
Alexey Sandlerbefd7842019-12-11 10:06:31 +02006 describe('Instantiation templates ', () => {
Ittay Sterne8887222019-12-01 19:38:32 +02007
8 beforeEach(() => {
9 cy.clearSessionStorage();
Ittay Stern4bfa2df2019-12-17 14:55:04 +020010 cy.setTestApiParamToGR();
Alexey Sandlerbefd7842019-12-11 10:06:31 +020011 cy.initAAIMock();
Alexey Sandler12ceb442019-12-16 10:18:41 +020012 cy.initGetAAISubDetails();
Ittay Sterne8887222019-12-01 19:38:32 +020013 cy.initVidMock();
14 cy.initDrawingBoardUserPermission();
15 cy.login();
16
17 mockAsyncBulkResponse();
18 });
19
20 afterEach(() => {
21 cy.screenshot();
22 });
23
Alexey Sandlerbefd7842019-12-11 10:06:31 +020024 describe('Load Page and Deploy', () => {
Ittay Sterne8887222019-12-01 19:38:32 +020025
Alexey Sandler12ceb442019-12-16 10:18:41 +020026 it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, () => {
Ittay Sterne8887222019-12-01 19:38:32 +020027
Alexey Sandlerbefd7842019-12-11 10:06:31 +020028 loadDrawingBoardWithRecreateMode();
Ittay Sterne8887222019-12-01 19:38:32 +020029
Alexey Sandlerbefd7842019-12-11 10:06:31 +020030 // Then...
31 cy.getElementByDataTestsId("node-vProbe_NC_VNF 0").should('be.visible');
32 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
33 });
Ittay Sterne8887222019-12-01 19:38:32 +020034
Sara Weiss19bfe442019-12-17 13:20:29 +020035 it('Given a stored template - when "edit" vnf and vfmodules are opened - then template’s details are visible as expected and deploy without changes', () => {
Ittay Sterne8887222019-12-01 19:38:32 +020036
Alexey Sandlerbefd7842019-12-11 10:06:31 +020037 loadDrawingBoardWithRecreateMode();
Ittay Sterne8887222019-12-01 19:38:32 +020038
Alexey Sandlerbefd7842019-12-11 10:06:31 +020039 // Then...
Ittay Stern8f0f7282019-12-16 20:07:50 +020040 editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
Alexey Sandler46363532019-12-12 11:52:18 +020041 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007')
42 .getElementByDataTestsId("productFamily").should('contain', 'Emanuel')
43 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
Alexey Sandlerbefd7842019-12-11 10:06:31 +020044 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
Alexey Sandler46363532019-12-12 11:52:18 +020045 .getElementByDataTestsId("lineOfBusiness").should('contain', 'zzz1')
46 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
Alexey Sandler12ceb442019-12-16 10:18:41 +020047 .checkPlatformValue('xxx1')
48 .getElementByDataTestsId("cancelButton").click();
Ittay Sterne8887222019-12-01 19:38:32 +020049
Ittay Stern8f0f7282019-12-16 20:07:50 +020050 editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0")
Alexey Sandler46363532019-12-12 11:52:18 +020051 .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01')
52 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
53 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
54 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
Alexey Sandler46363532019-12-12 11:52:18 +020055 .getElementByDataTestsId("cancelButton").click();
56
Ittay Stern8f0f7282019-12-16 20:07:50 +020057 editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1")
58 .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01')
59 .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol')
Alexey Sandler46363532019-12-12 11:52:18 +020060 .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6')
61 .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1')
62 .getElementByDataTestsId("rollback").should('contain', 'Rollback')
Ittay Stern8f0f7282019-12-16 20:07:50 +020063 .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on')
Alexey Sandler46363532019-12-12 11:52:18 +020064 .getElementByDataTestsId("cancelButton").click();
65
Alexey Sandlerbefd7842019-12-11 10:06:31 +020066 assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd();
Alexey Sandlerf53a9172019-12-05 17:04:45 +020067 });
Ittay Sterne8887222019-12-01 19:38:32 +020068
Ittay Stern8f0f7282019-12-16 20:07:50 +020069 it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`, function () {
Alexey Sandler46363532019-12-12 11:52:18 +020070
71 loadDrawingBoardWithRecreateMode();
72
73 cy.openServiceContextMenu()
Alexey Sandler12ceb442019-12-16 10:18:41 +020074 .getElementByDataTestsId("context-menu-header-edit-item").click()
75 .getElementByDataTestsId("instanceName").should('have.value', 'vProbe_NC_Service_DG_new_SI')
76 .getElementByDataTestsId("subscriberName").should('contain', 'SILVIA ROBBINS')
77 .getElementByDataTestsId("serviceType").should('contain', 'TYLER SILVIA')
78 .getElementByDataTestsId("owningEntity").should('contain', 'WayneHolland')
79 .getElementByDataTestsId("project").should('contain', 'WATKINS')
80 .getElementByDataTestsId("rollback").should('contain', 'Rollback');
81
Alexey Sandler12ceb442019-12-16 10:18:41 +020082 });
Ittay Stern8f0f7282019-12-16 20:07:50 +020083
Ittay Sternb9d47882019-12-17 06:54:33 +020084 [
85 {desc: "with changes", modifySomeValues: true},
86 {desc: "without changes", modifySomeValues: false},
87 ].forEach((testCase) => {
Ittay Stern8f0f7282019-12-16 20:07:50 +020088
Ittay Sternb9d47882019-12-17 06:54:33 +020089 it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () {
Sara Weiss19bfe442019-12-17 13:20:29 +020090
Ittay Sternb9d47882019-12-17 06:54:33 +020091 loadDrawingBoardWithRecreateMode();
Sara Weiss19bfe442019-12-17 13:20:29 +020092
Ittay Sternb9d47882019-12-17 06:54:33 +020093 //edit service
94 cy.openServiceContextMenu();
95 cy.getElementByDataTestsId("context-menu-header-edit-item").click();
96 if (testCase.modifySomeValues) {
97 cy.clearInput("instanceName");
98 cy.typeToInput("instanceName", "different.instance.name");
99 }
100 cy.getElementByDataTestsId('form-set').click();
Sara Weiss19bfe442019-12-17 13:20:29 +0200101
Ittay Sternb9d47882019-12-17 06:54:33 +0200102 // edit vnf
103 editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0");
104 if (testCase.modifySomeValues) {
105 cy.selectPlatformValue('platform');
106 cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909");
107 }
108 cy.getElementByDataTestsId('form-set').click();
Sara Weiss19bfe442019-12-17 13:20:29 +0200109
Ittay Sternb9d47882019-12-17 06:54:33 +0200110 //edit vf module
111 editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0");
112 if (testCase.modifySomeValues) {
113 cy.getElementByDataTestsId('sdncPreLoad').click();
114 }
115 cy.getElementByDataTestsId('form-set').click();
Sara Weiss19bfe442019-12-17 13:20:29 +0200116
Ittay Sternb9d47882019-12-17 06:54:33 +0200117 // Then...
118 let vnfPath = [
119 "vnfs", "vProbe_NC_VNF 0"
120 ];
121 let vfModule_0Path = [
122 ...vnfPath, "vfModules",
123 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0",
124 "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg",
125 ];
126
127 assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [
128 {path: ["instanceName"], value: "different.instance.name"},
129 {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined},
130 {path: ["existingNames", "different.instance.name"], value: ""},
131
132 {path: [...vnfPath, "platformName"], value: "xxx1,platform"},
133 {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"},
134
135 {path: [...vfModule_0Path, "sdncPreLoad"], value: true},
136 ] : []);
137 })
Ittay Stern8f0f7282019-12-16 20:07:50 +0200138
Alexey Sandler46363532019-12-12 11:52:18 +0200139 });
Ittay Sternb9d47882019-12-17 06:54:33 +0200140
Ittay Sterne8887222019-12-01 19:38:32 +0200141 });
Ittay Sterne8887222019-12-01 19:38:32 +0200142 });
Ittay Sternb9d47882019-12-17 06:54:33 +0200143});
Ittay Sterne8887222019-12-01 19:38:32 +0200144
Alexey Sandlerbefd7842019-12-11 10:06:31 +0200145function loadDrawingBoardWithRecreateMode() {
146 const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
147 const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
148
149 const drawingBoardAction = `RECREATE`;
150 const templateTopologyEndpoint = "templateTopology";
151 cy.route(`**/rest/models/services/${serviceModelId}`,
152 'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
153 .as('serviceModel');
154
155 cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
156 'fixture:../../../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json')
157 .as('templateTopology');
158
159 // When...
160
161 cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
162 `?jobId=${templateUuid}` +
163 `&serviceModelId=${serviceModelId}`);
164
165 cy.wait('@serviceModel');
166 cy.wait('@templateTopology');
167}
168
Ittay Stern8f0f7282019-12-16 20:07:50 +0200169function editNode(dataTestId: string) {
170 return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId)
171 .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
172}
173
Alexey Sandlerbefd7842019-12-11 10:06:31 +0200174function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
175 cy.getDrawingBoardDeployBtn().click();
176 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
177 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json').then((expectedResult) => {
178 convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
179
180 let xhrBodyWithoutIsDirtyField = removeIsDirtyFieldFromXhrRequestBody(xhr);
181 cy.deepCompare(xhrBodyWithoutIsDirtyField, expectedResult);
182 });
183 });
184}
185
Sara Weiss19bfe442019-12-17 13:20:29 +0200186
Ittay Sternb9d47882019-12-17 06:54:33 +0200187function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
Sara Weiss19bfe442019-12-17 13:20:29 +0200188 cy.getDrawingBoardDeployBtn().click();
189 cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
190
191 cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => {
Ittay Sternb9d47882019-12-17 06:54:33 +0200192 setDeviationInExpected(expectedResult, deviationFromExpected);
Sara Weiss19bfe442019-12-17 13:20:29 +0200193 cy.deepCompare(xhr.request.body, expectedResult);
194 });
195
196 });
197}
198
Ittay Sternb9d47882019-12-17 06:54:33 +0200199function setDeviationInExpected(expectedResult: any, deviation: { path: PropertyPath; value: any }[]) {
200 for (const caveat of deviation) {
201 _.set(expectedResult, caveat.path, caveat.value);
202 }
203}
204
Alexey Sandlerb85a0462019-12-04 17:48:06 +0200205 //We use this function because the deployService() on drawing-board-header.component class
206 // changes rollbackOnFailure value from string type to boolean.
207 function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
208 expectedResult.rollbackOnFailure = Boolean(expectedResult.rollbackOnFailure);
209 }
Ittay Sterne8887222019-12-01 19:38:32 +0200210
Alexey Sandlerbefd7842019-12-11 10:06:31 +0200211function removeIsDirtyFieldFromXhrRequestBody(xhr : any) {
212 let xhrTempBody = JSON.parse(JSON.stringify(xhr.request.body));
213 delete xhrTempBody.isDirty;
214 return xhrTempBody;
215}
216
Ittay Sterne8887222019-12-01 19:38:32 +0200217 function mockAsyncBulkResponse() {
218 cy.server().route({
219 url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
220 method: 'POST',
221 status: 200,
222 response: "[]",
223 }).as("expectedPostAsyncInstantiation");
224 }