blob: 35d2fa79c73525dae28ca19ff5ca5c51100f19e0 [file] [log] [blame]
Stone, Avi (as206k)9b2ceb32018-04-12 16:36:39 +03001declare namespace Cypress {
2 interface Chainable {
3 httpGetDDLData: typeof httpGetDDLData;
4 fillNewMcForm: typeof fillNewMcForm;
5 httpCreateNewMc: typeof httpCreateNewMc;
Stone, Avi (as206k)548c5a22018-06-03 13:12:12 +03006 httpCreateNewMcWithBooleanDDL: typeof httpCreateNewMcWithBooleanDDL;
Stone, Avi (as206k)9b2ceb32018-04-12 16:36:39 +03007 }
8}
9
10function httpGetDDLData(): void {
11 cy
12 .server()
13 .route({
14 method: 'GET',
15 url:
16 Cypress.env('backendUrl') +
17 '/service/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a',
18 response: 'fixture:serviceDdl'
19 })
20 .as('vfniListApi')
21 .route({
22 method: 'GET',
23 url:
24 Cypress.env('backendUrl') + '/getResourcesByMonitoringTemplateCategory',
25 response: [{ name: 'AviStone1234' }]
26 })
27 .as('templateAPi');
28}
29
30function fillNewMcForm() {
31 cy.get('input[data-tests-id="nameMc"]').type('new mc');
32 cy.get('textarea[data-tests-id="descMc"]').type('Hello Description');
33 cy.get('select[data-tests-id="templateDdl"]').select('AviStone1234');
34 cy.get('select[data-tests-id="vfniDdl"]').select('LiavSrv');
35}
36
37function httpCreateNewMc() {
38 cy.server();
39 cy
40 .route({
41 method: 'POST',
42 url: Cypress.env('backendUrl') + '/createMC',
43 response: 'fixture:createMcRes'
44 })
45 .as('newMC');
46}
47
Stone, Avi (as206k)548c5a22018-06-03 13:12:12 +030048function httpCreateNewMcWithBooleanDDL() {
49 cy.server();
50 cy
51 .route({
52 method: 'POST',
53 url: Cypress.env('backendUrl') + '/createMC',
54 response: 'fixture:createMcResWithBooleanDDL'
55 })
56 .as('newMCWithBooleanDDL');
57}
58
Stone, Avi (as206k)9b2ceb32018-04-12 16:36:39 +030059// Add cypress commands
60Cypress.Commands.add('httpGetDDLData', httpGetDDLData);
61Cypress.Commands.add('fillNewMcForm', fillNewMcForm);
62Cypress.Commands.add('httpCreateNewMc', httpCreateNewMc);
Stone, Avi (as206k)548c5a22018-06-03 13:12:12 +030063Cypress.Commands.add(
64 'httpCreateNewMcWithBooleanDDL',
65 httpCreateNewMcWithBooleanDDL
66);