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';
13 cy.clearSessionStorage();
15 cy.preventErrorsOnLoading();
18 jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
19 Cypress.config('baseUrl') + "/asyncInstantiation**",
31 it('should display the correct icons per status', function () {
32 const serviceAction:any = {INSTANTIATE : 'Instantiate', DELETE: 'Delete', UPDATE: 'Update', UPGRADE: 'Upgrade'};
33 cy.openIframe('app/ui/#/instantiationStatus');
34 for(let i = 0 ; i < asyncRes.length; i++){
35 if(asyncRes[i].project){
36 cy.getTableRowByIndex('instantiation-status', i).get('td#project span').contains(asyncRes[i].project);
38 if(asyncRes[i].userId){
39 cy.getTableRowByIndex('instantiation-status', i).get('td#userId span').contains(asyncRes[i].userId);
41 if(asyncRes[i].tenantName){
42 cy.getTableRowByIndex('instantiation-status', i).get('td#tenantName span').contains(asyncRes[i].tenantName);
44 if(asyncRes[i].serviceModelName){
45 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelName span').contains(asyncRes[i].serviceModelName);
47 if(asyncRes[i].serviceInstanceName){
48 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceInstanceName span').contains(asyncRes[i].serviceInstanceName);
50 if(asyncRes[i].serviceModelVersion){
51 cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelVersion span').contains(asyncRes[i].serviceModelVersion);
53 if(asyncRes[i].subscriberName){
54 cy.getTableRowByIndex('instantiation-status', i).get('td#subscriberName span').contains(asyncRes[i].subscriberName);
56 if(asyncRes[i].action) {
57 cy.getTableRowByIndex('instantiation-status', i).get('td#action span').contains(serviceAction[asyncRes[i].action]);
62 it('should filter rows by filter text', function () {
63 cy.openIframe('app/ui/#/instantiationStatus');
64 cy.getElementByDataTestsId("instantiation-status-filter").type("ComplexService");
65 cy.get('table#instantiation-status tbody tr').should('have.length', 2);
68 it('should filter rows by url filter text', function () {
69 cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService');
70 cy.getElementByDataTestsId("instantiation-status-filter").should('have.value','ComplexService');
71 cy.get('table#instantiation-status tbody tr').should('have.length', 2);
74 function getDisabledDropDownItemByDataTestId(testId:String) {
75 return cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='${testId}']`);
78 function clickOnTitleAndThenOnMenuWithJobId(jobId: string) {
79 cy.getElementByDataTestsId("instantiation-status-title").click();
80 cy.get('#' + jobId).find('.menu-div').click();
83 it('should disabled correct menu items', function () {
85 cy.openIframe('app/ui/#/instantiationStatus');
87 // Instantiate action with Job status FAILED - isRetry = true
89 clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459');
90 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.exist');
91 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
92 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
93 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
94 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
95 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
97 // Instantiate action with Job status FAILED - isRetry = false
98 clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7');
99 getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.be.visible');
100 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
101 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist');
103 //Delete action with Job status IN_PROGRESS
104 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2');
105 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
106 getDisabledDropDownItemByDataTestId('context-menu-open').should('exist');
107 getDisabledDropDownItemByDataTestId('context-menu-hide').should('exist');
108 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
109 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
111 //Update action with Job status COMPLETED
112 clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1');
113 getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist');
114 getDisabledDropDownItemByDataTestId('context-menu-open').should('not.exist');
115 getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist');
116 getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist');
117 getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist');
120 it('clicking on create another one item, go to expected url', function () {
121 //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:8
122 const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
123 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
124 const vidBaseUrl = `http://localhost:8080/vid/serviceModels.htm`;
126 cy.openIframe('app/ui/#/instantiationStatus');
128 clickOnTitleAndThenOnMenuWithJobId(jobId);
129 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).contains('Create another one');
130 cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).click();
131 cy.location().should((loc) => {
132 expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);