blob: fbd6d8b076419aeb3ee41b08327113ef0eb409f9 [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2/// <reference types="Cypress" />
3
Ittay Stern6f900cc2018-08-29 17:01:32 +03004import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
5import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
Einat Vinouze5b5e0bb2020-05-21 18:16:57 +03006import {
7 COMPLETED_WITH_ERRORS,
8 INPROGRESS,
9 PAUSE,
10 PAUSE_UPON_COMPLETION,
11 PENDING,
12 STOPPED,
13 SUCCESS_CIRCLE,
14 UNKNOWN,
15 X_O
16} from "../../../src/app/instantiationStatus/instantiationStatus.component.service";
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030017
Ittay Stern6f900cc2018-08-29 17:01:32 +030018describe('Instantiation status', function () {
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030019 var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
Ittay Stern6f900cc2018-08-29 17:01:32 +030020 var asyncRes: Array<any>;
Eylon Malin18361152019-12-16 10:24:57 +020021 const contextMenuCreateAnotherOne = 'context-menu-create-another-one';
Alexey Sandlera3b9e3e2020-04-19 20:32:42 +030022 const contextMenuNewViewEdit = 'context-menu-new-view-edit';
Ittay Stern6f900cc2018-08-29 17:01:32 +030023
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030024 beforeEach(() => {
Ittay Stern32dbf802019-10-29 12:58:49 +020025 cy.clearSessionStorage();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030026 cy.setReduxState();
27 cy.preventErrorsOnLoading();
28 cy.initAAIMock();
29 cy.initVidMock();
Ittay Stern607ea3d2019-10-23 17:10:52 +030030 jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
Ittay Stern6f900cc2018-08-29 17:01:32 +030031 Cypress.config('baseUrl') + "/asyncInstantiation**",
32 (res: any) => {
33 asyncRes = res;
34 return res;
35 });
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030036 cy.login();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030037 });
38
Ittay Stern6f900cc2018-08-29 17:01:32 +030039 afterEach(() => {
40 cy.screenshot();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030041 });
Ittay Stern6f900cc2018-08-29 17:01:32 +030042
43 it('should display the correct icons per status', function () {
Ittay Sternc439c812019-10-30 14:46:22 +020044 const serviceAction:any = {INSTANTIATE : 'Instantiate', DELETE: 'Delete', UPDATE: 'Update', UPGRADE: 'Upgrade'};
Ittay Stern6f900cc2018-08-29 17:01:32 +030045 cy.openIframe('app/ui/#/instantiationStatus');
46 for(let i = 0 ; i < asyncRes.length; i++){
Einat Vinouze5b5e0bb2020-05-21 18:16:57 +030047 cy.getTableRowByIndex('instantiation-status', i).get(`td custom-icon#jobStatusIcon-${i} div`)
48 .should('have.class', `__${getJobIconClass(asyncRes[i].jobStatus)}`);
49
Ittay Stern6f900cc2018-08-29 17:01:32 +030050 if(asyncRes[i].project){
51 cy.getTableRowByIndex('instantiation-status', i).get('td#project span').contains(asyncRes[i].project);
52 }
53 if(asyncRes[i].userId){
54 cy.getTableRowByIndex('instantiation-status', i).get('td#userId span').contains(asyncRes[i].userId);
55 }
56 if(asyncRes[i].tenantName){
57 cy.getTableRowByIndex('instantiation-status', i).get('td#tenantName span').contains(asyncRes[i].tenantName);
58 }
59 if(asyncRes[i].serviceModelName){
60 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelName span').contains(asyncRes[i].serviceModelName);
61 }
62 if(asyncRes[i].serviceInstanceName){
63 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceInstanceName span').contains(asyncRes[i].serviceInstanceName);
64 }
65 if(asyncRes[i].serviceModelVersion){
66 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelVersion span').contains(asyncRes[i].serviceModelVersion);
67 }
68 if(asyncRes[i].subscriberName){
69 cy.getTableRowByIndex('instantiation-status', i).get('td#subscriberName span').contains(asyncRes[i].subscriberName);
70 }
71 if(asyncRes[i].action) {
72 cy.getTableRowByIndex('instantiation-status', i).get('td#action span').contains(serviceAction[asyncRes[i].action]);
73 }
74 }
75 });
76
Einat Vinouze5b5e0bb2020-05-21 18:16:57 +030077 function getJobIconClass(status: string) : string{
78 switch(`${status}`.toUpperCase()) {
79 case 'PENDING' :
80 return PENDING;
81 case 'IN_PROGRESS' :
82 return INPROGRESS;
83 case 'PAUSED' :
84 return PAUSE;
85 case 'FAILED' :
86 return X_O;
87 case 'COMPLETED' :
88 return SUCCESS_CIRCLE;
89 case 'STOPPED' :
90 return STOPPED;
91 case 'COMPLETED_WITH_ERRORS' :
92 return COMPLETED_WITH_ERRORS;
93 case 'COMPLETED_AND_PAUSED' :
94 return PAUSE_UPON_COMPLETION;
95 default:
96 return UNKNOWN;
97 }
98 }
99
Eylon Malind00cf802019-12-03 12:12:38 +0200100 it('should filter rows by filter text', function () {
101 cy.openIframe('app/ui/#/instantiationStatus');
Sara Weissbae7a352019-12-08 14:47:42 +0200102 cy.getElementByDataTestsId("instantiation-status-filter").type("ComplexService");
Eylon Malinafcfb822019-12-08 16:42:52 +0200103 cy.get('table#instantiation-status tbody tr').should('have.length', 2);
Eylon Malind00cf802019-12-03 12:12:38 +0200104 });
105
106 it('should filter rows by url filter text', function () {
107 cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService');
Sara Weissbae7a352019-12-08 14:47:42 +0200108 cy.getElementByDataTestsId("instantiation-status-filter").should('have.value','ComplexService');
Eylon Malinafcfb822019-12-08 16:42:52 +0200109 cy.get('table#instantiation-status tbody tr').should('have.length', 2);
Eylon Malind00cf802019-12-03 12:12:38 +0200110 });
111
Eylon Malin640a01e2019-12-08 15:56:46 +0200112 function getDisabledDropDownItemByDataTestId(testId:String) {
Eylon Malin93f8bd72019-12-08 10:12:01 +0200113 return cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='${testId}']`);
114 }
115
116 function clickOnTitleAndThenOnMenuWithJobId(jobId: string) {
117 cy.getElementByDataTestsId("instantiation-status-title").click();
118 cy.get('#' + jobId).find('.menu-div').click();
119 }
120
Einat Vinouzed05d1c82020-06-02 13:49:23 +0300121 it('should disabled correct menu items', function () {
Ittay Stern6f900cc2018-08-29 17:01:32 +0300122
Eylon Malin93f8bd72019-12-08 10:12:01 +0200123 cy.openIframe('app/ui/#/instantiationStatus');
Ittay Stern6f900cc2018-08-29 17:01:32 +0300124
Eylon Malin93f8bd72019-12-08 10:12:01 +0200125 // Instantiate action with Job status FAILED - isRetry = true
Eylon Malin93f8bd72019-12-08 10:12:01 +0200126 clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459');
Eylon Malin640a01e2019-12-08 15:56:46 +0200127 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.exist');
128 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
129 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
130 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
131 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
132 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
Eylon Malin93f8bd72019-12-08 10:12:01 +0200133
134 // Instantiate action with Job status FAILED - isRetry = false
135 clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7');
Eylon Malin640a01e2019-12-08 15:56:46 +0200136 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.be.visible');
137 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
138 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
Eylon Malin93f8bd72019-12-08 10:12:01 +0200139
140 //Delete action with Job status IN_PROGRESS
141 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2');
Eylon Malin640a01e2019-12-08 15:56:46 +0200142 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
143 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
144 getDisabledDropDownItemByDataTestId('context-menu-hide').should('exist');
145 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
146 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
Eylon Malin93f8bd72019-12-08 10:12:01 +0200147
148 //Update action with Job status COMPLETED
149 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1');
Eylon Malin640a01e2019-12-08 15:56:46 +0200150 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
151 getDisabledDropDownItemByDataTestId('context-menu-open').should('not.exist');
152 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
153 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
154 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
Einat Vinouzee0638b12020-06-02 11:10:41 +0300155
156 //COMPLETED_AND_PAUSED
157 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339d9');
158 getDisabledDropDownItemByDataTestId('context-menu-retry').should('exist');
159 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
160 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('exist');
161 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
Eylon Malin640a01e2019-12-08 15:56:46 +0200162 });
163
164 it('clicking on create another one item, go to expected url', function () {
165 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:8
166 const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
167 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
Eylon Malinfa4d3e52020-01-02 14:08:31 +0200168 const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`;
Eylon Malin640a01e2019-12-08 15:56:46 +0200169
170 cy.openIframe('app/ui/#/instantiationStatus');
171
172 clickOnTitleAndThenOnMenuWithJobId(jobId);
Eylon Malin18361152019-12-16 10:24:57 +0200173 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).contains('Create another one');
Eylon Malin640a01e2019-12-08 15:56:46 +0200174 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).click();
175 cy.location().should((loc) => {
176 expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
177 });
Ittay Stern6f900cc2018-08-29 17:01:32 +0300178 });
Ittay Stern607ea3d2019-10-23 17:10:52 +0300179
Alexey Sandlera3b9e3e2020-04-19 20:32:42 +0300180 it('clicking on new view edit, go to expected url', function () {
181 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:10
182 const jobId = '850dc7d2-5240-437f-9bcd-b1ed7dc339c1';
183 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
184 const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`;
185 const serviceType = 'TYLER%20SILVIA';
186
187 cy.openIframe('app/ui/#/instantiationStatus');
188 clickOnTitleAndThenOnMenuWithJobId(jobId);
189 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).contains('New View/Edit');
190 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).click();
191 cy.location().should((location) => {
192 expect(location.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&serviceType=${serviceType}&jobId=${jobId}`);
193 });
194 });
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +0300195});