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 clickOnTitleAndThenOnMenuWithJobId(jobId: string) {
106 cy.getElementByDataTestsId("instantiation-status-title").click();
107 cy.get('#' + jobId).find('.menu-div').click({force: true});
110 it('should disabled correct menu items', function () {
112 cy.openIframe('app/ui/#/instantiationStatus');
114 // Instantiate action with Job status FAILED - isRetry = true
115 clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459');
116 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.exist');
117 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
118 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
119 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
120 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
121 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
123 // Instantiate action with Job status FAILED - isRetry = false
124 clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7');
125 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.be.visible');
126 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
127 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
129 //Delete action with Job status IN_PROGRESS
130 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2');
131 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
132 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
133 getDisabledDropDownItemByDataTestId('context-menu-hide').should('exist');
134 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
135 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
137 //Update action with Job status COMPLETED
138 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1');
139 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
140 getDisabledDropDownItemByDataTestId('context-menu-open').should('not.exist');
141 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
142 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
143 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
145 //COMPLETED_AND_PAUSED
146 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339d9');
147 getDisabledDropDownItemByDataTestId('context-menu-retry').should('exist');
148 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
149 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('exist');
150 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
153 it('clicking on create another one item, go to expected url', function () {
154 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:8
155 const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
156 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
157 const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`;
159 cy.openIframe('app/ui/#/instantiationStatus');
161 clickOnTitleAndThenOnMenuWithJobId(jobId);
162 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).contains('Create another one');
163 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).click();
164 cy.location().should((loc) => {
165 expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
169 it('clicking on new view edit, go to expected url', function () {
170 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:10
171 const jobId = '850dc7d2-5240-437f-9bcd-b1ed7dc339c1';
172 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
173 const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`;
174 const serviceType = 'TYLER%20SILVIA';
176 cy.openIframe('app/ui/#/instantiationStatus');
177 clickOnTitleAndThenOnMenuWithJobId(jobId);
178 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).contains('New View/Edit');
179 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).click();
180 cy.location().should((location) => {
181 expect(location.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&serviceType=${serviceType}&jobId=${jobId}`);