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; |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | function httpGetDDLData(): void { |
| 10 | cy |
| 11 | .server() |
| 12 | .route({ |
| 13 | method: 'GET', |
| 14 | url: |
| 15 | Cypress.env('backendUrl') + |
| 16 | '/service/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a', |
| 17 | response: 'fixture:serviceDdl' |
| 18 | }) |
| 19 | .as('vfniListApi') |
| 20 | .route({ |
| 21 | method: 'GET', |
| 22 | url: |
| 23 | Cypress.env('backendUrl') + '/getResourcesByMonitoringTemplateCategory', |
| 24 | response: [{ name: 'AviStone1234' }] |
| 25 | }) |
| 26 | .as('templateAPi'); |
| 27 | } |
| 28 | |
| 29 | function fillNewMcForm() { |
| 30 | cy.get('input[data-tests-id="nameMc"]').type('new mc'); |
| 31 | cy.get('textarea[data-tests-id="descMc"]').type('Hello Description'); |
| 32 | cy.get('select[data-tests-id="templateDdl"]').select('AviStone1234'); |
| 33 | cy.get('select[data-tests-id="vfniDdl"]').select('LiavSrv'); |
| 34 | } |
| 35 | |
| 36 | function httpCreateNewMc() { |
| 37 | cy.server(); |
| 38 | cy |
| 39 | .route({ |
| 40 | method: 'POST', |
| 41 | url: Cypress.env('backendUrl') + '/createMC', |
| 42 | response: 'fixture:createMcRes' |
| 43 | }) |
| 44 | .as('newMC'); |
| 45 | } |
| 46 | |
| 47 | // Add cypress commands |
| 48 | Cypress.Commands.add('httpGetDDLData', httpGetDDLData); |
| 49 | Cypress.Commands.add('fillNewMcForm', fillNewMcForm); |
| 50 | Cypress.Commands.add('httpCreateNewMc', httpCreateNewMc); |