Stone, Avi (as206k) | 9b2ceb3 | 2018-04-12 16:36:39 +0300 | [diff] [blame] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | httpGetDDLData: typeof httpGetDDLData; |
| 4 | fillNewMcForm: typeof fillNewMcForm; |
| 5 | httpCreateNewMc: typeof httpCreateNewMc; |
Stone, Avi (as206k) | 548c5a2 | 2018-06-03 13:12:12 +0300 | [diff] [blame^] | 6 | httpCreateNewMcWithBooleanDDL: typeof httpCreateNewMcWithBooleanDDL; |
Stone, Avi (as206k) | 9b2ceb3 | 2018-04-12 16:36:39 +0300 | [diff] [blame] | 7 | } |
| 8 | } |
| 9 | |
| 10 | function httpGetDDLData(): void { |
| 11 | cy |
| 12 | .server() |
| 13 | .route({ |
| 14 | method: 'GET', |
| 15 | url: |
| 16 | Cypress.env('backendUrl') + |
| 17 | '/service/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a', |
| 18 | response: 'fixture:serviceDdl' |
| 19 | }) |
| 20 | .as('vfniListApi') |
| 21 | .route({ |
| 22 | method: 'GET', |
| 23 | url: |
| 24 | Cypress.env('backendUrl') + '/getResourcesByMonitoringTemplateCategory', |
| 25 | response: [{ name: 'AviStone1234' }] |
| 26 | }) |
| 27 | .as('templateAPi'); |
| 28 | } |
| 29 | |
| 30 | function fillNewMcForm() { |
| 31 | cy.get('input[data-tests-id="nameMc"]').type('new mc'); |
| 32 | cy.get('textarea[data-tests-id="descMc"]').type('Hello Description'); |
| 33 | cy.get('select[data-tests-id="templateDdl"]').select('AviStone1234'); |
| 34 | cy.get('select[data-tests-id="vfniDdl"]').select('LiavSrv'); |
| 35 | } |
| 36 | |
| 37 | function httpCreateNewMc() { |
| 38 | cy.server(); |
| 39 | cy |
| 40 | .route({ |
| 41 | method: 'POST', |
| 42 | url: Cypress.env('backendUrl') + '/createMC', |
| 43 | response: 'fixture:createMcRes' |
| 44 | }) |
| 45 | .as('newMC'); |
| 46 | } |
| 47 | |
Stone, Avi (as206k) | 548c5a2 | 2018-06-03 13:12:12 +0300 | [diff] [blame^] | 48 | function httpCreateNewMcWithBooleanDDL() { |
| 49 | cy.server(); |
| 50 | cy |
| 51 | .route({ |
| 52 | method: 'POST', |
| 53 | url: Cypress.env('backendUrl') + '/createMC', |
| 54 | response: 'fixture:createMcResWithBooleanDDL' |
| 55 | }) |
| 56 | .as('newMCWithBooleanDDL'); |
| 57 | } |
| 58 | |
Stone, Avi (as206k) | 9b2ceb3 | 2018-04-12 16:36:39 +0300 | [diff] [blame] | 59 | // Add cypress commands |
| 60 | Cypress.Commands.add('httpGetDDLData', httpGetDDLData); |
| 61 | Cypress.Commands.add('fillNewMcForm', fillNewMcForm); |
| 62 | Cypress.Commands.add('httpCreateNewMc', httpCreateNewMc); |
Stone, Avi (as206k) | 548c5a2 | 2018-06-03 13:12:12 +0300 | [diff] [blame^] | 63 | Cypress.Commands.add( |
| 64 | 'httpCreateNewMcWithBooleanDDL', |
| 65 | httpCreateNewMcWithBooleanDDL |
| 66 | ); |