summaryrefslogtreecommitdiffstats
path: root/public/cypress/integration/mocks/homePage-spec.ts
blob: 2889390a02d3b72d0c0ace1fe84612f86580df8d (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
export const buttonCreateMC = () => {
  return cy.get('button[data-tests-id="btn-create-mc"]');
};
export const buttonCreateMCSpan = () => {
  return cy.get('span[data-tests-id="btn-span-create-mc"]');
};

export const tableItems = () => {
  return cy.get('tr[data-tests-id="monitoringComponentTableItems"]');
};

export const tableHeaders = () => {
  return cy.get('tr[data-tests-id="monitoringComponentTableHeaders"]');
};
export const tableItemsDeleteButton = () => {
  return cy.get('button[data-tests-id="tableItemsButtonDelete"]');
};

export const tableItemsInfoButton = () => {
  return cy.get('button[data-tests-id="tableItemsButtonInfo"]');
};

export const popupGetDeleteBtn = () => {
  return cy.get('button[data-tests-id="btnDelete"]');
};

export const popupGetCancelBtn = () => {
  return cy.get('button[data-tests-id="btnCancel"]');
};

export const getMonitoringConfiguration = () => {
  return cy.get('div[data-tests-id="tableItemsMonitoringConfiguration"]');
};

export const doHoverOverFirstLine = () => {
  return tableItems()
    .first()
    .trigger('mouseover');
};

export const doHoverOverFirstLineMonitoringConfiguration = () => {
  tableItems()
    .first()
    .trigger('mouseover');
  return getMonitoringConfiguration();
};

const NUMBER_OF_ITEMS = 12;

const navigateButtonDisabled = () => {
  return buttonCreateMC()
    .should('be.visible')
    .and('be.disabled')
    .get('button[data-tests-id="btn-fab-create-mc"]')
    .should('be.visible')
    .and('be.disabled');
};

describe('Home Page - E2E test flow with mock', () => {
  describe('MC List empty', () => {
    beforeEach(() => {
      cy.getMCListEmpty();
      cy.homePage();
    });

    it("Shouldn't have create table with headers", () => {
      tableHeaders().should('not.be.visible');
    });
    it("Shouldn't have create table without items", () => {
      buttonCreateMC()
        .get('div[data-tests-id="new-monitoring-title"]')
        .should('contain', 'Monitoring');
    });
  });

  describe('Check Edit Save and Submit', () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePage();
      cy.getMC();
      cy.submitMonitoringComponent();
      cy.saveMonitoringComponent();
    });

    it('Edit VFCMT', () => {
      this.doHoverOverFirstLineMonitoringConfiguration()
        .first()
        .click({ force: true });
    });
  });

  describe('MC List', () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePage();
    });

    it('Should have create button on top of the screen', () => {
      buttonCreateMC().should('be.visible');
    });

    it('Should have create table with headers', () => {
      tableHeaders().should('be.visible');
    });
    it('Should have create table with items', () => {
      tableItems().should('have.length', NUMBER_OF_ITEMS);
    });
  });

  describe('MC List Edit Tests', () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePage();
    });
  });

  describe('MC List Delete Tests', () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePage();
      cy.deleteMonitoringComponent();
      cy.deleteMonitoringComponentWithBlueprint();
    });
    it('Mouse hover over item, delete is visible, info not visible', () => {
      doHoverOverFirstLine();
      tableItemsDeleteButton().should('be.visible');
      tableItemsInfoButton().should('not.be.visible');
    });
    it('Mouse hover over item, call delete and remove not submitted (call delete without blueprint api)', () => {
      tableItems().should('have.length', NUMBER_OF_ITEMS);
      doHoverOverFirstLine();
      tableItemsDeleteButton()
        .should('be.visible')
        .click({ force: true });
      popupGetDeleteBtn().click({ force: true });
      tableItems().should('have.length', NUMBER_OF_ITEMS - 1);
    });
    it('Mouse hover over item, call delete and remove submitted (call delete with blueprint api)', () => {
      tableItems()
        .should('have.length', NUMBER_OF_ITEMS)
        .last()
        .trigger('mouseover');
      tableItemsDeleteButton()
        .should('be.visible')
        .click({ force: true });
      popupGetDeleteBtn().click({ force: true });
      tableItems().should('have.length', NUMBER_OF_ITEMS - 1);
    });
    it('Mouse hover over item, call delete and cancelOperation', () => {
      tableItems().should('have.length', NUMBER_OF_ITEMS);
      doHoverOverFirstLine();
      tableItemsDeleteButton()
        .should('be.visible')
        .click({ force: true });
      popupGetCancelBtn().click({ force: true });
      tableItems().should('have.length', NUMBER_OF_ITEMS);
    });
  });

  describe('Show Info icon', () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePageCertified();
    });
    it('Mouse hover over item, delete is not visible, info visible', () => {
      doHoverOverFirstLine();
      tableItemsInfoButton().should('be.visible');
      tableItemsDeleteButton().should('not.be.visible');
    });
  });

  describe('Successfully Entry Home Page Monitoring Configuration', () => {
    beforeEach(() => {
      cy.getMCListEmpty();
      cy.homePage();
    });

    it('Buttons looks Assertion', () => {
      buttonCreateMC()
        .should('contain', 'Create New MC')
        .and('be.visible')
        .and('not.be.disabled');

      buttonCreateMCSpan()
        .should('contain', 'Add First MC')
        .and('be.visible')
        .and('not.be.disabled');
    });

    it('Buttons Functionality Assertion', () => {
      buttonCreateMC()
        .click()
        .get('div[data-tests-id="new-monitoring-title"]')
        .should('contain', 'Monitoring');
    });
  });

  describe('Not Auth Entry Home Page Monitoring Configuration', () => {
    it('Buttons disabled when user not owner', () => {
      cy.sdcIsOwnerFalse();
      navigateButtonDisabled();
    });

    it('Buttons disabled when user not checkout', () => {
      cy.sdcUserNotCheckout();
      navigateButtonDisabled();
    });
  });
});