blob: 8b25488b6600a22fd9349bf1c885fa87ff6b8d95 [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001declare namespace Cypress {
2 interface Chainable {
3 initVidMock: typeof initVidMock;
4 preventErrorsOnLoading : typeof preventErrorsOnLoading;
5 initCategoryParameter : typeof initCategoryParameter;
Ittay Stern6f900cc2018-08-29 17:01:32 +03006 initAuditInfoMSO: typeof initAuditInfoMSO;
7 initAuditInfoMSOALaCarte: typeof initAuditInfoMSOALaCarte;
8 initAsyncInstantiation : typeof initAsyncInstantiation;
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03009 }
10}
11
12function preventErrorsOnLoading() : void {
13 cy.on('uncaught:exception', (err, runnable) => {
14 return false
15 });
16}
17
18function initGetToMenuInfo(response? : JSON) : void {
19 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/topMenuInfo.json').then((res) => {
20 cy.server()
21 .route({
22 method: 'GET',
23 status : 200,
24 url : Cypress.config('baseUrl') + "/get_topMenuInfo",
25 response : response ? response : res
26 });
27 });
28
29}
30
31
32function initCategoryParameter(response? : JSON) : void {
33 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/categoryParametres.json').then((res) => {
34 cy.server()
35 .route({
36 method: 'GET',
37 status : 200,
38 url : Cypress.config('baseUrl') + "/category_parameter**",
39 response : response ? response : res
Ittay Stern6f900cc2018-08-29 17:01:32 +030040 }).as('initCategoryParameters');
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030041 })
42}
43
44function initFlags(response? : JSON, delay?: number, status?: number) : void {
45 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/flags.json').then((res) => {
46 cy.server()
47 .route({
48 method: 'GET',
49 delay : delay ? delay : 0,
50 status : status ? status : 200,
51 url : Cypress.config('baseUrl') + "/flags**",
52 response : response ? response : res
53 }).as('initFlags');
54 })
55}
56
57function initAuditInfoVID(response? : JSON, delay?: number, status?: number) : void {
58 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/auditInfoVid.json').then((res) => {
59 cy.server()
60 .route({
61 method: 'GET',
62 delay : delay ? delay : 0,
63 status : status ? status : 200,
64 url : Cypress.config('baseUrl') + "/asyncInstantiation/auditStatus/**?source=VID",
65 response : response ? response : res
66 }).as('initAuditInfoVID');
67 })
68}
69
70function initAuditInfoMSO(response? : JSON, delay?: number, status?: number) : void {
71 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/auditInfoMSO.json').then((res) => {
72 cy.server()
73 .route({
74 method: 'GET',
75 delay : delay ? delay : 0,
76 status : status ? status : 200,
77 url : Cypress.config('baseUrl') + "/asyncInstantiation/auditStatus/**?source=MSO",
78 response : response ? response : res
79 }).as('initAuditInfoMSO');
80 })
81}
82
Ittay Stern6f900cc2018-08-29 17:01:32 +030083function initAuditInfoMSOALaCarte(response? : JSON, delay?: number, status?: number) : void {
84 cy.readFile('../vid-automation/src/test/resources/a-la-carte/auditInfoMSOALaCarte.json').then((res) => {
85 cy.server()
86 .route({
87 method: 'GET',
88 delay : delay ? delay : 0,
89 status : status ? status : 200,
90 url : Cypress.config('baseUrl') + "/asyncInstantiation/auditStatus/**/mso**",
91 response : response ? response : res
92 }).as('initAuditInfoMSOAlaCarte');
93 })
94}
95
96function initAsyncInstantiation(response? : JSON, delay?: number, status?: number) : void {
97 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/basicAsyncInstantiation.json').then((res) => {
98 cy.server()
99 .route({
100 method: 'GET',
101 delay : delay ? delay : 0,
102 status : status ? status : 200,
103 url : Cypress.config('baseUrl') + "/asyncInstantiation",
104 response : response ? response : res
105 }).as('initAsyncInstantiation');
106 })
107}
108
109
110
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +0300111function initVidMock(): void {
112 initGetToMenuInfo();
113 initCategoryParameter();
114 initFlags();
115 initAuditInfoVID();
116 initAuditInfoMSO();
117}
118
119
120Cypress.Commands.add('initVidMock', initVidMock);
121Cypress.Commands.add('preventErrorsOnLoading', preventErrorsOnLoading);
122Cypress.Commands.add('initCategoryParameter', initCategoryParameter);
Ittay Stern6f900cc2018-08-29 17:01:32 +0300123Cypress.Commands.add('initAuditInfoMSO', initAuditInfoMSO);
124Cypress.Commands.add('initAuditInfoMSOALaCarte', initAuditInfoMSOALaCarte);
125Cypress.Commands.add('initAsyncInstantiation', initAsyncInstantiation);