blob: 2142e7f513fed027065a04abae6df23c68f4687f [file] [log] [blame]
Stone, Avi (as206k)9b2ceb32018-04-12 16:36:39 +03001declare namespace Cypress {
2 interface Chainable {
3 emptyRuleEngine: typeof emptyRuleEngine;
4 httpTargetTree: typeof httpTargetTree;
5 doneSaveRule: typeof doneSaveRule;
6 httpTransalte: typeof httpTransalte;
7 }
8}
9
10function 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
29function 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
41function 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
54function 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
68Cypress.Commands.add('emptyRuleEngine', emptyRuleEngine);
69Cypress.Commands.add('httpTargetTree', httpTargetTree);
70Cypress.Commands.add('doneSaveRule', doneSaveRule);
71Cypress.Commands.add('httpTransalte', httpTransalte);