1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 /// <reference types="Cypress" />
4 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
5 import {AsyncInstantiationModel} from '../../support/jsonBuilders/models/asyncInstantiation.model';
7 describe('Instantiation status', function () {
8 var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
9 var asyncRes: Array<any>;
10 const contextMenuCreateAnotherOne = 'context-menu-create-another-one';
11 const contextMenuNewViewEdit = 'context-menu-new-view-edit';
14 cy.clearSessionStorage();
16 cy.preventErrorsOnLoading();
19 jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
20 Cypress.config('baseUrl') + "/asyncInstantiation**",
32 it('should display the correct icons per status', function () {
33 const serviceAction:any = {INSTANTIATE : 'Instantiate', DELETE: 'Delete', UPDATE: 'Update', UPGRADE: 'Upgrade'};
34 cy.openIframe('app/ui/#/instantiationStatus');
35 for(let i = 0 ; i < asyncRes.length; i++){
36 cy.getTableRowByIndex('instantiation-status', i).get(`td custom-icon#jobStatusIcon-${i} div`)
37 .should('have.class', `__${getJobIconClass(asyncRes[i].jobStatus)}`);
39 if(asyncRes[i].project){
40 cy.getTableRowByIndex('instantiation-status', i).get('td#project span').contains(asyncRes[i].project);
42 if(asyncRes[i].userId){
43 cy.getTableRowByIndex('instantiation-status', i).get('td#userId span').contains(asyncRes[i].userId);
45 if(asyncRes[i].tenantName){
46 cy.getTableRowByIndex('instantiation-status', i).get('td#tenantName span').contains(asyncRes[i].tenantName);
48 if(asyncRes[i].serviceModelName){
49 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelName span').contains(asyncRes[i].serviceModelName);
51 if(asyncRes[i].serviceInstanceName){
52 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceInstanceName span').contains(asyncRes[i].serviceInstanceName);
54 if(asyncRes[i].serviceModelVersion){
55 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelVersion span').contains(asyncRes[i].serviceModelVersion);
57 if(asyncRes[i].subscriberName){
58 cy.getTableRowByIndex('instantiation-status', i).get('td#subscriberName span').contains(asyncRes[i].subscriberName);
60 if(asyncRes[i].action) {
61 cy.getTableRowByIndex('instantiation-status', i).get('td#action span').contains(serviceAction[asyncRes[i].action]);
66 function getJobIconClass(status: string) : string{
67 switch(`${status}`.toUpperCase()) {
77 return "success-circle-o";
80 case 'COMPLETED_WITH_ERRORS' :
81 return "success_with_warning";
82 case 'COMPLETED_AND_PAUSED' :
83 return "stopped-upon-success";
85 return "question-mark-circle-o";
89 it('should filter rows by filter text', function () {
90 cy.openIframe('app/ui/#/instantiationStatus');
91 cy.getElementByDataTestsId("instantiation-status-filter").type("ComplexService");
92 cy.get('table#instantiation-status tbody tr').should('have.length', 2);
95 it('should filter rows by url filter text', function () {
96 cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService');
97 cy.getElementByDataTestsId("instantiation-status-filter").should('have.value','ComplexService');
98 cy.get('table#instantiation-status tbody tr').should('have.length', 2);
101 function getDisabledDropDownItemByDataTestId(testId:String) {
102 return cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='${testId}']`);
105 function getDropDownItemByDataTestId(testId:String) {
106 return cy.get('.dropdown-menu').find(`[data-tests-id='${testId}']`);
109 function clickOnTitleAndThenOnMenuWithJobId(jobId: string) {
110 cy.getElementByDataTestsId("instantiation-status-title").click();
111 cy.get('#' + jobId).find('.menu-div').click({force: true});
114 it('should disabled correct menu items', function () {
116 cy.openIframe('app/ui/#/instantiationStatus');
118 // Instantiate action with Job status FAILED - isRetry = true
119 clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459');
120 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.exist');
121 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
122 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
123 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
124 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
125 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
127 // Instantiate action with Job status FAILED - isRetry = false
128 clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7');
129 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.be.visible');
130 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
131 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
133 //Delete action with Job status IN_PROGRESS
134 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2');
135 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
136 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
137 getDisabledDropDownItemByDataTestId('context-menu-hide').should('exist');
138 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
139 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
141 //Update action with Job status COMPLETED
142 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1');
143 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
144 getDisabledDropDownItemByDataTestId('context-menu-open').should('not.exist');
145 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
146 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
147 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
150 it('COMPLETED_AND_PAUSED should have correct menu items', function () {
151 cy.openIframe('app/ui/#/instantiationStatus');
153 //COMPLETED_AND_PAUSED
154 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339d9');
155 getDropDownItemByDataTestId('context-menu-retry').should('exist');
156 getDropDownItemByDataTestId('context-menu-open').should('exist');
157 getDropDownItemByDataTestId('context-menu-audit-info').should('exist');
158 getDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
161 it('clicking on create another one item, go to expected url', function () {
162 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:8
163 const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
164 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
165 const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`;
167 cy.openIframe('app/ui/#/instantiationStatus');
169 clickOnTitleAndThenOnMenuWithJobId(jobId);
170 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).contains('Create another one');
171 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).click();
172 cy.location().should((loc) => {
173 expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
177 it('clicking on new view edit, go to expected url', function () {
178 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:10
179 const jobId = '850dc7d2-5240-437f-9bcd-b1ed7dc339c1';
180 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
181 const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`;
182 const serviceType = 'TYLER%20SILVIA';
184 cy.openIframe('app/ui/#/instantiationStatus');
185 clickOnTitleAndThenOnMenuWithJobId(jobId);
186 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).contains('New View/Edit');
187 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).click();
188 cy.location().should((location) => {
189 expect(location.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&serviceType=${serviceType}&jobId=${jobId}`);