Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add ability to search dReps by name #2401

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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