free text filter in instantiationStatus Page
[vid.git] / vid-webpack-master / cypress / integration / iFrames / instantiationStatus.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 /// <reference types="Cypress" />
3
4 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
5 import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
6
7 describe('Instantiation status', function () {
8   var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
9   var asyncRes: Array<any>;
10
11   beforeEach(() => {
12       cy.clearSessionStorage();
13       cy.setReduxState();
14       cy.preventErrorsOnLoading();
15       cy.initAAIMock();
16       cy.initVidMock();
17       jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
18         Cypress.config('baseUrl') + "/asyncInstantiation**",
19         (res: any) => {
20             asyncRes = res;
21             return res;
22       });
23       cy.login();
24   });
25
26   afterEach(() => {
27     cy.screenshot();
28   });
29
30   it('should display the correct icons per status', function () {
31       const serviceAction:any = {INSTANTIATE : 'Instantiate', DELETE: 'Delete', UPDATE: 'Update', UPGRADE: 'Upgrade'};
32       cy.openIframe('app/ui/#/instantiationStatus');
33       for(let i = 0 ; i < asyncRes.length; i++){
34         if(asyncRes[i].project){
35           cy.getTableRowByIndex('instantiation-status', i).get('td#project span').contains(asyncRes[i].project);
36         }
37         if(asyncRes[i].userId){
38           cy.getTableRowByIndex('instantiation-status', i).get('td#userId span').contains(asyncRes[i].userId);
39         }
40         if(asyncRes[i].tenantName){
41           cy.getTableRowByIndex('instantiation-status', i).get('td#tenantName span').contains(asyncRes[i].tenantName);
42         }
43         if(asyncRes[i].serviceModelName){
44           cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelName span').contains(asyncRes[i].serviceModelName);
45         }
46         if(asyncRes[i].serviceInstanceName){
47           cy.getTableRowByIndex('instantiation-status', i).get('td#serviceInstanceName span').contains(asyncRes[i].serviceInstanceName);
48         }
49         if(asyncRes[i].serviceModelVersion){
50           cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelVersion span').contains(asyncRes[i].serviceModelVersion);
51         }
52         if(asyncRes[i].subscriberName){
53           cy.getTableRowByIndex('instantiation-status', i).get('td#subscriberName span').contains(asyncRes[i].subscriberName);
54         }
55         if(asyncRes[i].action) {
56           cy.getTableRowByIndex('instantiation-status', i).get('td#action span').contains(serviceAction[asyncRes[i].action]);
57         }
58     }
59   });
60
61   it('should filter rows by filter text', function () {
62     cy.openIframe('app/ui/#/instantiationStatus');
63     cy.getElementByDataTestsId("instantiationStatusFilter").type("ComplexService");
64     cy.get('table#instantiation-status tbody tr').should('have.length', 3);
65   });
66
67   it('should filter rows by url filter text', function () {
68     cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService');
69     cy.getElementByDataTestsId("instantiationStatusFilter").should('have.value','ComplexService');
70     cy.get('table#instantiation-status tbody tr').should('have.length', 3);
71   });
72
73   it('should enable correct menu items', function () {
74         cy.openIframe('app/ui/#/instantiationStatus');
75
76         // Instantiate action with Job status FAILED - isRetry = true
77         cy.get( '#5c2cd8e5-27d0-42e3-85a1-85db5eaba459').find('.menu-div').click();
78         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-retry']`).should('not.exist');
79         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-remove']`).should('exist');
80         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-open']`).should('exist');
81         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-hide']`).should('not.exist');
82         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-audit-info']`).should('not.exist');
83
84         // Instantiate action with Job status FAILED - isRetry = false
85         cy.get( '#e1db03c3-6274-4ff7-84cf-7bd3a3946de7').find('.menu-div').click();
86         cy.get('.dropdown-menu').find(`[data-tests-id='context-menu-retry']`).should('not.be.visible');
87         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-open']`).should('exist');
88
89         //Delete action with Job status IN_PROGRESS
90         cy.get( '#850dc7d2-5240-437f-9bcd-b1ed7dc339c2').find('.menu-div').click();
91         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-remove']`).should('exist');
92         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-open']`).should('exist');
93         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-hide']`).should('exist');
94         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-audit-info']`).should('not.exist');
95         //Update action with Job status COMPLETED
96         cy.get( '#850dc7d2-5240-437f-9bcd-b1ed7dc339c1').find('.menu-div').click();
97         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-remove']`).should('exist');
98         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-open']`).should('not.exist');
99         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-hide']`).should('not.exist');
100         cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='context-menu-audit-info']`).should('not.exist');
101   });
102
103 });