Skip to content

Commit 4b9d272

Browse files
authored
Merge pull request #7162 from microting/copilot/migrate-searchable-lists-tests
Migrate Searchable Lists Tests from WDIO to Cypress
2 parents cb7bb83 + 0a011d5 commit 4b9d272

File tree

7 files changed

+686
-24
lines changed

7 files changed

+686
-24
lines changed

WDIO_TO_CYPRESS_MIGRATION.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This document tracks the migration of WebDriverIO (wdio) e2e tests to Cypress te
77
## Current Status
88

99
- **Total wdio tests**: 38
10-
- **Cypress tests implemented**: 39
11-
- **Tests remaining to migrate**: 11
10+
- **Cypress tests implemented**: 42
11+
- **Tests remaining to migrate**: 8
1212

1313
## Tests Already Migrated to Cypress ✓
1414

@@ -58,7 +58,12 @@ The following wdio tests have been successfully migrated to Cypress:
5858
- ✓ application-settings.login-page.spec.cy.ts (cypress/e2e/g/)
5959
- ✓ application-settings.site-header.spec.cy.ts (cypress/e2e/g/)
6060

61-
## Tests to Migrate (15 tests)
61+
### Searchable Lists
62+
- ✓ searchable-lists.add.spec.cy.ts (cypress/e2e/h/)
63+
- ✓ searchable-lists.delete.spec.cy.ts (cypress/e2e/h/)
64+
- ✓ searchable-lists.edit.spec.cy.ts (cypress/e2e/h/)
65+
66+
## Tests to Migrate (8 tests)
6267

6368
The following tests need to be migrated from wdio to Cypress. They are organized by functional area for easier sub-issue creation.
6469

@@ -226,16 +231,17 @@ Tests to migrate:
226231

227232
---
228233

229-
### 9. Searchable Lists (3 tests)
234+
### 9. Searchable Lists (3 tests)
230235

231236
**Category**: Searchable Lists Management
232237
**Priority**: Medium
233-
**Location**: e2e/Tests/searchable-lists/
238+
**Location**: e2e/Tests/searchable-lists/
239+
**Migrated to**: cypress/e2e/h/
234240

235-
Tests to migrate:
236-
- [ ] searchable-lists.add.spec.ts
237-
- [ ] searchable-lists.delete.spec.ts
238-
- [ ] searchable-lists.edit.spec.ts
241+
Tests migrated:
242+
- searchable-lists.add.spec.cy.ts
243+
- searchable-lists.delete.spec.cy.ts
244+
- searchable-lists.edit.spec.cy.ts
239245

240246
**Description**: Tests for managing searchable dropdown lists used in eForms.
241247

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

0 commit comments

Comments
 (0)