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

Tests/drep directory #1068

Merged
merged 12 commits into from
May 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ export const dRep02Wallet = staticWallets[2];

export const adaHolder01Wallet = staticWallets[3];
export const adaHolder02Wallet = staticWallets[4];
export const adaHolder03Wallet = staticWallets[6];
export const adaHolder04Wallet = staticWallets[7];

// Does not takes part in transaction
export const user01Wallet: StaticWallet = staticWallets[5];

export const adaHolderWallets = [adaHolder01Wallet, adaHolder02Wallet];
export const adaHolderWallets = [
adaHolder01Wallet,
adaHolder02Wallet,
adaHolder03Wallet,
adaHolder04Wallet,
];

export const userWallets = [user01Wallet];

export const dRepWallets = [dRep01Wallet];
export const dRepWallets = [dRep01Wallet, dRep02Wallet];
18 changes: 18 additions & 0 deletions tests/govtool-frontend/playwright/lib/pages/dRepDetailsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Page } from "@playwright/test";

export default class DRepDetailsPage {
readonly copyIdBtn = this.page.getByTestId("copy-drep-id-button");
readonly delegateBtn = this.page.getByTestId("delegate-button");
readonly shareBtn = this.page.getByTestId("share-button");

constructor(private readonly page: Page) {}

async goto(dRepId: string) {
await this.page.goto(`/connected/drep_directory/${dRepId}`);
}

async shareLink() {
await this.shareBtn.click();
await this.page.getByTestId("copy-link-from-share-button").click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class DRepDirectoryPage {
); // BUG: testId -> abstain-delegation-card

readonly delegationErrorModal = this.page.getByTestId(
"delegation-transaction-error-modal"
"delegate-transaction-error-modal"
);

readonly delegateBtns = this.page.locator(
Expand Down
2 changes: 1 addition & 1 deletion tests/govtool-frontend/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"allure:serve": "npx allure serve",
"test": "npx playwright test",
"format": "prettier . --write",
"generate-wallets": "ts-node ./generate_wallets.ts 6"
"generate-wallets": "ts-node ./generate_wallets.ts 8"
},
"dependencies": {
"@cardanoapi/cardano-test-wallet": "^1.1.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import environments from "@constants/environments";
import { dRep01Wallet } from "@constants/staticWallets";
import { dRep01Wallet, user01Wallet } from "@constants/staticWallets";
import { createTempDRepAuth } from "@datafactory/createAuth";
import { faker } from "@faker-js/faker";
import { test } from "@fixtures/walletExtension";
Expand All @@ -9,6 +9,7 @@ import { isMobile, openDrawer } from "@helpers/mobile";
import { createNewPageWithWallet } from "@helpers/page";
import extractDRepFromWallet from "@helpers/shellyWallet";
import { transferAdaForWallet } from "@helpers/transaction";
import DRepDetailsPage from "@pages/dRepDetailsPage";
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
import DRepRegistrationPage from "@pages/dRepRegistrationPage";
import { expect } from "@playwright/test";
Expand Down Expand Up @@ -102,3 +103,50 @@ test("2N. Should show DRep information on details page", async ({
}
await expect(dRepPage.getByText(bio, { exact: true })).toBeVisible();
});

test("2P. Should enable sharing of DRep details", async ({ page, context }) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"]);

const dRepDetailsPage = new DRepDetailsPage(page);
await dRepDetailsPage.goto(dRep01Wallet.dRepId);

await dRepDetailsPage.shareLink();
await expect(page.getByText("Copied to clipboard")).toBeVisible();

const copiedText = await page.evaluate(() => navigator.clipboard.readText());
expect(copiedText).toEqual(
`${environments.frontendUrl}/drep_directory/${dRep01Wallet.dRepId}`
);
});

test("2Q. Should include DRep status and voting power on the DRep card", async ({
page,
}) => {
test.skip(); // Cannot access dRep card

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

const dRepCard = dRepDirectory.getDRepCard(dRep01Wallet.dRepId);
await expect(dRepCard).toHaveText("20");
});

test.describe("Insufficient funds", () => {
test.use({ storageState: ".auth/user01.json", wallet: user01Wallet });

test("2T. Should show warning message on delegation when insufficient funds", async ({
page,
}) => {
const dRepDirectoryPage = new DRepDirectoryPage(page);
await dRepDirectoryPage.goto();

await dRepDirectoryPage.searchInput.fill(dRep01Wallet.dRepId);
const delegateBtn = page.getByTestId(
`${dRep01Wallet.dRepId}-delegate-button`
);
await expect(delegateBtn).toBeVisible();
await page.getByTestId(`${dRep01Wallet.dRepId}-delegate-button`).click();

await expect(dRepDirectoryPage.delegationErrorModal).toBeVisible();
});
});
Loading