Skip to content

Commit 1811541

Browse files
Copilotrenemadsen
andcommitted
Add Cypress page object and test files for searchable lists migration
Co-authored-by: renemadsen <[email protected]>
1 parent c3b61ec commit 1811541

File tree

4 files changed

+654
-0
lines changed

4 files changed

+654
-0
lines changed
Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
import { Navbar } from './Navbar.page';
2+
3+
export class SearchableListsPage {
4+
private navbar = new Navbar();
5+
6+
// Navigation
7+
public goToEntitySearchPage() {
8+
this.navbar.goToEntitySearch();
9+
}
10+
11+
// Element selectors
12+
public createEntitySearchBtn() {
13+
return cy.get('#createEntitySearchBtn');
14+
}
15+
16+
public entitySearchSearchField() {
17+
return cy.get('#labelInput');
18+
}
19+
20+
public entitySearchCreateName() {
21+
return cy.get('#editName');
22+
}
23+
24+
public entitySearchCreateImportBtn() {
25+
return cy.get('#editEntitySearchImportBtn');
26+
}
27+
28+
public entitySearchCreateSingleItemBtn() {
29+
return cy.get('#addSingleEntitySelectableItem');
30+
}
31+
32+
public entitySearchCreateSingleItemEditBtn() {
33+
return cy.get('.entityItemEditBtn');
34+
}
35+
36+
public entitySearchCreateItemNameBox() {
37+
return cy.get('#entityItemEditNameBox');
38+
}
39+
40+
public entitySearchCreateItemSaveBtn() {
41+
return cy.get('#entityItemSaveBtn');
42+
}
43+
44+
public entitySearchCreateItemCancelBtn() {
45+
return cy.get('#entityItemCancelBtn');
46+
}
47+
48+
public entitySearchCreateImportItemTextArea() {
49+
return cy.get('#entityImportTextArea');
50+
}
51+
52+
public entitySearchCreateImportItemSaveBtn() {
53+
return cy.get('#entityImportSaveBtn');
54+
}
55+
56+
public entitySearchCreateImportItemCancelBtn() {
57+
return cy.get('#entityImportCancelBtn');
58+
}
59+
60+
public entitySearchCreateSaveBtn() {
61+
return cy.get('#entityCreateSaveBtn');
62+
}
63+
64+
public entitySearchCreateCancelBtn() {
65+
return cy.get('#entitySearchUpdateCancelBtn');
66+
}
67+
68+
public entitySearchEditBtn(index = 0) {
69+
return cy.get('#entitySearchUpdateBtn').eq(index);
70+
}
71+
72+
public entitySearchEditNameBox() {
73+
return cy.get('#editName');
74+
}
75+
76+
public entitySearchEditImportBtn() {
77+
return cy.get('#editEntitySearchImportBtn');
78+
}
79+
80+
public entitySearchEditSingleItemBtn() {
81+
return cy.get('#editEntitySearchCreateItem');
82+
}
83+
84+
public entitySearchItemEditBtn() {
85+
return cy.get('.entityItemEditBtn');
86+
}
87+
88+
public entitySearchItemDeleteBtn() {
89+
return cy.get('.entityItemDeleteBtn');
90+
}
91+
92+
public entitySearchEditItemNameBox() {
93+
return cy.get('#entityItemEditNameBox');
94+
}
95+
96+
public entitySearchEditItemSaveBtn() {
97+
return cy.get('#entityItemSaveBtn');
98+
}
99+
100+
public entitySearchEditItemCancelBtn() {
101+
return cy.get('#entityItemCancelBtn');
102+
}
103+
104+
public entitySearchEditImportItemTextArea() {
105+
return cy.get('#entityImportTextArea');
106+
}
107+
108+
public entitySearchEditImportItemSaveBtn() {
109+
return cy.get('#entityImportSaveBtn');
110+
}
111+
112+
public entitySearchEditImportItemCancelBtn() {
113+
return cy.get('#entityImportCancelBtn');
114+
}
115+
116+
public entitySearchEditSaveBtn() {
117+
return cy.get('#entityUpdateSaveBtn');
118+
}
119+
120+
public entitySearchEditCancelBtn() {
121+
return cy.get('#entitySearchUpdateCancelBtn');
122+
}
123+
124+
public entitySearchDeleteBtn() {
125+
return cy.get('#entitySearchDeleteBtn');
126+
}
127+
128+
public entitySearchDeleteDeleteBtn() {
129+
return cy.get('#entitySearchDeleteDeleteBtn');
130+
}
131+
132+
public entitySearchDeleteCancelBtn() {
133+
return cy.get('#entitySearchDeleteCancelBtn');
134+
}
135+
136+
public firstEntityItemName() {
137+
return cy.get('.createEntityItemName');
138+
}
139+
140+
// Row and item operations
141+
public rowNum() {
142+
return cy.get('tbody > tr').its('length');
143+
}
144+
145+
public items() {
146+
return cy.get('app-entity-search-edit ul li').its('length');
147+
}
148+
149+
public getFirstRowObject() {
150+
return cy.get('tbody > tr').first().then($row => {
151+
const name = $row.find('#entitySearchName').text();
152+
return {
153+
name: name,
154+
editBtn: cy.get('#entitySearchUpdateBtn').first(),
155+
deleteBtn: cy.get('#entitySearchDeleteBtn').first()
156+
};
157+
});
158+
}
159+
160+
// Create operations
161+
public createSearchableList_NoItem(name: string) {
162+
this.createEntitySearchBtn().click();
163+
cy.wait(250);
164+
this.entitySearchCreateName().should('be.visible').clear().type(name);
165+
cy.wait(250);
166+
this.entitySearchCreateSaveBtn().click();
167+
cy.wait(250);
168+
this.createEntitySearchBtn().should('be.visible', { timeout: 90000 });
169+
cy.wait(1500);
170+
}
171+
172+
public createSearchableList_OneItem(name: string, itemName: string) {
173+
this.createEntitySearchBtn().click();
174+
this.entitySearchCreateName().should('be.visible').clear().type(name);
175+
cy.wait(250);
176+
this.entitySearchCreateSingleItemBtn().click();
177+
cy.wait(250);
178+
this.entitySearchCreateSingleItemEditBtn().click();
179+
this.entitySearchCreateItemNameBox().clear().type(itemName);
180+
this.entitySearchCreateItemSaveBtn().click();
181+
cy.wait(250);
182+
this.entitySearchCreateSaveBtn().click();
183+
cy.wait(250);
184+
this.createEntitySearchBtn().should('be.visible', { timeout: 90000 });
185+
cy.wait(1500);
186+
}
187+
188+
public createSearchableList_MultipleItems(name: string, itemNames: string[]) {
189+
this.createEntitySearchBtn().click();
190+
cy.wait(250);
191+
this.entitySearchCreateName().should('be.visible').clear().type(name);
192+
cy.wait(250);
193+
this.entitySearchCreateImportBtn().click();
194+
cy.wait(250);
195+
this.entitySearchCreateImportItemTextArea().click().type(itemNames.join(''));
196+
cy.wait(250);
197+
this.entitySearchCreateImportItemSaveBtn().click();
198+
cy.wait(250);
199+
this.entitySearchCreateSaveBtn().click();
200+
cy.wait(250);
201+
this.createEntitySearchBtn().should('be.visible', { timeout: 90000 });
202+
cy.wait(1500);
203+
}
204+
205+
public createSearchableList_NoItem_Cancels(name: string) {
206+
this.createEntitySearchBtn().click();
207+
this.entitySearchCreateName().should('be.visible').clear().type(name);
208+
cy.wait(250);
209+
this.entitySearchCreateCancelBtn().click();
210+
this.createEntitySearchBtn().should('be.visible', { timeout: 90000 });
211+
cy.wait(250);
212+
}
213+
214+
public createSearchableList_OneItem_Cancels(name: string, itemName: string) {
215+
this.createEntitySearchBtn().click();
216+
cy.wait(250);
217+
this.entitySearchCreateName().should('be.visible').clear().type(name);
218+
this.entitySearchCreateSingleItemBtn().click();
219+
cy.wait(250);
220+
this.entitySearchCreateSingleItemEditBtn().click();
221+
cy.wait(250);
222+
this.entitySearchCreateItemNameBox().clear().type(itemName);
223+
cy.wait(250);
224+
this.entitySearchCreateItemSaveBtn().click();
225+
cy.wait(250);
226+
this.entitySearchCreateCancelBtn().click();
227+
cy.wait(250);
228+
this.createEntitySearchBtn().should('be.visible', { timeout: 90000 });
229+
cy.wait(1500);
230+
}
231+
232+
public createSearchableList_MultipleItems_Cancels(name: string, itemNames: string[]) {
233+
this.createEntitySearchBtn().click();
234+
cy.wait(250);
235+
this.entitySearchCreateName().should('be.visible').clear().type(name);
236+
cy.wait(250);
237+
this.entitySearchCreateImportBtn().click();
238+
cy.wait(250);
239+
this.entitySearchCreateImportItemTextArea().click().type(itemNames.join(''));
240+
cy.wait(250);
241+
this.entitySearchCreateImportItemSaveBtn().click();
242+
cy.wait(250);
243+
this.entitySearchCreateCancelBtn().click();
244+
cy.wait(250);
245+
this.createEntitySearchBtn().should('be.visible', { timeout: 90000 });
246+
}
247+
248+
// Edit operations
249+
public editSearchableListNameOnly(newName: string) {
250+
this.rowNum().then(count => {
251+
const index = count - 1;
252+
this.entitySearchEditBtn(index).click();
253+
cy.wait(250);
254+
this.entitySearchEditNameBox().should('be.visible').clear().type(newName);
255+
cy.wait(250);
256+
this.entitySearchEditSaveBtn().click();
257+
cy.wait(250);
258+
});
259+
}
260+
261+
public editSearchableListNameAndItem(newName: string, newItemName: string) {
262+
this.rowNum().then(count => {
263+
const index = count - 1;
264+
this.entitySearchEditBtn(index).click();
265+
cy.wait(250);
266+
this.entitySearchEditNameBox().should('be.visible').clear().type(newName);
267+
cy.wait(250);
268+
this.editItemName(newItemName);
269+
cy.wait(250);
270+
this.entitySearchEditSaveBtn().click();
271+
cy.wait(250);
272+
});
273+
}
274+
275+
public deleteItemFromList() {
276+
this.rowNum().then(count => {
277+
const index = count - 1;
278+
this.entitySearchEditBtn(index).click();
279+
cy.wait(250);
280+
this.entitySearchEditNameBox().should('be.visible');
281+
this.deleteItem();
282+
cy.wait(250);
283+
this.entitySearchEditSaveBtn().click();
284+
cy.wait(250);
285+
});
286+
}
287+
288+
// Delete operations
289+
public deleteList() {
290+
cy.get('#entitySearchDeleteBtn').first().click();
291+
this.entitySearchDeleteDeleteBtn().click();
292+
cy.wait(500);
293+
}
294+
295+
// Helper methods
296+
public editItemName(newItemName: string) {
297+
this.entitySearchItemEditBtn().click();
298+
this.entitySearchEditItemNameBox().clear().type(newItemName);
299+
cy.wait(250);
300+
this.entitySearchEditItemSaveBtn().click();
301+
}
302+
303+
public deleteItem() {
304+
this.entitySearchItemDeleteBtn().click();
305+
}
306+
307+
public cleanup() {
308+
cy.get('#entitySearchDeleteBtn').first().then($btn => {
309+
if ($btn.length > 0) {
310+
this.waitForSpinnerHide();
311+
cy.wrap($btn).click();
312+
this.waitForSpinnerHide();
313+
this.entitySearchDeleteDeleteBtn().click();
314+
this.waitForSpinnerHide();
315+
}
316+
});
317+
}
318+
319+
public waitForSpinnerHide() {
320+
cy.get('#spinner-animation', { timeout: 90000 }).should('not.exist');
321+
}
322+
}
323+
324+
const searchableListsPage = new SearchableListsPage();
325+
export default searchableListsPage;

0 commit comments

Comments
 (0)