Skip to content

Commit

Permalink
Merge pull request #2401 from IntersectMBO/tests/dRep-search-by-name
Browse files Browse the repository at this point in the history
test: add ability to search dReps by name
  • Loading branch information
kneerose authored Nov 22, 2024
2 parents 20ebc9c + ebaebc7 commit af1ca81
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ test("2N. Should show DRep information on details page", async ({

await dRepRegistrationPage.confirmBtn.click();

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

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

test("2J. Should search by DRep id", async ({ page }) => {
test("2J. Should search by DRep id and DRep givenname", async ({ page }) => {
let dRepGivenName = "test";

await page.route(
"**/drep/list?page=0&pageSize=10&sort=Random",
async (route) => {
const response = await route.fetch();
const json = await response.json();
const elements = json["elements"].filter(
(element) => element["givenName"] != null
);
dRepGivenName =
elements[Math.floor(Math.random() * elements.length)]["givenName"];
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(json),
});
}
);

const responsePromise = page.waitForResponse(
"**/drep/list?page=0&pageSize=10&sort=Random"
);

const dRepDirectory = new DRepDirectoryPage(page);
await dRepDirectory.goto();

await responsePromise;

// search by dRep Id
await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId);
await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toBeVisible();

// search by dRep givenname
await dRepDirectory.searchInput.fill(dRepGivenName);
const searchDRepCards = await dRepDirectory.getAllListedDReps();

for (const dRepCard of searchDRepCards) {
expect((await dRepCard.innerText()).includes(dRepGivenName));
}
});

test("2M. Should access dRep directory page on disconnected state", async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test.describe("Logged in DReps", () => {

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

const governanceActionsPage = new GovernanceActionsPage(page);

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

await page.goto("/");

// Add an assertion to prevent clicking on "View Your dRep Details".
await expect(
page.getByTestId("dRep-id-display-card-dashboard")
).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 });

await page.getByTestId("view-drep-details-button").click();
await page.getByTestId("edit-drep-data-button").click();
const editDRepPage = new DRepRegistrationPage(page);
Expand Down

0 comments on commit af1ca81

Please sign in to comment.