blob: 5bc02d1c2f318b0e0d17bb90ad34316f66c2bb9b [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;
6 }
7}
8
9function preventErrorsOnLoading() : void {
10 cy.on('uncaught:exception', (err, runnable) => {
11 return false
12 });
13}
14
15function initGetToMenuInfo(response? : JSON) : void {
16 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/topMenuInfo.json').then((res) => {
17 cy.server()
18 .route({
19 method: 'GET',
20 status : 200,
21 url : Cypress.config('baseUrl') + "/get_topMenuInfo",
22 response : response ? response : res
23 });
24 });
25
26}
27
28
29function initCategoryParameter(response? : JSON) : void {
30 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/categoryParametres.json').then((res) => {
31 cy.server()
32 .route({
33 method: 'GET',
34 status : 200,
35 url : Cypress.config('baseUrl') + "/category_parameter**",
36 response : response ? response : res
37 });
38 })
39}
40
41function initFlags(response? : JSON, delay?: number, status?: number) : void {
42 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/flags.json').then((res) => {
43 cy.server()
44 .route({
45 method: 'GET',
46 delay : delay ? delay : 0,
47 status : status ? status : 200,
48 url : Cypress.config('baseUrl') + "/flags**",
49 response : response ? response : res
50 }).as('initFlags');
51 })
52}
53
54function initAuditInfoVID(response? : JSON, delay?: number, status?: number) : void {
55 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/auditInfoVid.json').then((res) => {
56 cy.server()
57 .route({
58 method: 'GET',
59 delay : delay ? delay : 0,
60 status : status ? status : 200,
61 url : Cypress.config('baseUrl') + "/asyncInstantiation/auditStatus/**?source=VID",
62 response : response ? response : res
63 }).as('initAuditInfoVID');
64 })
65}
66
67function initAuditInfoMSO(response? : JSON, delay?: number, status?: number) : void {
68 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/auditInfoMSO.json').then((res) => {
69 cy.server()
70 .route({
71 method: 'GET',
72 delay : delay ? delay : 0,
73 status : status ? status : 200,
74 url : Cypress.config('baseUrl') + "/asyncInstantiation/auditStatus/**?source=MSO",
75 response : response ? response : res
76 }).as('initAuditInfoMSO');
77 })
78}
79
80function initVidMock(): void {
81 initGetToMenuInfo();
82 initCategoryParameter();
83 initFlags();
84 initAuditInfoVID();
85 initAuditInfoMSO();
86}
87
88
89Cypress.Commands.add('initVidMock', initVidMock);
90Cypress.Commands.add('preventErrorsOnLoading', preventErrorsOnLoading);
91Cypress.Commands.add('initCategoryParameter', initCategoryParameter);