summaryrefslogtreecommitdiffstats
path: root/public/cypress/support/ruleEngineCommands.ts
blob: 2142e7f513fed027065a04abae6df23c68f4687f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
declare namespace Cypress {
  interface Chainable {
    emptyRuleEngine: typeof emptyRuleEngine;
    httpTargetTree: typeof httpTargetTree;
    doneSaveRule: typeof doneSaveRule;
    httpTransalte: typeof httpTransalte;
  }
}

function emptyRuleEngine(targetFiled) {
  cy.server();
  cy
    .route({
      method: 'GET',
      url: `${Cypress.env(
        'backendUrl'
      )}/rule-editor/rule/6d436c07-8006-4335-8c84-d65b4740f8d6/map/n.1517823219961.0/${targetFiled}`,
      response: {}
    })
    .as('serverRuleList')
    .route({
      method: 'GET',
      url: Cypress.env('backendUrl') + '/rule-editor/list-events-by-versions',
      response: 'fixture:list-events-by-version'
    })
    .as('serverEventsAndVersion');
}

function httpTargetTree() {
  cy.server();
  cy
    .route({
      method: 'GET',
      url:
        Cypress.env('backendUrl') + '/rule-editor/definition/4.1/syslogFields',
      response: 'fixture:syslogTargetTree'
    })
    .as('targetData');
}

function doneSaveRule() {
  cy.server();
  cy
    .route({
      method: 'POST',
      url:
        Cypress.env('backendUrl') +
        '/rule-editor/rule/6d436c07-8006-4335-8c84-d65b4740f8d6/map/n.1517823219961.0/Type1',
      response: 'fixture:doneSaveSimpleCopy'
    })
    .as('doneSaveCopyRule');
}

function httpTransalte() {
  cy.server();
  cy
    .route({
      method: 'GET',
      url:
        Cypress.env('backendUrl') +
        '/rule-editor/rule/translate/6d436c07-8006-4335-8c84-d65b4740f8d6/map/n.1517823219961.0/Type1',
      response: 'fixture:TranslateSimpleCopy'
    })
    .as('TranslateSimpleCopy');
}

// Add cypress commands
Cypress.Commands.add('emptyRuleEngine', emptyRuleEngine);
Cypress.Commands.add('httpTargetTree', httpTargetTree);
Cypress.Commands.add('doneSaveRule', doneSaveRule);
Cypress.Commands.add('httpTransalte', httpTransalte);