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