regression unit test for getServicesByOwningEntityId
[vid.git] / vid-webpack-master / cypress / integration / iFrames / retry.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 /// <reference types="Cypress" />
3 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
4 import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
5
6 describe('Retry Page', function () {
7   let jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
8   beforeEach(() => {
9       cy.clearSessionStorage();
10       cy.preventErrorsOnLoading();
11       cy.initAAIMock();
12       jsonBuilderAndMock.basicMock('cypress/support/jsonBuilders/mocks/jsons/serviceModels/ecompNamingFalseModel.json',
13         Cypress.config('baseUrl') + "/rest/models/services/6b528779-44a3-4472-bdff-9cd15ec93450");
14       cy.initVidMock();
15       cy.initZones();
16       cy.permissionVidMock();
17       cy.login();
18   });
19
20   afterEach(() => {
21     cy.screenshot();
22   });
23
24   it(`RETRY - drawing board mode - should show correct failed icon with children + Retry button / Mock Data`,  ()=> {
25     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
26     const SERVICE_TYPE: string = "TYLER SILVIA";
27     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
28     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
29     const JOB_ID: string = '123456-44a3-4472-bdff-9cd15ec12345';
30     cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/getServiceInstanceTopologyResult.json').then((res) => {
31       // Service with isFailed.
32       res.isFailed= true;
33       res.action = 'Create';
34       res.statusMessage = 'Service instantiation has failed.'
35       // Adding VNF with isFailed.
36       res.vnfs["2017-388_PASQUALE-vPE 0"].isFailed = true;
37       res.vnfs["2017-488_PASQUALE-vPE 0"].isFailed = true;
38       res.vnfs["2017-488_PASQUALE-vPE 0"].statusMessage = 'VNF instantiation failed message';
39       res.vnfs["2017-388_PASQUALE-vPE 0"].action = 'Create';
40       res.vnfs["2017-488_PASQUALE-vPE 0"].action = 'Create';
41       res.networks["ExtVL 0"].action = 'Create';
42       res.networks["ExtVL 0"].statusMessage = 'Network instantiation failed message';
43
44       // Adding VFModule with isFailed.
45       res.vnfs["2017-488_PASQUALE-vPE 0"].vfModules["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"]["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot"].isFailed = true;
46       res.vnfs["2017-488_PASQUALE-vPE 0"].vfModules["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"]["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot"].statusMessage = 'Short vfModule Failure Message';
47       res.vnfs["2017-488_PASQUALE-vPE 0"].vfModules["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"]["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot"].action = 'Create';
48
49       jsonBuilderAndMock.basicJson(
50         res,
51         Cypress.config('baseUrl') + "/asyncInstantiation/bulkForRetry/" + JOB_ID,
52         200, 0,
53         "initServiceInstanceRetryTopology",
54       )
55     });
56
57     cy.openIframe(`app/ui/#/servicePlanning/RETRY_EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&jobId=${JOB_ID}`);
58
59     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').eq(0).click();
60
61     cy.get('.failed-msg').should('have.length', 5);
62     cy.get('.newIcon').should('have.length', 4);
63
64     //cy.drawingBoardNumberOfExistingElementsShouldContains(4);
65     cy.get('.toggle-children-wrapper.toggle-children-wrapper-expanded').eq(0).click().then(()=>{
66       cy.get('.failed-msg').should('have.length', 5);
67       cy.get('.newIcon').should('have.length', 4);
68     });
69
70     cy.drawingBoardTreeOpenContextMenuByElementDataTestId('node-afacccf6-397d-45d6-b5ae-94c39734b168-2017-388_PASQUALE-vPE 0')
71       .drawingBoardTreeClickOnContextMenuOptionByName('Edit')
72       .getElementByDataTestsId('cancelButton').click({force: true});
73     cy.drawingBoardTreeOpenContextMenuByElementDataTestId('node-afacccf6-397d-45d6-b5ae-94c39734b168-2017-388_PASQUALE-vPE 0')
74       .drawingBoardTreeClickOnContextMenuOptionByName('Remove');
75
76     cy.get('.newIcon').should('have.length', 2);
77     cy.getElementByDataTestsId('isViewOnly-status-test').contains('IN EDITING');
78
79     cy.getElementByDataTestsId("openMenuBtn").click({force: true})
80       .getElementByDataTestsId("context-menu-header-edit-item").click({force: true})
81       .getElementByDataTestsId("serviceName").should('have.text','mCaNkinstancename')
82       .getElementByDataTestsId("subscriberName")
83       .getElementByDataTestsId("serviceType")
84       .getElementByDataTestsId("owningEntity")
85       .getElementByDataTestsId("project")
86       .getElementByDataTestsId("rollback")
87       .getElementByDataTestsId('cancelButton').click({force: true});
88     cy.getElementByDataTestsId("openMenuBtn").click({force: true})
89       .getElementByDataTestsId("context-menu-header-audit-item");
90     // button should be RETRY
91     cy.getElementByDataTestsId('deployBtn').should('contain', 'REDEPLOY');
92     cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled');
93
94     cy.checkPopoverContentOnMouseEvent('service-failed-msg',  '.popover-content.popover-body','mouseenter', 0)
95       .should('contain', 'Service instantiation has failed');
96   });
97
98   it(`RETRY - view mode- should show failed icon with no actions enabled`, ()=> {
99     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
100     const SERVICE_TYPE: string = "TYLER SILVIA";
101     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
102     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
103     const JOB_ID: string = '123456-44a3-4472-bdff-9cd15ec12345';
104     cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/getServiceInstanceTopologyResult.json').then((res) => {
105
106       // Adding VNF with isFailed.
107       res.vnfs["2017-388_PASQUALE-vPE 0"].isFailed = true;
108       res.vnfs["2017-488_PASQUALE-vPE 0"].isFailed = true;
109       res.vnfs["2017-388_PASQUALE-vPE 0"].action = 'Create';
110       res.vnfs["2017-488_PASQUALE-vPE 0"].action = 'Create';
111       res.vnfs["2017-488_PASQUALE-vPE 0"].statusMessage = 'Very long message that checks the popoverwindow can show very very long messagewithout problem.as-erfderfd-rfghthth-yjyjyj-ukuk. For more details go to audit show window';
112       // Adding VFModule with isFailed.
113       res.vnfs["2017-488_PASQUALE-vPE 0"].vfModules["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"]["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot"].isFailed = true;
114       res.vnfs["2017-488_PASQUALE-vPE 0"].vfModules["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"]["2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot"].action = 'Create';
115
116       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/responceForFailedInstance.json').then((res) => {
117         jsonBuilderAndMock.basicJson(
118           res,
119           Cypress.config('baseUrl') + "/asyncInstantiation/auditStatusForRetry**",
120           200,
121           0,
122           "msoStatusForFailedInstance",
123         )
124       });
125
126       jsonBuilderAndMock.basicJson(
127         res,
128         Cypress.config('baseUrl') + "/asyncInstantiation/bulkForRetry/" + JOB_ID,
129         200, 0,
130         "initServiceInstanceRetryTopology",
131       )
132     });
133
134     cy.openIframe(`app/ui/#/servicePlanning/RETRY?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&jobId=${JOB_ID}`);
135
136     cy.getElementByDataTestsId('node-69e09f68-8b63-4cc9-b9ff-860960b5db09-2017-488_PASQUALE-vPE 0').eq(0).click();
137
138     cy.get('.failed-msg').should('have.length', 4);
139     cy.get('.newIcon').should('have.length', 4);
140
141     cy.get('.toggle-children-wrapper.toggle-children-wrapper-expanded').eq(0).click().then(()=>{
142       cy.get('.failed-msg').should('have.length', 4);
143       cy.get('.newIcon').should('have.length', 4);
144     });
145     cy.assertMenuItemsForNode(['showAuditInfo'],'node-afacccf6-397d-45d6-b5ae-94c39734b168-2017-388_PASQUALE-vPE 0-menu-btn');
146     cy.getElementByDataTestsId('isViewOnly-status-test').contains('VIEW ONLY');
147
148     // deploy button should be 'REDEPLOY' and disabled.
149     cy.getElementByDataTestsId('editBtn').should('contain', 'REDEPLOY').should('have.attr', 'disabled');
150
151     cy.checkPopoverContentOnMouseEvent('failed-error-message',  '.popover-content.popover-body','mouseenter', 0)
152       .should('not.be.visible');
153     cy.checkPopoverContentOnMouseEvent('failed-error-message',  '.popover-content.popover-body','mouseenter', 1)
154       .should('contain', 'Very long');
155
156   });
157
158   it(`RETRY - drawing board mode - should show correct failed icon + Retry button`,  ()=> {
159     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
160     const SERVICE_TYPE: string = "TYLER SILVIA";
161     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
162     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
163     const JOB_ID: string = '123456-44a3-4472-bdff-9cd15ec12345';
164     let expectedResult: JSON;
165
166     cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/ServiceTreeForRetry_serviceInstance.json').then((res) => {
167
168       jsonBuilderAndMock.basicJson(
169         res,
170         Cypress.config('baseUrl') + "/asyncInstantiation/bulkForRetry/" + JOB_ID,
171         200, 0,
172         "initServiceInstanceRetryTopology",
173       )
174     });
175
176     //TODO - join this to correct API test
177
178
179
180     cy.openIframe(`app/ui/#/servicePlanning/RETRY_EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&jobId=${JOB_ID}`);
181
182     cy.get('.failed-msg').should('have.length', 1);
183     cy.get('.newIcon').should('have.length', 1);
184     //TODO
185
186     cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled');
187
188     // button should be RETRY
189     cy.getElementByDataTestsId('deployBtn').should('contain', 'REDEPLOY').click();
190
191
192     //TODO - join this to correct API test
193
194
195   });
196
197   it('RETRY- edit mode- failed service with vnf', ()=>{
198     const SUBSCRIBER_ID: string = "e433710f-9217-458d-a79d-1c7aff376d89";
199     const SERVICE_TYPE: string = "TYLER SILVIA";
200     const SERVICE_INSTANCE_ID: string = "f8791436-8d55-4fde-b4d5-72dd2cf13cfb";
201     const SERVICE_MODEL_ID: string = '6b528779-44a3-4472-bdff-9cd15ec93450';
202     const JOB_ID: string = '123456-44a3-4472-bdff-9cd15ec12345';
203     const TRACK_BY_ID = '14561234';
204     let expectedResult: JSON;
205     cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/ServiceWithFailedServiceInstance.json').then((res) => {
206
207       cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/auditModalFailedServiceInstance.json').then((res) => {
208         jsonBuilderAndMock.basicJson(
209           res,
210           Cypress.config('baseUrl') + "/asyncInstantiation/auditStatusForRetry/TRACK_BY_ID",
211           200,
212           0,
213           "msoStatusForFailedInstance",
214         )
215       });
216
217       jsonBuilderAndMock.basicJson(
218         res,
219         Cypress.config('baseUrl') + "/asyncInstantiation/bulkForRetry/" + JOB_ID,
220         200, 0,
221         "initFAiledServiceInstanceRetryTopology",
222       )
223     });
224
225     cy.openIframe(`app/ui/#/servicePlanning/RETRY_EDIT?serviceModelId=${SERVICE_MODEL_ID}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}&jobId=${JOB_ID}`);
226     cy.get('.newIcon').should('have.length', 1);
227     cy.getElementByDataTestsId('isViewOnly-status-test').contains('IN EDITING');
228     cy.getElementByDataTestsId("openMenuBtn").click({force: true});
229     cy.getElementByDataTestsId("context-menu-header-edit-item").click({force: true})
230       .getElementByDataTestsId("serviceName").should('have.text','INSTANCE_NAME')
231       .getElementByDataTestsId("subscriberName")
232       .getElementByDataTestsId("serviceType")
233       .getElementByDataTestsId("owningEntity")
234       .getElementByDataTestsId("project")
235       .getElementByDataTestsId("rollback")
236       .getElementByDataTestsId('cancelButton').click({force: true});
237     cy.getElementByDataTestsId("openMenuBtn").click({force: true})
238       .getElementByDataTestsId("context-menu-header-audit-item").click({force: true});
239     cy.getElementByDataTestsId('requestId').should('contain', 'e5f93320-cce6-424d-adc6-259a4ee8b342');
240     cy.getElementByDataTestsId('jobStatus').should('contain', 'Failed');
241     cy.getElementByDataTestsId('additionalInfo').should('contain', 'The service instantiation is failed');
242     cy.getElementByDataTestsId('close-button').click({force: true});
243     // // button should be RETRY
244     cy.getElementByDataTestsId('deployBtn').should('contain', 'REDEPLOY');
245     cy.getElementByDataTestsId('deployBtn').should('not.have.attr', 'disabled');
246     cy.get('.failed-msg').should('have.length', 1);
247     cy.get('.newIcon').should('have.length', 1);
248
249     cy.checkPopoverContentOnMouseEvent('service-failed-msg',  '.popover-content.popover-body','mouseenter', 0)
250       .should('contain', 'The service instantiation is failed');
251     });
252 });