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

Fix/flaky tests #1168

Merged
merged 5 commits into from
Jun 5, 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 @@ -27,9 +27,9 @@ export default class DRepRegistrationPage {

// input fields
readonly nameInput = this.page.getByTestId("name-input");
readonly emailInput = this.page.locator('[data-testid="email-input"] input'); // BUG incorrect cannot interact with text input
readonly emailInput = this.page.getByTestId("email-input");
readonly bioInput = this.page.getByTestId("bio-input");
readonly linkInput = this.page.locator('[data-testid="link-input"] input'); // BUG incorrect cannot interact with text input
readonly linkInput = this.page.getByTestId("link-1-input");

constructor(private readonly page: Page) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default class GovernanceActionDetailsPage {
return downloadMetadata(download);
}

@withTxConfirmation
async reVote() {
await this.noVoteRadio.click();
await this.changeVoteBtn.click();
Expand Down
3 changes: 2 additions & 1 deletion tests/govtool-frontend/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ export default defineConfig({
{
name: "dRep setup",
testMatch: "**/dRep.setup.ts",
dependencies: environments.ci ? ["faucet setup"] : [],
},
{
name: "wallet bootstrap",
testMatch: "**/wallet.bootstrap.ts",
dependencies: !environments.ci ? ["faucet setup"] : [],
dependencies: environments.ci ? ["faucet setup"] : [],
},
{
name: "transaction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ test("2N. Should show DRep information on details page", async ({
const name = faker.person.firstName();
const email = faker.internet.email({ firstName: name });
const bio = faker.person.bio();
const links = [
faker.internet.url({ appendSlash: true }),
faker.internet.url(),
];
const links = [faker.internet.url()];

await dRepRegistrationPage.register({
name,
Expand Down Expand Up @@ -146,9 +143,7 @@ test("2I. Should check validity of DRep Id", async ({ page }) => {
await dRepDirectory.goto();

await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId);
await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toHaveText(
dRep01Wallet.dRepId
);
await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toBeVisible();

const wallet = await ShelleyWallet.generate();
const invalidDRepId = extractDRepFromWallet(wallet);
Expand All @@ -162,25 +157,7 @@ test("2J. Should search by DRep id", async ({ page }) => {
await dRepDirectory.goto();

await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId);
await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toHaveText(
dRep01Wallet.dRepId
);
});

test("2D. Should show delegation options in connected state", async ({
page,
}) => {
const dRepDirectoryPage = new DRepDirectoryPage(page);
await dRepDirectoryPage.goto();

// Verifying automatic delegation options
await dRepDirectoryPage.automaticDelegationOptionsDropdown.click();
await expect(dRepDirectoryPage.abstainDelegationCard).toBeVisible();
await expect(dRepDirectoryPage.signalNoConfidenceCard).toBeVisible();

expect(await dRepDirectoryPage.delegateBtns.count()).toBeGreaterThanOrEqual(
2
);
await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toBeVisible();
});

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 @@ -2,6 +2,7 @@ import { user01Wallet } from "@constants/staticWallets";
import { test } from "@fixtures/walletExtension";
import { setAllureEpic } from "@helpers/allure";
import { isMobile } from "@helpers/mobile";
import DRepDirectoryPage from "@pages/dRepDirectoryPage";
import { expect } from "@playwright/test";

test.use({ storageState: ".auth/user01.json", wallet: user01Wallet });
Expand All @@ -22,3 +23,19 @@ test("2B. Should access DRep Directory page", async ({ page }) => {
).toBeVisible();
}
});

test("2D. Should show delegation options in connected state", async ({
page,
}) => {
const dRepDirectoryPage = new DRepDirectoryPage(page);
await dRepDirectoryPage.goto();

// Verifying automatic delegation options
await dRepDirectoryPage.automaticDelegationOptionsDropdown.click();
await expect(dRepDirectoryPage.abstainDelegationCard).toBeVisible();
await expect(dRepDirectoryPage.signalNoConfidenceCard).toBeVisible();

expect(await dRepDirectoryPage.delegateBtns.count()).toBeGreaterThanOrEqual(
2
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test.describe("Delegate to others", () => {
await expect(
page.getByTestId(`${dRepId}-delegate-button')`)
).not.toBeVisible();

await expect(page.getByTestId(`${dRepId}-copy-id-button`)).toHaveCount(1, {
timeout: 20_000,
});
Expand Down Expand Up @@ -128,10 +129,8 @@ test.describe("Register DRep state", () => {
});
});

test("2E. Should register as Sole voter", async ({}, testInfo) => {
test("2E. Should register as Direct voter", async ({}, testInfo) => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);

const wallet = await walletManager.popWallet("registeredDRep");
const dRepId = wallet.dRepId;

await dRepPage.goto("/");
Expand All @@ -145,16 +144,18 @@ test.describe("Register DRep state", () => {
await dRepPage.getByTestId("confirm-modal-button").click();
await waitForTxConfirmation(dRepPage);

// Checks in dashboard
await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible();
await expect(
dRepPage.getByTestId("register-as-sole-voter-button")
).not.toBeVisible();

// Checks in dRep directory
await dRepPage.getByTestId("drep-directory-link").click();
await expect(dRepPage.getByText("Direct Voter")).toBeVisible();
await expect(dRepPage.getByTestId(`${dRepId}-copy-id-button`)).toHaveText(
dRepId
);
await expect(
dRepPage.getByTestId(`${dRepId}-copy-id-button`)
).toBeVisible();
});

test("2S. Should retire as a Direct Voter on delegating to another DRep", async ({}, testInfo) => {
Expand Down Expand Up @@ -226,10 +227,7 @@ test.describe("Multiple delegations", () => {
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 page.waitForTimeout(2_000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ test.describe("Temporary DReps", () => {
const dRepRegistrationPage = new DRepRegistrationPage(dRepPage);
await dRepRegistrationPage.goto();
await dRepRegistrationPage.register({ name: faker.person.firstName() });
dRepRegistrationPage.registrationSuccessModal
await dRepRegistrationPage.registrationSuccessModal
.getByTestId("confirm-modal-button")
.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,12 @@ test.describe("Temporary DReps", async () => {
const govActionDetailsPage = await govActionsPage.viewFirstProposal();
await govActionDetailsPage.vote(faker.lorem.sentence(200));

await dRepPage.waitForTimeout(5_000);

await govActionsPage.votedTab.click();
await govActionsPage.viewFirstVotedProposal();
expect(false, "No vote context displayed").toBe(true);
});

// test("4I. Should display the recent vote on same snapshot", async ({
// context,
// }, testInfo) => {
// test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut);

// const govActionsPage = new GovernanceActionsPage(dRepPage);
// await govActionsPage.goto();

// const govActionDetailsPage = await govActionsPage.viewFirstProposal();
// const urlList = dRepPage.url().split("/");
// const governanceActionId = urlList[urlList.length - 1];
// await govActionDetailsPage.vote();

// await govActionsPage.votedTab.click();

// await govActionsPage.searchInput.fill(governanceActionId);

// await dRepPage
// .getByTestId(`govaction-${governanceActionId}-change-your-vote`)
// .click();
// const votedActionDetailsPage = new GovernanceActionDetailsPage(dRepPage);
// await votedActionDetailsPage.noVoteRadio.click();
// await votedActionDetailsPage.changeVoteBtn.click();

// await govActionsPage.searchInput.fill(governanceActionId);

// await expect(dRepPage.getByTestId("my-vote").getByText("No")).toBeVisible();
// });
});

test.describe("Check vote count", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,27 @@ test.describe("Perform voting", () => {
test("5E. Should re-vote with new data on a already voted governance action", async ({}, testInfo) => {
test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut);

govActionDetailsPage.vote();
await waitForTxConfirmation(govActionDetailsPage.currentPage);
await govActionDetailsPage.vote();

const governanceActionsPage = new GovernanceActionsPage(
govActionDetailsPage.currentPage
);
await governanceActionsPage.goto();

await dRepPage.waitForTimeout(5_000);

await governanceActionsPage.votedTab.click();

await expect(
govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("Yes")
).toBeVisible();

govActionDetailsPage = await governanceActionsPage.viewFirstVotedProposal();
govActionDetailsPage.reVote();
await waitForTxConfirmation(govActionDetailsPage.currentPage);

await govActionDetailsPage.reVote();
await governanceActionsPage.votedTab.click();

await expect(
govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("No")
).toBeVisible({ timeout: 20_000 });
).toBeVisible();
});

test("5F. Should show notification of casted vote after vote", async ({}, testInfo) => {
Expand All @@ -183,14 +182,14 @@ test.describe("Perform voting", () => {
test("5I. Should view the vote details,when viewing governance action already voted by the DRep", async ({}, testInfo) => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);

govActionDetailsPage.vote();
await waitForTxConfirmation(govActionDetailsPage.currentPage);
await govActionDetailsPage.vote();

const governanceActionsPage = new GovernanceActionsPage(
govActionDetailsPage.currentPage
);
await governanceActionsPage.goto();

await dRepPage.waitForTimeout(5_000);

await governanceActionsPage.votedTab.click();
await expect(
govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("Yes")
Expand Down
2 changes: 1 addition & 1 deletion tests/govtool-frontend/playwright/tests/faucet.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ setup.beforeEach(async () => {

setup("Faucet setup", async () => {
const balance = await kuberService.getBalance(faucetWallet.address);
if (balance > 10000) return;
if (balance > 1_00_000) return;

const res = await loadAmountFromFaucet(faucetWallet.address);
await pollTransaction(res.txid);
Expand Down