Stone, Avi (as206k) | 9b2ceb3 | 2018-04-12 16:36:39 +0300 | [diff] [blame] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | emptyRuleEngine: typeof emptyRuleEngine; |
| 4 | httpTargetTree: typeof httpTargetTree; |
| 5 | doneSaveRule: typeof doneSaveRule; |
| 6 | httpTransalte: typeof httpTransalte; |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | function emptyRuleEngine(targetFiled) { |
| 11 | cy.server(); |
| 12 | cy |
| 13 | .route({ |
| 14 | method: 'GET', |
| 15 | url: `${Cypress.env( |
| 16 | 'backendUrl' |
| 17 | )}/rule-editor/rule/6d436c07-8006-4335-8c84-d65b4740f8d6/map/n.1517823219961.0/${targetFiled}`, |
| 18 | response: {} |
| 19 | }) |
| 20 | .as('serverRuleList') |
| 21 | .route({ |
| 22 | method: 'GET', |
| 23 | url: Cypress.env('backendUrl') + '/rule-editor/list-events-by-versions', |
| 24 | response: 'fixture:list-events-by-version' |
| 25 | }) |
| 26 | .as('serverEventsAndVersion'); |
| 27 | } |
| 28 | |
| 29 | function httpTargetTree() { |
| 30 | cy.server(); |
| 31 | cy |
| 32 | .route({ |
| 33 | method: 'GET', |
| 34 | url: |
| 35 | Cypress.env('backendUrl') + '/rule-editor/definition/4.1/syslogFields', |
| 36 | response: 'fixture:syslogTargetTree' |
| 37 | }) |
| 38 | .as('targetData'); |
| 39 | } |
| 40 | |
| 41 | function doneSaveRule() { |
| 42 | cy.server(); |
| 43 | cy |
| 44 | .route({ |
| 45 | method: 'POST', |
| 46 | url: |
| 47 | Cypress.env('backendUrl') + |
| 48 | '/rule-editor/rule/6d436c07-8006-4335-8c84-d65b4740f8d6/map/n.1517823219961.0/Type1', |
| 49 | response: 'fixture:doneSaveSimpleCopy' |
| 50 | }) |
| 51 | .as('doneSaveCopyRule'); |
| 52 | } |
| 53 | |
| 54 | function httpTransalte() { |
| 55 | cy.server(); |
| 56 | cy |
| 57 | .route({ |
| 58 | method: 'GET', |
| 59 | url: |
| 60 | Cypress.env('backendUrl') + |
| 61 | '/rule-editor/rule/translate/6d436c07-8006-4335-8c84-d65b4740f8d6/map/n.1517823219961.0/Type1', |
| 62 | response: 'fixture:TranslateSimpleCopy' |
| 63 | }) |
| 64 | .as('TranslateSimpleCopy'); |
| 65 | } |
| 66 | |
| 67 | // Add cypress commands |
| 68 | Cypress.Commands.add('emptyRuleEngine', emptyRuleEngine); |
| 69 | Cypress.Commands.add('httpTargetTree', httpTargetTree); |
| 70 | Cypress.Commands.add('doneSaveRule', doneSaveRule); |
| 71 | Cypress.Commands.add('httpTransalte', httpTransalte); |