Skip to content

Commit ebaebc7

Browse files
committed
test: add ability to search dReps by name
1 parent 81f8378 commit ebaebc7

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,47 @@ test("2I. Should check validity of DRep Id", async ({ page }) => {
193193
await expect(dRepDirectory.getDRepCard(invalidDRepId)).not.toBeVisible();
194194
});
195195

196-
test("2J. Should search by DRep id", async ({ page }) => {
196+
test("2J. Should search by DRep id and DRep givenname", async ({ page }) => {
197+
let dRepGivenName = "test";
198+
199+
await page.route(
200+
"**/drep/list?page=0&pageSize=10&sort=Random",
201+
async (route) => {
202+
const response = await route.fetch();
203+
const json = await response.json();
204+
const elements = json["elements"].filter(
205+
(element) => element["givenName"] != null
206+
);
207+
dRepGivenName =
208+
elements[Math.floor(Math.random() * elements.length)]["givenName"];
209+
await route.fulfill({
210+
status: 200,
211+
contentType: "application/json",
212+
body: JSON.stringify(json),
213+
});
214+
}
215+
);
216+
217+
const responsePromise = page.waitForResponse(
218+
"**/drep/list?page=0&pageSize=10&sort=Random"
219+
);
220+
197221
const dRepDirectory = new DRepDirectoryPage(page);
198222
await dRepDirectory.goto();
199223

224+
await responsePromise;
225+
226+
// search by dRep Id
200227
await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId);
201228
await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toBeVisible();
229+
230+
// search by dRep givenname
231+
await dRepDirectory.searchInput.fill(dRepGivenName);
232+
const searchDRepCards = await dRepDirectory.getAllListedDReps();
233+
234+
for (const dRepCard of searchDRepCards) {
235+
expect((await dRepCard.innerText()).includes(dRepGivenName));
236+
}
202237
});
203238

204239
test("2M. Should access dRep directory page on disconnected state", async ({

0 commit comments

Comments
 (0)