Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | declare namespace Cypress { |
| 2 | interface Chainable { |
| 3 | initAAIMock: typeof initAAIMock; |
| 4 | initAlaCarteService : typeof initAlaCarteService; |
| 5 | initZones : typeof initZones; |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | function initGetSubscribers(response? : JSON) : void { |
| 10 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/subscribers.json').then((res) => { |
| 11 | cy.server() |
| 12 | .route({ |
| 13 | method: 'GET', |
| 14 | status : 200, |
| 15 | url : Cypress.config('baseUrl') + "/aai_get_subscribers**", |
| 16 | response : response ? response : res |
| 17 | }).as('initGetSubscribers') |
| 18 | }); |
| 19 | } |
| 20 | |
| 21 | function initGetAAISubDetails(response? : JSON) : void { |
| 22 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/aaiSubDetails.json').then((res) => { |
| 23 | cy.server() |
| 24 | .route({ |
| 25 | method: 'GET', |
| 26 | status: 200, |
| 27 | url: Cypress.config('baseUrl') + "/aai_sub_details**", |
| 28 | response: response ? response : res |
| 29 | }) |
| 30 | }); |
| 31 | } |
| 32 | |
| 33 | function initAlaCarteService(response? : JSON) : void { |
| 34 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/a-la-carteService.json').then((res) => { |
| 35 | cy.server() |
| 36 | .route({ |
| 37 | method: 'GET', |
| 38 | status: 200, |
| 39 | url: Cypress.config('baseUrl') + "/rest/models/services**", |
| 40 | response: response ? response : res |
| 41 | }).as('initAlaCarteService') |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | function initAAIServices(response? : JSON) : void { |
| 46 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/aaiServices.json').then((res) => { |
| 47 | cy.server() |
| 48 | .route({ |
| 49 | method: 'GET', |
| 50 | status : 200, |
| 51 | url : Cypress.config('baseUrl') + "/aai_get_services**", |
| 52 | response : response ? response : res |
| 53 | }).as(('initAAIServices')); |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | function initZones(response? : JSON) : void { |
| 58 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/zones.json').then((res) => { |
| 59 | cy.server() |
| 60 | .route({ |
| 61 | method: 'GET', |
| 62 | status : 200, |
| 63 | url : Cypress.config('baseUrl') + "/aai_get_aic_zones**", |
| 64 | response : response ? response : res |
| 65 | }).as(('zones')); |
| 66 | }); |
| 67 | } |
| 68 | |
| 69 | |
| 70 | function initAAIMock(): void { |
| 71 | initGetSubscribers(); |
| 72 | initAAIServices(); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | Cypress.Commands.add('initAAIMock', initAAIMock); |
| 77 | Cypress.Commands.add('initAlaCarteService', initAlaCarteService); |
| 78 | Cypress.Commands.add('initZones', initZones); |
| 79 | |
| 80 | |