summaryrefslogtreecommitdiffstats
path: root/public/cypress/integration/e2e/e2eWithIntegration-spec.ts
blob: 949e96639f5b3ef99fbd018a3ca232d9e231307a (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const randomNodeName = () =>
  Math.random()
    .toString(36)
    .substr(2, 7);
const NODE_NAME = randomNodeName();
const serverGetDDLData = () => {
  return cy
    .server()
    .route(
      'GET',
      Cypress.env('backendUrl') + '/getResourcesByMonitoringTemplateCategory'
    )
    .as('templateAPi')
    .route('GET', Cypress.env('backendUrl') + '/service/**')
    .as('vfniListAPi');
};
const saveAndDoneHttp = () => {
  cy.server();
  cy
    .route({
      method: 'POST',
      url: Cypress.env('backendUrl') + '/rule-editor/rule/**/**/**/**'
    })
    .as('doneSaveCopyRule');
};
const createNewMC = () => {
  cy
    .get('input[data-tests-id="nameMc"]')
    .type(`Hello${NODE_NAME}`)
    .get('textarea[data-tests-id="descMc"]')
    .type('Hello Description')
    .get('select[data-tests-id="templateDdl"]')
    .then($els => {
      const opt = $els.find('option');
      const first = opt.get(1) as any;
      return $els.val(first.value);
    })
    .trigger('change')
    .get('select[data-tests-id="vfniDdl"]')
    .then($els => {
      const opt = $els.find('option');
      const first = opt.get(1) as any;
      return $els.val(first.value);
    })
    .trigger('change')
    .get('button[data-tests-id="createMonitoring"]')
    .not('[disabled]')
    .should('not.contain', 'Disabled');
  cy
    .server()
    .route({
      method: 'POST',
      url: Cypress.env('backendUrl') + '/createMC'
    })
    .as('newMC')
    .get('button[data-tests-id="createMonitoring"]')
    .click()
    .wait('@newMC');
};
import { buttonCreateMC } from '../mocks/homePage-spec';
import {
  selectVersionAndTypeAndAddFirstRule,
  fillRuleDescription,
  addCopyAction,
  editFirstRule
} from '../mocks/ruleEngine-spec';
describe('DCAED - forntend e2e and inagration test ', () => {
  // context(('home page'), () => {   it.only('should open env', () => {     cy
  // .visit('https://www.e-access.att.com/DevOps02/sdc1/portal#!/dashboard')
  // .get(':nth-child(2) > :nth-child(1) > [border="0"][width="100%"] >
  // :nth-child(1) > :nt' +           'h-child(1) > td > input') .type('ym903w')
  //     .get(':nth-child(3) > td > input') .type('Apple1qazxsw2')
  // .get('[border="0"][width="100%"] > :nth-child(1) > :nth-child(5) > td >
  // input')       .click()       .get('#srv_successok > input')       .click()
  //    .get(':nth-child(1) > .w-sdc-dashboard-card-new-content')
  // .trigger('mouseover') .get('button[data-tests-id="createServiceButton"]')
  //   .click() .get('input[data-tests-id="name"]')
  // .type(`DCAE_SRV_${NODE_NAME}`)
  // .get('select[data-tests-id="selectGeneralCategory"]') .select('Mobility')
  //   .get('textarea[data-tests-id="description"]') .type('bla')
  // .get('input[data-tests-id="projectCode"]') .type('att01')
  // .get('button[data-tests-id="create/save"]') .click()
  // .get('div[data-tests-id="CompositionLeftSideMenu"]') .click()   }); });

  context('Empty Monitoring Configuration list for service ', () => {
    it(' Loads ', () => {
      cy.homePage();
    });
  });

  context('Create new monitoring configuration', () => {
    beforeEach(() => {
      serverGetDDLData();
      cy.homePage();
      buttonCreateMC()
        .click()
        .wait(['@templateAPi', '@vfniListAPi']);
    });

    it('After api call success verify create button is disabled', () => {
      cy
        .get('button[data-tests-id="createMonitoring"]')
        .should('be.visible')
        .and('be.disabled');
    });

    // it('click on create mc - more then one tab should be visible', () => {
    // createNewMC();   cy     .get('ul[p-tabviewnav]')     .children()
    // .should($el => {       expect($el.length).to.be.greaterThan(1);     }); });
    // it('should enter rule engine in map tab and create new rule', () => {
    // createNewMC();   cy     .get('#ui-tabpanel-1-label')     .should('contain',
    // 'map')     .click();   selectVersionAndTypeAndAddFirstRule();
    // fillRuleDescription('newRule');   addCopyAction();   saveAndDoneHttp();
    // cy.get('button[data-tests-id="btnDone"]').click();   cy
    // .wait('@doneSaveCopyRule')     .get('div[data-tests-id="ruleElement"]')
    // .should('be.visible')     .then(function($lis) {
    // expect($lis).to.have.length(1);
    // expect($lis.eq(0)).to.contain('newRule');     });   editFirstRule();
    // fillRuleDescription('LiavRule');   saveAndDoneHttp();   cy
    // .get('button[data-tests-id="btnSave"]')     .click()
    // .wait('@doneSaveCopyRule')     .get('a[data-tests-id="btnBackRule"]')
    // .click()     .get('div[data-tests-id="ruleElement"]')
    // .should('be.visible')     .then(function($lis) {
    // expect($lis).to.have.length(1);
    // expect($lis.eq(0)).to.contain('LiavRule');     }); });
  });
});