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; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 6 | initTenants : typeof initTenants; |
| 7 | initSearchVNFMemebers : typeof initSearchVNFMemebers; |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 8 | initActiveNetworks : typeof initActiveNetworks; |
| 9 | initActiveVPNs : typeof initActiveVPNs; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 10 | } |
| 11 | } |
| 12 | |
| 13 | function initGetSubscribers(response? : JSON) : void { |
| 14 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/subscribers.json').then((res) => { |
| 15 | cy.server() |
| 16 | .route({ |
| 17 | method: 'GET', |
| 18 | status : 200, |
| 19 | url : Cypress.config('baseUrl') + "/aai_get_subscribers**", |
| 20 | response : response ? response : res |
| 21 | }).as('initGetSubscribers') |
| 22 | }); |
| 23 | } |
| 24 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 25 | function initAaiGetFullSubscribers(response? : JSON) : void { |
| 26 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/subscribers.json').then((res) => { |
| 27 | cy.server() |
| 28 | .route({ |
| 29 | method: 'GET', |
| 30 | status : 200, |
| 31 | url : Cypress.config('baseUrl') + "/aai_get_full_subscribers**", |
| 32 | response : response ? response : res |
| 33 | }).as('initGetSubscribers') |
| 34 | }); |
| 35 | } |
| 36 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 37 | function initGetAAISubDetails(response? : JSON) : void { |
| 38 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/aaiSubDetails.json').then((res) => { |
| 39 | cy.server() |
| 40 | .route({ |
| 41 | method: 'GET', |
| 42 | status: 200, |
| 43 | url: Cypress.config('baseUrl') + "/aai_sub_details**", |
| 44 | response: response ? response : res |
| 45 | }) |
| 46 | }); |
| 47 | } |
| 48 | |
| 49 | function initAlaCarteService(response? : JSON) : void { |
| 50 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/a-la-carteService.json').then((res) => { |
| 51 | cy.server() |
| 52 | .route({ |
| 53 | method: 'GET', |
| 54 | status: 200, |
| 55 | url: Cypress.config('baseUrl') + "/rest/models/services**", |
| 56 | response: response ? response : res |
| 57 | }).as('initAlaCarteService') |
| 58 | }); |
| 59 | } |
| 60 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | function initTenants(response? : JSON) : void { |
| 66 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/tenants.json').then((res) => { |
| 67 | cy.server() |
| 68 | .route({ |
| 69 | method: 'GET', |
| 70 | status: 200, |
| 71 | url: Cypress.config('baseUrl') + "/aai_get_tenants/**", |
| 72 | response: response ? response : res |
| 73 | }).as('initTenants') |
| 74 | }); |
| 75 | } |
| 76 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 77 | function initAAIServices(response? : JSON) : void { |
| 78 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/aaiServices.json').then((res) => { |
| 79 | cy.server() |
| 80 | .route({ |
| 81 | method: 'GET', |
| 82 | status : 200, |
| 83 | url : Cypress.config('baseUrl') + "/aai_get_services**", |
| 84 | response : response ? response : res |
| 85 | }).as(('initAAIServices')); |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | function initZones(response? : JSON) : void { |
| 90 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/zones.json').then((res) => { |
| 91 | cy.server() |
| 92 | .route({ |
| 93 | method: 'GET', |
| 94 | status : 200, |
| 95 | url : Cypress.config('baseUrl') + "/aai_get_aic_zones**", |
| 96 | response : response ? response : res |
| 97 | }).as(('zones')); |
| 98 | }); |
| 99 | } |
| 100 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 101 | //Mock of vnf's that members for VNF Group |
| 102 | function initSearchVNFMemebers(response? : JSON) : void { |
| 103 | cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => { |
| 104 | cy.server() |
| 105 | .route({ |
| 106 | method: 'GET', |
| 107 | status : 200, |
| 108 | url : Cypress.config('baseUrl') + "/aai_search_group_members/**", |
| 109 | response : response ? response : res |
| 110 | }).as(('searchVNFMembers')); |
| 111 | }); |
| 112 | } |
| 113 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 114 | function initActiveNetworks(response? : JSON) : void { |
| 115 | cy.readFile('../vid-automation/src/test/resources/viewEdit/aaiGetActiveNetworks.json').then((res) => { |
| 116 | cy.server() |
| 117 | .route({ |
| 118 | method: 'GET', |
| 119 | status : 200, |
| 120 | url : Cypress.config('baseUrl') + "/aai_get_active_networks/**", |
| 121 | response : response ? response : res |
| 122 | }).as(('getActiveNetworks')); |
| 123 | }); |
| 124 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 125 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 126 | function initActiveVPNs(response? : JSON) : void { |
| 127 | cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/aaiActiveVPNs.json').then((res) => { |
| 128 | cy.server() |
| 129 | .route({ |
| 130 | method: 'GET', |
| 131 | status : 200, |
| 132 | url : Cypress.config('baseUrl') + "/aai_get_vpn_list/**", |
| 133 | response : response ? response : res |
| 134 | }).as(('getVPNs')); |
| 135 | }); |
| 136 | } |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 137 | |
| 138 | function initAAIMock(): void { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 139 | initAaiGetFullSubscribers(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 140 | initGetSubscribers(); |
| 141 | initAAIServices(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 142 | initTenants(); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 143 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | |
| 147 | Cypress.Commands.add('initAAIMock', initAAIMock); |
| 148 | Cypress.Commands.add('initAlaCarteService', initAlaCarteService); |
| 149 | Cypress.Commands.add('initZones', initZones); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 150 | Cypress.Commands.add('initTenants', initTenants); |
| 151 | Cypress.Commands.add('initAaiGetFullSubscribers', initAaiGetFullSubscribers); |
| 152 | Cypress.Commands.add('initSearchVNFMemebers', initSearchVNFMemebers); |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 153 | Cypress.Commands.add('initActiveNetworks', initActiveNetworks); |
| 154 | Cypress.Commands.add('initActiveVPNs', initActiveVPNs); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 155 | |
| 156 | |