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'; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 6 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 7 | describe('Instantiation status', function () { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 8 | var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 9 | var asyncRes: Array<any>; |
| 10 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 11 | beforeEach(() => { |
Ittay Stern | 32dbf80 | 2019-10-29 12:58:49 +0200 | [diff] [blame] | 12 | cy.clearSessionStorage(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 13 | cy.setReduxState(); |
| 14 | cy.preventErrorsOnLoading(); |
| 15 | cy.initAAIMock(); |
| 16 | cy.initVidMock(); |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 17 | jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json', |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 18 | Cypress.config('baseUrl') + "/asyncInstantiation**", |
| 19 | (res: any) => { |
| 20 | asyncRes = res; |
| 21 | return res; |
| 22 | }); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 23 | cy.login(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 24 | }); |
| 25 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 26 | afterEach(() => { |
| 27 | cy.screenshot(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 28 | }); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 29 | |
| 30 | it('should display the correct icons per status', function () { |
Ittay Stern | c439c81 | 2019-10-30 14:46:22 +0200 | [diff] [blame] | 31 | const serviceAction:any = {INSTANTIATE : 'Instantiate', DELETE: 'Delete', UPDATE: 'Update', UPGRADE: 'Upgrade'}; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 32 | cy.openIframe('app/ui/#/instantiationStatus'); |
| 33 | for(let i = 0 ; i < asyncRes.length; i++){ |
| 34 | if(asyncRes[i].project){ |
| 35 | cy.getTableRowByIndex('instantiation-status', i).get('td#project span').contains(asyncRes[i].project); |
| 36 | } |
| 37 | if(asyncRes[i].userId){ |
| 38 | cy.getTableRowByIndex('instantiation-status', i).get('td#userId span').contains(asyncRes[i].userId); |
| 39 | } |
| 40 | if(asyncRes[i].tenantName){ |
| 41 | cy.getTableRowByIndex('instantiation-status', i).get('td#tenantName span').contains(asyncRes[i].tenantName); |
| 42 | } |
| 43 | if(asyncRes[i].serviceModelName){ |
| 44 | cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelName span').contains(asyncRes[i].serviceModelName); |
| 45 | } |
| 46 | if(asyncRes[i].serviceInstanceName){ |
| 47 | cy.getTableRowByIndex('instantiation-status', i).get('td#serviceInstanceName span').contains(asyncRes[i].serviceInstanceName); |
| 48 | } |
| 49 | if(asyncRes[i].serviceModelVersion){ |
| 50 | cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelVersion span').contains(asyncRes[i].serviceModelVersion); |
| 51 | } |
| 52 | if(asyncRes[i].subscriberName){ |
| 53 | cy.getTableRowByIndex('instantiation-status', i).get('td#subscriberName span').contains(asyncRes[i].subscriberName); |
| 54 | } |
| 55 | if(asyncRes[i].action) { |
| 56 | cy.getTableRowByIndex('instantiation-status', i).get('td#action span').contains(serviceAction[asyncRes[i].action]); |
| 57 | } |
| 58 | } |
| 59 | }); |
| 60 | |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 61 | it('should filter rows by filter text', function () { |
| 62 | cy.openIframe('app/ui/#/instantiationStatus'); |
| 63 | cy.getElementByDataTestsId("instantiationStatusFilter").type("ComplexService"); |
Eylon Malin | afcfb82 | 2019-12-08 16:42:52 +0200 | [diff] [blame^] | 64 | cy.get('table#instantiation-status tbody tr').should('have.length', 2); |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 65 | }); |
| 66 | |
| 67 | it('should filter rows by url filter text', function () { |
| 68 | cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService'); |
| 69 | cy.getElementByDataTestsId("instantiationStatusFilter").should('have.value','ComplexService'); |
Eylon Malin | afcfb82 | 2019-12-08 16:42:52 +0200 | [diff] [blame^] | 70 | cy.get('table#instantiation-status tbody tr').should('have.length', 2); |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 71 | }); |
| 72 | |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 73 | function getDropDownMenuByDataTestId(testId:String) { |
| 74 | return cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='${testId}']`); |
| 75 | } |
| 76 | |
| 77 | function clickOnTitleAndThenOnMenuWithJobId(jobId: string) { |
| 78 | cy.getElementByDataTestsId("instantiation-status-title").click(); |
| 79 | cy.get('#' + jobId).find('.menu-div').click(); |
| 80 | } |
| 81 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 82 | it('should enable correct menu items', function () { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 83 | |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 84 | cy.openIframe('app/ui/#/instantiationStatus'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 85 | |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 86 | // Instantiate action with Job status FAILED - isRetry = true |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 87 | |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 88 | clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459'); |
| 89 | getDropDownMenuByDataTestId('context-menu-retry').should('not.exist'); |
| 90 | getDropDownMenuByDataTestId('context-menu-remove').should('exist'); |
| 91 | getDropDownMenuByDataTestId('context-menu-open').should('exist'); |
| 92 | getDropDownMenuByDataTestId('context-menu-hide').should('not.exist'); |
| 93 | getDropDownMenuByDataTestId('context-menu-audit-info').should('not.exist'); |
| 94 | |
| 95 | // Instantiate action with Job status FAILED - isRetry = false |
| 96 | clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7'); |
| 97 | getDropDownMenuByDataTestId('context-menu-retry').should('not.be.visible'); |
| 98 | getDropDownMenuByDataTestId('context-menu-open').should('exist'); |
| 99 | |
| 100 | //Delete action with Job status IN_PROGRESS |
| 101 | clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2'); |
| 102 | getDropDownMenuByDataTestId('context-menu-remove').should('exist'); |
| 103 | getDropDownMenuByDataTestId('context-menu-open').should('exist'); |
| 104 | getDropDownMenuByDataTestId('context-menu-hide').should('exist'); |
| 105 | getDropDownMenuByDataTestId('context-menu-audit-info').should('not.exist'); |
| 106 | |
| 107 | //Update action with Job status COMPLETED |
| 108 | clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1'); |
| 109 | getDropDownMenuByDataTestId('context-menu-remove').should('exist'); |
| 110 | getDropDownMenuByDataTestId('context-menu-open').should('not.exist'); |
| 111 | getDropDownMenuByDataTestId('context-menu-hide').should('not.exist'); |
| 112 | getDropDownMenuByDataTestId('context-menu-audit-info').should('not.exist'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 113 | }); |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 114 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 115 | }); |