blob: 2889390a02d3b72d0c0ace1fe84612f86580df8d [file] [log] [blame]
Stone, Avi (as206k)9b2ceb32018-04-12 16:36:39 +03001export const buttonCreateMC = () => {
2 return cy.get('button[data-tests-id="btn-create-mc"]');
3};
4export const buttonCreateMCSpan = () => {
5 return cy.get('span[data-tests-id="btn-span-create-mc"]');
6};
7
8export const tableItems = () => {
9 return cy.get('tr[data-tests-id="monitoringComponentTableItems"]');
10};
11
12export const tableHeaders = () => {
13 return cy.get('tr[data-tests-id="monitoringComponentTableHeaders"]');
14};
15export const tableItemsDeleteButton = () => {
16 return cy.get('button[data-tests-id="tableItemsButtonDelete"]');
17};
18
19export const tableItemsInfoButton = () => {
20 return cy.get('button[data-tests-id="tableItemsButtonInfo"]');
21};
22
23export const popupGetDeleteBtn = () => {
24 return cy.get('button[data-tests-id="btnDelete"]');
25};
26
27export const popupGetCancelBtn = () => {
28 return cy.get('button[data-tests-id="btnCancel"]');
29};
30
31export const getMonitoringConfiguration = () => {
32 return cy.get('div[data-tests-id="tableItemsMonitoringConfiguration"]');
33};
34
35export const doHoverOverFirstLine = () => {
36 return tableItems()
37 .first()
38 .trigger('mouseover');
39};
40
41export const doHoverOverFirstLineMonitoringConfiguration = () => {
42 tableItems()
43 .first()
44 .trigger('mouseover');
45 return getMonitoringConfiguration();
46};
47
48const NUMBER_OF_ITEMS = 12;
49
50const navigateButtonDisabled = () => {
51 return buttonCreateMC()
52 .should('be.visible')
53 .and('be.disabled')
54 .get('button[data-tests-id="btn-fab-create-mc"]')
55 .should('be.visible')
56 .and('be.disabled');
57};
58
59describe('Home Page - E2E test flow with mock', () => {
60 describe('MC List empty', () => {
61 beforeEach(() => {
62 cy.getMCListEmpty();
63 cy.homePage();
64 });
65
66 it("Shouldn't have create table with headers", () => {
67 tableHeaders().should('not.be.visible');
68 });
69 it("Shouldn't have create table without items", () => {
70 buttonCreateMC()
71 .get('div[data-tests-id="new-monitoring-title"]')
72 .should('contain', 'Monitoring');
73 });
74 });
75
76 describe('Check Edit Save and Submit', () => {
77 beforeEach(() => {
78 cy.getMCList();
79 cy.homePage();
80 cy.getMC();
81 cy.submitMonitoringComponent();
82 cy.saveMonitoringComponent();
83 });
84
85 it('Edit VFCMT', () => {
86 this.doHoverOverFirstLineMonitoringConfiguration()
87 .first()
88 .click({ force: true });
89 });
90 });
91
92 describe('MC List', () => {
93 beforeEach(() => {
94 cy.getMCList();
95 cy.homePage();
96 });
97
98 it('Should have create button on top of the screen', () => {
99 buttonCreateMC().should('be.visible');
100 });
101
102 it('Should have create table with headers', () => {
103 tableHeaders().should('be.visible');
104 });
105 it('Should have create table with items', () => {
106 tableItems().should('have.length', NUMBER_OF_ITEMS);
107 });
108 });
109
110 describe('MC List Edit Tests', () => {
111 beforeEach(() => {
112 cy.getMCList();
113 cy.homePage();
114 });
115 });
116
117 describe('MC List Delete Tests', () => {
118 beforeEach(() => {
119 cy.getMCList();
120 cy.homePage();
121 cy.deleteMonitoringComponent();
122 cy.deleteMonitoringComponentWithBlueprint();
123 });
124 it('Mouse hover over item, delete is visible, info not visible', () => {
125 doHoverOverFirstLine();
126 tableItemsDeleteButton().should('be.visible');
127 tableItemsInfoButton().should('not.be.visible');
128 });
129 it('Mouse hover over item, call delete and remove not submitted (call delete without blueprint api)', () => {
130 tableItems().should('have.length', NUMBER_OF_ITEMS);
131 doHoverOverFirstLine();
132 tableItemsDeleteButton()
133 .should('be.visible')
134 .click({ force: true });
135 popupGetDeleteBtn().click({ force: true });
136 tableItems().should('have.length', NUMBER_OF_ITEMS - 1);
137 });
138 it('Mouse hover over item, call delete and remove submitted (call delete with blueprint api)', () => {
139 tableItems()
140 .should('have.length', NUMBER_OF_ITEMS)
141 .last()
142 .trigger('mouseover');
143 tableItemsDeleteButton()
144 .should('be.visible')
145 .click({ force: true });
146 popupGetDeleteBtn().click({ force: true });
147 tableItems().should('have.length', NUMBER_OF_ITEMS - 1);
148 });
149 it('Mouse hover over item, call delete and cancelOperation', () => {
150 tableItems().should('have.length', NUMBER_OF_ITEMS);
151 doHoverOverFirstLine();
152 tableItemsDeleteButton()
153 .should('be.visible')
154 .click({ force: true });
155 popupGetCancelBtn().click({ force: true });
156 tableItems().should('have.length', NUMBER_OF_ITEMS);
157 });
158 });
159
160 describe('Show Info icon', () => {
161 beforeEach(() => {
162 cy.getMCList();
163 cy.homePageCertified();
164 });
165 it('Mouse hover over item, delete is not visible, info visible', () => {
166 doHoverOverFirstLine();
167 tableItemsInfoButton().should('be.visible');
168 tableItemsDeleteButton().should('not.be.visible');
169 });
170 });
171
172 describe('Successfully Entry Home Page Monitoring Configuration', () => {
173 beforeEach(() => {
174 cy.getMCListEmpty();
175 cy.homePage();
176 });
177
178 it('Buttons looks Assertion', () => {
179 buttonCreateMC()
180 .should('contain', 'Create New MC')
181 .and('be.visible')
182 .and('not.be.disabled');
183
184 buttonCreateMCSpan()
185 .should('contain', 'Add First MC')
186 .and('be.visible')
187 .and('not.be.disabled');
188 });
189
190 it('Buttons Functionality Assertion', () => {
191 buttonCreateMC()
192 .click()
193 .get('div[data-tests-id="new-monitoring-title"]')
194 .should('contain', 'Monitoring');
195 });
196 });
197
198 describe('Not Auth Entry Home Page Monitoring Configuration', () => {
199 it('Buttons disabled when user not owner', () => {
200 cy.sdcIsOwnerFalse();
201 navigateButtonDisabled();
202 });
203
204 it('Buttons disabled when user not checkout', () => {
205 cy.sdcUserNotCheckout();
206 navigateButtonDisabled();
207 });
208 });
209});