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'; |
Einat Vinouze | 97710de | 2020-06-03 12:18:26 +0300 | [diff] [blame^] | 6 | |
| 7 | export let PENDING : string = "pending"; |
| 8 | export let INPROGRESS : string = "in_progress"; |
| 9 | export let PAUSE : string = "pause"; |
| 10 | export let X_O : string = "x-circle-o"; |
| 11 | export let SUCCESS_CIRCLE : string = "success-circle-o"; |
| 12 | export let STOPPED : string = "stop"; |
| 13 | export let COMPLETED_WITH_ERRORS : string = "success_with_warning"; |
| 14 | export let PAUSE_UPON_COMPLETION : string = "stopped-upon-success"; |
| 15 | export let UNKNOWN : string = "question-mark-circle-o"; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 16 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 17 | describe('Instantiation status', function () { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 18 | var jsonBuilderInstantiationBuilder : JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 19 | var asyncRes: Array<any>; |
Eylon Malin | 1836115 | 2019-12-16 10:24:57 +0200 | [diff] [blame] | 20 | const contextMenuCreateAnotherOne = 'context-menu-create-another-one'; |
Alexey Sandler | a3b9e3e | 2020-04-19 20:32:42 +0300 | [diff] [blame] | 21 | const contextMenuNewViewEdit = 'context-menu-new-view-edit'; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 22 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 23 | beforeEach(() => { |
Ittay Stern | 32dbf80 | 2019-10-29 12:58:49 +0200 | [diff] [blame] | 24 | cy.clearSessionStorage(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 25 | cy.setReduxState(); |
| 26 | cy.preventErrorsOnLoading(); |
| 27 | cy.initAAIMock(); |
| 28 | cy.initVidMock(); |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 29 | jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json', |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 30 | Cypress.config('baseUrl') + "/asyncInstantiation**", |
| 31 | (res: any) => { |
| 32 | asyncRes = res; |
| 33 | return res; |
| 34 | }); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 35 | cy.login(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 36 | }); |
| 37 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 38 | afterEach(() => { |
| 39 | cy.screenshot(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 40 | }); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 41 | |
| 42 | it('should display the correct icons per status', function () { |
Ittay Stern | c439c81 | 2019-10-30 14:46:22 +0200 | [diff] [blame] | 43 | const serviceAction:any = {INSTANTIATE : 'Instantiate', DELETE: 'Delete', UPDATE: 'Update', UPGRADE: 'Upgrade'}; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 44 | cy.openIframe('app/ui/#/instantiationStatus'); |
| 45 | for(let i = 0 ; i < asyncRes.length; i++){ |
Einat Vinouze | 5b5e0bb | 2020-05-21 18:16:57 +0300 | [diff] [blame] | 46 | cy.getTableRowByIndex('instantiation-status', i).get(`td custom-icon#jobStatusIcon-${i} div`) |
| 47 | .should('have.class', `__${getJobIconClass(asyncRes[i].jobStatus)}`); |
| 48 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 49 | if(asyncRes[i].project){ |
| 50 | cy.getTableRowByIndex('instantiation-status', i).get('td#project span').contains(asyncRes[i].project); |
| 51 | } |
| 52 | if(asyncRes[i].userId){ |
| 53 | cy.getTableRowByIndex('instantiation-status', i).get('td#userId span').contains(asyncRes[i].userId); |
| 54 | } |
| 55 | if(asyncRes[i].tenantName){ |
| 56 | cy.getTableRowByIndex('instantiation-status', i).get('td#tenantName span').contains(asyncRes[i].tenantName); |
| 57 | } |
| 58 | if(asyncRes[i].serviceModelName){ |
| 59 | cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelName span').contains(asyncRes[i].serviceModelName); |
| 60 | } |
| 61 | if(asyncRes[i].serviceInstanceName){ |
| 62 | cy.getTableRowByIndex('instantiation-status', i).get('td#serviceInstanceName span').contains(asyncRes[i].serviceInstanceName); |
| 63 | } |
| 64 | if(asyncRes[i].serviceModelVersion){ |
| 65 | cy.getTableRowByIndex('instantiation-status', i).get('td#serviceModelVersion span').contains(asyncRes[i].serviceModelVersion); |
| 66 | } |
| 67 | if(asyncRes[i].subscriberName){ |
| 68 | cy.getTableRowByIndex('instantiation-status', i).get('td#subscriberName span').contains(asyncRes[i].subscriberName); |
| 69 | } |
| 70 | if(asyncRes[i].action) { |
| 71 | cy.getTableRowByIndex('instantiation-status', i).get('td#action span').contains(serviceAction[asyncRes[i].action]); |
| 72 | } |
| 73 | } |
| 74 | }); |
| 75 | |
Einat Vinouze | 5b5e0bb | 2020-05-21 18:16:57 +0300 | [diff] [blame] | 76 | function getJobIconClass(status: string) : string{ |
| 77 | switch(`${status}`.toUpperCase()) { |
| 78 | case 'PENDING' : |
| 79 | return PENDING; |
| 80 | case 'IN_PROGRESS' : |
| 81 | return INPROGRESS; |
| 82 | case 'PAUSED' : |
| 83 | return PAUSE; |
| 84 | case 'FAILED' : |
| 85 | return X_O; |
| 86 | case 'COMPLETED' : |
| 87 | return SUCCESS_CIRCLE; |
| 88 | case 'STOPPED' : |
| 89 | return STOPPED; |
| 90 | case 'COMPLETED_WITH_ERRORS' : |
| 91 | return COMPLETED_WITH_ERRORS; |
| 92 | case 'COMPLETED_AND_PAUSED' : |
| 93 | return PAUSE_UPON_COMPLETION; |
| 94 | default: |
| 95 | return UNKNOWN; |
| 96 | } |
| 97 | } |
| 98 | |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 99 | it('should filter rows by filter text', function () { |
| 100 | cy.openIframe('app/ui/#/instantiationStatus'); |
Sara Weiss | bae7a35 | 2019-12-08 14:47:42 +0200 | [diff] [blame] | 101 | cy.getElementByDataTestsId("instantiation-status-filter").type("ComplexService"); |
Eylon Malin | afcfb82 | 2019-12-08 16:42:52 +0200 | [diff] [blame] | 102 | cy.get('table#instantiation-status tbody tr').should('have.length', 2); |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 103 | }); |
| 104 | |
| 105 | it('should filter rows by url filter text', function () { |
| 106 | cy.openIframe('app/ui/#/instantiationStatus?filterText=ComplexService'); |
Sara Weiss | bae7a35 | 2019-12-08 14:47:42 +0200 | [diff] [blame] | 107 | cy.getElementByDataTestsId("instantiation-status-filter").should('have.value','ComplexService'); |
Eylon Malin | afcfb82 | 2019-12-08 16:42:52 +0200 | [diff] [blame] | 108 | cy.get('table#instantiation-status tbody tr').should('have.length', 2); |
Eylon Malin | d00cf80 | 2019-12-03 12:12:38 +0200 | [diff] [blame] | 109 | }); |
| 110 | |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 111 | function getDisabledDropDownItemByDataTestId(testId:String) { |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 112 | return cy.get('.dropdown-menu').find('.disabled').find(`[data-tests-id='${testId}']`); |
| 113 | } |
| 114 | |
| 115 | function clickOnTitleAndThenOnMenuWithJobId(jobId: string) { |
| 116 | cy.getElementByDataTestsId("instantiation-status-title").click(); |
| 117 | cy.get('#' + jobId).find('.menu-div').click(); |
| 118 | } |
| 119 | |
Einat Vinouze | d05d1c8 | 2020-06-02 13:49:23 +0300 | [diff] [blame] | 120 | it('should disabled correct menu items', function () { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 121 | |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 122 | cy.openIframe('app/ui/#/instantiationStatus'); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 123 | |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 124 | // Instantiate action with Job status FAILED - isRetry = true |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 125 | clickOnTitleAndThenOnMenuWithJobId('5c2cd8e5-27d0-42e3-85a1-85db5eaba459'); |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 126 | getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.exist'); |
| 127 | getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist'); |
| 128 | getDisabledDropDownItemByDataTestId('context-menu-open').should('exist'); |
| 129 | getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist'); |
| 130 | getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist'); |
| 131 | getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist'); |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 132 | |
| 133 | // Instantiate action with Job status FAILED - isRetry = false |
| 134 | clickOnTitleAndThenOnMenuWithJobId('e1db03c3-6274-4ff7-84cf-7bd3a3946de7'); |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 135 | getDisabledDropDownItemByDataTestId('context-menu-retry').should('not.be.visible'); |
| 136 | getDisabledDropDownItemByDataTestId('context-menu-open').should('exist'); |
| 137 | getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('not.exist'); |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 138 | |
| 139 | //Delete action with Job status IN_PROGRESS |
| 140 | clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c2'); |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 141 | getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist'); |
| 142 | getDisabledDropDownItemByDataTestId('context-menu-open').should('exist'); |
| 143 | getDisabledDropDownItemByDataTestId('context-menu-hide').should('exist'); |
| 144 | getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist'); |
| 145 | getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist'); |
Eylon Malin | 93f8bd7 | 2019-12-08 10:12:01 +0200 | [diff] [blame] | 146 | |
| 147 | //Update action with Job status COMPLETED |
| 148 | clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339c1'); |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 149 | getDisabledDropDownItemByDataTestId('context-menu-remove').should('exist'); |
| 150 | getDisabledDropDownItemByDataTestId('context-menu-open').should('not.exist'); |
| 151 | getDisabledDropDownItemByDataTestId('context-menu-hide').should('not.exist'); |
| 152 | getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('not.exist'); |
| 153 | getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist'); |
Einat Vinouze | e0638b1 | 2020-06-02 11:10:41 +0300 | [diff] [blame] | 154 | |
| 155 | //COMPLETED_AND_PAUSED |
| 156 | clickOnTitleAndThenOnMenuWithJobId('850dc7d2-5240-437f-9bcd-b1ed7dc339d9'); |
| 157 | getDisabledDropDownItemByDataTestId('context-menu-retry').should('exist'); |
| 158 | getDisabledDropDownItemByDataTestId('context-menu-open').should('exist'); |
| 159 | getDisabledDropDownItemByDataTestId('context-menu-audit-info').should('exist'); |
| 160 | getDisabledDropDownItemByDataTestId(contextMenuCreateAnotherOne).should('exist'); |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 161 | }); |
| 162 | |
| 163 | it('clicking on create another one item, go to expected url', function () { |
| 164 | //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:8 |
| 165 | const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459'; |
| 166 | const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0'; |
Eylon Malin | fa4d3e5 | 2020-01-02 14:08:31 +0200 | [diff] [blame] | 167 | const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`; |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 168 | |
| 169 | cy.openIframe('app/ui/#/instantiationStatus'); |
| 170 | |
| 171 | clickOnTitleAndThenOnMenuWithJobId(jobId); |
Eylon Malin | 1836115 | 2019-12-16 10:24:57 +0200 | [diff] [blame] | 172 | cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).contains('Create another one'); |
Eylon Malin | 640a01e | 2019-12-08 15:56:46 +0200 | [diff] [blame] | 173 | cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuCreateAnotherOne).click(); |
| 174 | cy.location().should((loc) => { |
| 175 | expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`); |
| 176 | }); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 177 | }); |
Ittay Stern | 607ea3d | 2019-10-23 17:10:52 +0300 | [diff] [blame] | 178 | |
Alexey Sandler | a3b9e3e | 2020-04-19 20:32:42 +0300 | [diff] [blame] | 179 | it('clicking on new view edit, go to expected url', function () { |
| 180 | //see cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json id:10 |
| 181 | const jobId = '850dc7d2-5240-437f-9bcd-b1ed7dc339c1'; |
| 182 | const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0'; |
| 183 | const vidBaseUrl = `${Cypress.config().baseUrl}/serviceModels.htm`; |
| 184 | const serviceType = 'TYLER%20SILVIA'; |
| 185 | |
| 186 | cy.openIframe('app/ui/#/instantiationStatus'); |
| 187 | clickOnTitleAndThenOnMenuWithJobId(jobId); |
| 188 | cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).contains('New View/Edit'); |
| 189 | cy.get('.dropdown-menu').getElementByDataTestsId(contextMenuNewViewEdit).click(); |
| 190 | cy.location().should((location) => { |
| 191 | expect(location.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&serviceType=${serviceType}&jobId=${jobId}`); |
| 192 | }); |
| 193 | }); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 194 | }); |