summaryrefslogtreecommitdiffstats
path: root/cypress-docker/test/src/cypress/integration/mocks/newApp/homePage-spec.js
blob: ee2d5129feb2aab4b87c13413071af4e8d6a5f58 (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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
export const buttonCreateMC = () => {
  return cy.get('button[data-tests-id="btn-create-mc"]');
};
export const buttonCreateMCSpan = () => {
  return cy.get('[data-tests-id="btn-span-create-mc"]');
};

export const tableItems = () => {
  return cy.get("datatable-row-wrapper");
};

export const monitoringComponentTable = () => {
  return cy.get('ngx-datatable[data-tests-id="monitoringComponentTable"]');
};
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="editMC"]');
};

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

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

const NUMBER_OF_ITEMS = 9;

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", () => {
      monitoringComponentTable().should("not.be.visible");
    });
    it("Shouldn't have create table with 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 icon visablity", () => {
      doHoverOverFirstLine();
      cy.get('[data-tests-id="editMC"').should("be.visible");
    });
  });

  describe("Revert Mc table item", () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePage();
      cy.getMC();
      cy.submitMonitoringComponent();
      cy.saveMonitoringComponent();
    });

    it("should not see revert icon on version that is lower then 1.x", () => {
      tableItems()
        .first()
        .trigger("mouseover");
      cy.get('[data-tests-id="revertMC"').should("not.be.visible");
    });

    it("should get revert icon on version that is above then 1.x", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy.get('[data-tests-id="revertMC"]').should("be.visible");
    });
    it("should get revert open model", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy
        .get('[data-tests-id="revertMC"]')
        .should("be.visible")
        .click({ force: true })
        .get('[data-tests-id="revert-dialog-title"]')
        .should("contain", "Are you sure you want to revert?");
    });

    it("should get revert open model clicking on cancel should close popup", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy
        .get('[data-tests-id="revertMC"]')
        .should("be.visible")
        .click({ force: true })
        .get('[data-tests-id="revert-cancel"]')
        .click()
        .get('[data-tests-id="revert-dialog-title"]')
        .should("not.be.visible");
    });
  });

  describe("View only", () => {
    beforeEach(() => {
      cy.getMCList();
      cy.homePage();
      cy.getMC();
      cy.submitMonitoringComponent();
      cy.saveMonitoringComponent();
    });

    it("should not see view Submitted icon in 0.x version", () => {
      tableItems()
        .first()
        .click()
        .trigger("mouseover");
      cy.get('[data-tests-id="viewSubmitted"]').should("not.be.visible");
    });
    it("should see view Submitted icon in 1.x version", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy.get('[data-tests-id="viewSubmitted"]').should("be.visible");
    });
    it("should see view Submitted status in mc data page", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy
        .get('[data-tests-id="viewSubmitted"]')
        .should("be.visible")
        .click()
        .get('[data-tests-id="viewOnlyLabel"]')
        .should("contain", "view only");
    });
    it("save and submit buttons need to be disabled on view only mode", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy
        .get('[data-tests-id="viewSubmitted"]')
        .should("be.visible")
        .click()
        .get('[data-tests-id="save-btn"]')
        .should("be.disabled")
        .get('[data-tests-id="submit-btn"]')
        .should("be.disabled");
    });
    it("setting inputs need to be disabled on view only mode", () => {
      tableItems()
        .last()
        .click()
        .trigger("mouseover");
      cy
        .get('[data-tests-id="viewSubmitted"]')
        .should("be.visible")
        .click()
        .get("#ui-tabpanel-1-label")
        .should("be.visible")
        .click()
        .get('[data-tests-id="setting-gear"]')
        .first()
        .click()
        .get(".field-text")
        .first()
        .should("be.disabled");
    });
  });

  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", () => {
      monitoringComponentTable().should("be.visible");
    });
    it("Should have create table with items", () => {
      tableItems().should("have.length", NUMBER_OF_ITEMS);
    });
  });

  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 bluepr" +
        "int 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.httpGetDDLData();
      cy.getMCListEmpty();
      cy.homePage();
    });

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

      cy
        .get('[data-tests-id="btn-span-create-mc"]')
        .should("contain", "Add First MC")
        .and("be.visible")
        .and("not.be.disabled");
    });

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

  describe("Not Auth Entry Home Page Monitoring Configuration", () => {
    beforeEach(() => {
      cy.httpGetDDLData();
      cy.getMCListEmpty();
    });

    it("Buttons disabled when user not owner", () => {
      cy.sdcIsOwnerFalse();
      navigateButtonDisabled();
    });

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