Skip to content

Commit af1ca81

Browse files
authored
Merge pull request #2401 from IntersectMBO/tests/dRep-search-by-name
test: add ability to search dReps by name
2 parents 20ebc9c + ebaebc7 commit af1ca81

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

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

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ test("2N. Should show DRep information on details page", async ({
8686

8787
await dRepRegistrationPage.confirmBtn.click();
8888

89+
// Add an assertion to prevent clicking on "View Your dRep Details".
90+
await expect(
91+
dRepPage.getByTestId("dRep-id-display-card-dashboard")
92+
).toContainText(wallet.dRepId, { timeout: 10_000 });
8993
await dRepPage.getByTestId("view-drep-details-button").click();
9094

9195
// Verification
@@ -189,12 +193,47 @@ test("2I. Should check validity of DRep Id", async ({ page }) => {
189193
await expect(dRepDirectory.getDRepCard(invalidDRepId)).not.toBeVisible();
190194
});
191195

192-
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+
193221
const dRepDirectory = new DRepDirectoryPage(page);
194222
await dRepDirectory.goto();
195223

224+
await responsePromise;
225+
226+
// search by dRep Id
196227
await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId);
197228
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+
}
198237
});
199238

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

tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test.describe("Logged in DReps", () => {
3232

3333
await expect(
3434
page.getByTestId("dRep-id-display-card-dashboard")
35-
).toContainText(dRep01Wallet.dRepId);
35+
).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 });
3636

3737
const governanceActionsPage = new GovernanceActionsPage(page);
3838

@@ -53,6 +53,11 @@ test.describe("Logged in DReps", () => {
5353

5454
await page.goto("/");
5555

56+
// Add an assertion to prevent clicking on "View Your dRep Details".
57+
await expect(
58+
page.getByTestId("dRep-id-display-card-dashboard")
59+
).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 });
60+
5661
await page.getByTestId("view-drep-details-button").click();
5762
await page.getByTestId("edit-drep-data-button").click();
5863
const editDRepPage = new DRepRegistrationPage(page);

0 commit comments

Comments
 (0)