Sorting functionality on audit info screen
[vid.git] / vid-webpack-master / cypress / integration / iFrames / auditInfo.modal.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
3 import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
4 import * as _ from 'lodash';
5 import {ServiceModel} from "../../support/jsonBuilders/models/service.model";
6
7 describe('Audit information modal', function () {
8   describe('basic UI tests', () => {
9     var jsonBuilderInstantiationBuilder: JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
10     var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
11     beforeEach(() => {
12         cy.clearSessionStorage();
13         cy.setReduxState();
14         cy.preventErrorsOnLoading();
15         jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
16           Cypress.config('baseUrl') + "/asyncInstantiation**");
17         cy.initAAIMock();
18         cy.initVidMock();
19         cy.initAsyncInstantiation();
20         cy.login();
21     });
22
23     afterEach(() => {
24       cy.screenshot();
25     }); 
26
27     it(`should display 2 tables with information's`, function () {
28       cy.initAuditInfoMSOALaCarte();
29       cy.openIframe('app/ui/#/instantiationStatus');
30       cy.get('.instantiation-status-data tbody tr').each(function (row, index) {
31         cy.get('.icon-menu').eq(index).click({force: true}).then(()=>{
32           cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(()=>{
33             cy.setViewportToSmallPopup();
34               cy.get('#service-instantiation-audit-info-mso').should('be.visible')
35               .get('#service-instantiation-audit-info-mso').find('#msoJobStatus').should('be.visible')
36               .get('#cancelButton').click({force: true})
37               .setViewportToDefault();
38           })
39         });
40       });
41     });
42
43     it("shouldn't show instance name in mso table on macro service", function () {
44       cy.openIframe('app/ui/#/instantiationStatus');
45       cy.get('.icon-menu').eq(0).click({force:true}).then(() => {
46         cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(() => {
47           cy.setViewportToSmallPopup();
48           cy.get('#service-instantiation-audit-info-mso thead tr th#instanceName').should("not.be.visible")
49             .get('#service-instantiation-audit-info-mso tbody tr td.msoInstanceName').should("not.be.visible");
50         })
51       })
52     });
53
54     it('should show instance name in mso table on a la carte service', function () {
55       cy.readFile('../vid-automation/src/test/resources/a-la-carte/auditInfoMSOALaCarte.json').then((res) => {
56         cy.initAuditInfoMSOALaCarte(res);
57         cy.openIframe('app/ui/#/instantiationStatus');
58         cy.get('.icon-menu').eq(7).click({force:true}).then(() => {
59           cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(() => {
60             cy.setViewportToSmallPopup();
61             cy.get('#service-instantiation-audit-info-mso thead tr th#instanceName').should("be.visible")
62               .get('#service-instantiation-audit-info-mso tbody tr').each(function (row, index) {
63               assert.equal(row.find('#msoRequestId').text().trim(), res[index]['requestId']);
64               assert.equal(row.find('.msoInstanceName').text().trim(), res[index]['instanceName']);
65               assert.equal(row.find('#msoJobStatus').text().trim(), _.capitalize(res[index]['jobStatus']));
66               assert.equal(row.find('#msoAdditionalInfo span').text().trim(), res[index]['additionalInfo']);
67             });
68           });
69         })
70       })
71     });
72
73     it('glossary should be visible', function () {
74       cy.openIframe('app/ui/#/instantiationStatus');
75       cy.get('.icon-menu').eq(7).click().then(() => {
76         cy.getElementByDataTestsId('context-menu-audit-info').click().then(() => {
77           cy.setViewportToSmallPopup();
78           cy.get('#glossary_link').should('be.visible');
79         });
80       })
81     });
82
83     it('Refresh link should be visible and clicking refresh should fetch latest data', function () {
84       cy.initAuditInfoMSOALaCarte(); 
85       cy.openIframe('app/ui/#/instantiationStatus');
86       cy.get('.instantiation-status-data tbody tr').each(function (row, index) {
87         cy.get('.icon-menu').eq(index).click({force: true}).then(()=>{
88           cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(()=>{
89             cy.setViewportToSmallPopup();
90             cy.get('#refreshButton').should('be.visible')
91             cy.get('#refreshButton').click({force: true}).then(() => {
92               cy.initAuditInfoMSOALaCarteNew();
93             })
94           })
95   
96           })
97         });
98       });
99
100     it('Check if the table data is sorted in descending order by start time', function () {
101         const expectedResult = getExpectedResult();
102         cy.readFile('../vid-automation/src/test/resources/a-la-carte/auditInfoMSOALaCarteNew.json').then((res) => {
103         cy.initAuditInfoMSOALaCarteNew(res);
104         cy.openIframe('app/ui/#/instantiationStatus');
105         cy.get('.icon-menu').eq(7).click({force:true}).then(() => {
106           cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(() => {
107             cy.setViewportToSmallPopup();
108             cy.get('#service-instantiation-audit-info-mso thead tr th#instanceName').should("be.visible")
109               .get('#service-instantiation-audit-info-mso tbody tr').each(function (row, index) {
110               assert.equal(row.find('#msoRequestId').text().trim(), expectedResult[index]['requestId']);
111               assert.equal(row.find('.msoInstanceName').text().trim(), expectedResult[index]['instanceName']);
112               assert.equal(row.find('#msostartTime').text().trim(), expectedResult[index]['startTime']);
113             });
114           });
115         })
116         });
117       }); 
118
119   });
120 });
121
122
123
124 function getExpectedResult() {
125   return [
126     {
127       "requestId": "1fc2ef3b-26f0-4e62-a00a-6a31502d39e2",
128       "instanceName": "zrdm54cfmgw01_sup_1",
129       "modelType": "vfModule",
130       "instanceType": "createInstance",
131       "startTime": "Mon, 24 Aug 2020 22:54:29 GMT",
132       "finishTime": "Mon, 24 Aug 2020 22:56:35 GMT",
133       "jobStatus": "ROLLED_BACK_TO_ASSIGNED",
134       "additionalInfo": "<b>Source:</b> VID</br><b>StatusMessage:</b>STATUS: Error Source: OPENSTACK, Error Message: Received vfModuleException from VnfAdapter: category='INTERNAL' message='Exception during create VF 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=UserParameterMissing, error.message=The Parameter (VSFO_CP0_compute_node) was not provided.' rolledBack='true'</br><b>FlowStatus:</b> All Rollback flows have completed successfully</br><b>TestAPI:</b> GR_API</br><b>TenantId:</b> ad299b37da30413391e9c28138f0b0cd</br><b>TenantName:</b> FNCORE-30052-D-MC-RDM54c</br><b>CloudOwner:</b> att-nc</br>"
135     },
136     {
137       "requestId": "a4e43d9e-4813-42e4-94bf-c5c6f22ed0bc",
138       "instanceName": "zrdm54cfmgw01_base",
139       "modelType": "vfModule",
140       "instanceType": "createInstance",
141       "startTime": "Mon, 24 Aug 2020 22:44:42 GMT",
142       "finishTime": "Mon, 24 Aug 2020 22:54:17 GMT",
143       "jobStatus": "COMPLETE",
144       "additionalInfo": "<b>Source:</b> VID</br><b>StatusMessage:</b>STATUS: ALaCarte-VfModule-createInstance request was executed correctly.</br><b>FlowStatus:</b> Successfully completed all Building Blocks</br><b>TestAPI:</b> GR_API</br><b>TenantId:</b> ad299b37da30413391e9c28138f0b0cd</br><b>TenantName:</b> FNCORE-30052-D-MC-RDM54c</br><b>CloudOwner:</b> att-nc</br>"
145     },
146     {
147       "requestId": "f1aa7175-c237-4b56-ba64-7cb728a38ff2",
148       "instanceName": "zrdm54cfmgw01",
149       "modelType": "vnf",
150       "instanceType": "createInstance",
151       "startTime": "Mon, 24 Aug 2020 22:38:18 GMT",
152       "finishTime": "Mon, 24 Aug 2020 22:44:24 GMT",
153       "jobStatus": "COMPLETE",
154       "additionalInfo": "<b>Source:</b> VID</br><b>StatusMessage:</b>STATUS: ALaCarte-Vnf-createInstance request was executed correctly.</br><b>FlowStatus:</b> Successfully completed all Building Blocks</br><b>TestAPI:</b> GR_API</br><b>TenantId:</b> ad299b37da30413391e9c28138f0b0cd</br><b>TenantName:</b> FNCORE-30052-D-MC-RDM54c</br><b>CloudOwner:</b> att-nc</br><b>PlatformName:</b> FIRSTNET-DEDICATED,NETWORK-CLOUD</br><b>LineOfBusiness:</b> FIRSTNET</br>"
155     },
156     {
157       "requestId": "7ba7900c-3e51-4d87-b1b4-3c53bdfaaa7d",
158       "instanceName": "zrdm54cfmgw01_svc",
159       "modelType": "service",
160       "instanceType": "createInstance",
161       "startTime": "Mon, 24 Aug 2020 22:37:53 GMT",
162       "finishTime": "Mon, 24 Aug 2020 22:38:10 GMT",
163       "jobStatus": "COMPLETE",
164       "additionalInfo": "<b>Source:</b> VID</br><b>StatusMessage:</b>STATUS: ALaCarte-Service-createInstance request was executed correctly.</br><b>FlowStatus:</b> Successfully completed all Building Blocks</br><b>SubscriptionServiceType:</b> FIRSTNET</br><b>Alacarte:</b> true</br><b>TestAPI:</b> GR_API</br><b>ProjectName: FIRSTNET</br><b>OwningEntityId:</b> 10c645f5-9924-4b89-bec0-b17cf49d3cad</br><b>OwningEntityName:</b> MOBILITY-CORE</br>"
165     }
166   ];
167 }