Skip to content
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
@@ -1,6 +1,6 @@
import environments from "@constants/environments";
import { downloadMetadata } from "@helpers/metadata";
import { Download, Page, Response } from "@playwright/test";
import { Download, expect, Page, Response } from "@playwright/test";
import metadataBucketService from "@services/metadataBucketService";
import { IProposal } from "@types";
import { withTxConfirmation } from "lib/transaction.decorator";
Expand Down Expand Up @@ -76,8 +76,10 @@ export default class GovernanceActionDetailsPage {
}

@withTxConfirmation
async vote(context?: string) {
await this.yesVoteRadio.click();
async vote(context?: string, isAlreadyVoted: boolean = false) {
if (!isAlreadyVoted) {
await this.yesVoteRadio.click();
}

if (context) {
await this.contextBtn.click();
Expand All @@ -98,6 +100,12 @@ export default class GovernanceActionDetailsPage {
await this.page.getByTestId("go-to-vote-modal-button").click();
}

const isVoteButtonEnabled = await this.voteBtn.isEnabled();

await expect(this.voteBtn, {
message: !isVoteButtonEnabled && "Vote button is not enabled",
}).toBeEnabled({ timeout: 60_000 });

await this.voteBtn.click();
}

Expand Down Expand Up @@ -154,6 +162,6 @@ export default class GovernanceActionDetailsPage {
@withTxConfirmation
async reVote() {
await this.noVoteRadio.click();
await this.voteBtn.click();
await this.changeVoteBtn.click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default class GovernanceActionsPage {
await this.page.waitForTimeout(2_000); // Waits to ensure the alert-success popup does not interfere
}

get currentPage(): Page {
return this.page;
}

async viewProposal(
proposal: IProposal
): Promise<GovernanceActionDetailsPage> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ test.describe("Temporary DReps", async () => {
});

test("4J. Should include metadata anchor in the vote transaction", async ({}, testInfo) => {
test.skip(); // Skipped: Vote context is not displayed in UI to validate

test.setTimeout(testInfo.timeout + environments.txTimeOut);

const govActionsPage = new GovernanceActionsPage(dRepPage);
Expand All @@ -130,6 +128,8 @@ test.describe("Temporary DReps", async () => {

await govActionsPage.votedTab.click();
await govActionsPage.viewFirstVotedProposal();

// Vote context is not displayed in UI to validate
expect(false, "No vote context displayed").toBe(true);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ test.describe("Proposal checks", () => {

test.describe("Perform voting", () => {
let govActionDetailsPage: GovernanceActionDetailsPage;
let dRepPage: Page;

test.beforeEach(async ({ page, browser }) => {
test.slow(); // Due to queue in pop wallets
Expand All @@ -145,7 +144,7 @@ test.describe("Perform voting", () => {

const tempDRepAuth = await createTempDRepAuth(page, wallet);

dRepPage = await createNewPageWithWallet(browser, {
const dRepPage = await createNewPageWithWallet(browser, {
storageState: tempDRepAuth,
wallet,
enableStakeSigning: true,
Expand All @@ -166,7 +165,7 @@ test.describe("Perform voting", () => {
: await govActionsPage.viewFirstProposal();
});

test("5E. Should re-vote with new data on a already voted governance action", async ({}, testInfo) => {
test("5E. Should re-vote with change vote on an already voted governance action", async ({}, testInfo) => {
test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut);

await govActionDetailsPage.vote();
Expand All @@ -175,7 +174,7 @@ test.describe("Perform voting", () => {
govActionDetailsPage.currentPage
);

await dRepPage.waitForTimeout(5_000);
await governanceActionsPage.currentPage.reload();

await governanceActionsPage.votedTab.click();

Expand All @@ -190,7 +189,7 @@ test.describe("Perform voting", () => {
govActionDetailsPage = await governanceActionsPage.viewFirstVotedProposal();
await govActionDetailsPage.reVote();

await dRepPage.reload();
await govActionDetailsPage.currentPage.reload();

await governanceActionsPage.votedTab.click();

Expand Down Expand Up @@ -224,6 +223,56 @@ test.describe("Perform voting", () => {
});
});

test("5L. Should update context on an already voted governance action without changing the vote", async ({}, testInfo) => {
test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut);

await govActionDetailsPage.vote();

const governanceActionsPage = new GovernanceActionsPage(
govActionDetailsPage.currentPage
);

await governanceActionsPage.currentPage.reload();

await governanceActionsPage.votedTab.click();

await govActionDetailsPage.currentPage.evaluate(() =>
window.scrollTo(0, 500)
);

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

govActionDetailsPage = await governanceActionsPage.viewFirstVotedProposal();
await govActionDetailsPage.vote(faker.lorem.sentence(200), true);

await govActionDetailsPage.currentPage.reload();

await governanceActionsPage.votedTab.click();

const isYesVoteVisible = await govActionDetailsPage.currentPage
.getByTestId("my-vote")
.getByText("Yes")
.isVisible();

const textContent = await govActionDetailsPage.currentPage
.getByTestId("my-vote")
.textContent();

await govActionDetailsPage.currentPage.evaluate(() =>
window.scrollTo(0, 500)
);
await expect(
govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("No"),
{
message:
!isYesVoteVisible &&
`"Yes" vote not visible, current vote status: ${textContent.match(/My Vote:(Yes|No)/)[1]}`,
}
).toBeVisible({ timeout: 60_000 });
});

test("5I. Should view the vote details,when viewing governance action already voted by the DRep", async ({}, testInfo) => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);

Expand All @@ -233,7 +282,7 @@ test.describe("Perform voting", () => {
govActionDetailsPage.currentPage
);

await dRepPage.waitForTimeout(5_000);
await governanceActionsPage.currentPage.waitForTimeout(5_000);

await governanceActionsPage.votedTab.click();
await expect(
Expand Down
2 changes: 1 addition & 1 deletion tests/govtool-frontend/playwright/tests/dRep.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import walletManager from "lib/walletManager";
import { functionWaitedAssert } from "@helpers/waitedLoop";

const REGISTER_DREP_WALLETS_COUNT = 6;
const DREP_WALLETS_COUNT = 9;
const DREP_WALLETS_COUNT = 10;

let dRepDeposit: number;

Expand Down