Skip to content

Commit d7f5df9

Browse files
committed
fix: dRep poll vote/comment issue
fix: remove unnecessary temp dRep wallets and use static wallets for poll vote and comment test and use fixture to poll vote on new proposal
1 parent 0b80ed4 commit d7f5df9

File tree

2 files changed

+80
-74
lines changed

2 files changed

+80
-74
lines changed
Lines changed: 68 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,87 @@
1-
import { createTempDRepAuth } from "@datafactory/createAuth";
21
import { faker } from "@faker-js/faker";
3-
import { test } from "@fixtures/walletExtension";
2+
import { test } from "@fixtures/budgetProposal";
43
import { setAllureEpic } from "@helpers/allure";
5-
import { createNewPageWithWallet } from "@helpers/page";
64
import BudgetDiscussionDetailsPage from "@pages/budgetDiscussionDetailsPage";
5+
import { expect } from "@playwright/test";
6+
import { dRep01Wallet } from "@constants/staticWallets";
77
import BudgetDiscussionPage from "@pages/budgetDiscussionPage";
8-
import { expect, Page } from "@playwright/test";
9-
import walletManager from "lib/walletManager";
10-
import { valid as mockValid } from "@mock/index";
11-
import { StaticWallet } from "@types";
128

139
test.beforeEach(async () => {
1410
await setAllureEpic("11. Proposal Budget");
1511
});
1612

1713
test.describe("Budget proposal dRep behaviour", () => {
18-
let budgetDiscussionDetailsPage: BudgetDiscussionDetailsPage;
19-
let wallet: StaticWallet;
20-
test.beforeEach(async ({ browser, page }) => {
21-
wallet = await walletManager.popWallet("registeredDRep");
22-
23-
const tempDRepAuth = await createTempDRepAuth(page, wallet);
24-
25-
const dRepPage = await createNewPageWithWallet(browser, {
26-
storageState: tempDRepAuth,
27-
wallet,
28-
});
29-
const budgetDiscussionPage = new BudgetDiscussionPage(dRepPage);
30-
await budgetDiscussionPage.goto();
31-
await budgetDiscussionPage.verifyIdentityBtn.click();
32-
await budgetDiscussionPage.setUsername(mockValid.username());
33-
budgetDiscussionDetailsPage =
34-
await budgetDiscussionPage.viewFirstProposal();
35-
await expect(budgetDiscussionDetailsPage.pollVoteCard).toBeVisible({
36-
timeout: 60_000,
37-
});
14+
test.use({
15+
storageState: ".auth/dRep01.json",
16+
wallet: dRep01Wallet,
3817
});
3918

40-
test("11K. Should allow registered DRep to vote on a proposal", async () => {
41-
const pollVotes = ["Yes", "No"];
42-
const choice = faker.helpers.arrayElement(pollVotes);
43-
44-
await budgetDiscussionDetailsPage.voteOnPoll(choice);
19+
test.describe("Budget proposal voting", () => {
20+
let budgetDiscussionDetailsPage: BudgetDiscussionDetailsPage;
21+
test.beforeEach(async ({ page, proposalId }) => {
22+
budgetDiscussionDetailsPage = new BudgetDiscussionDetailsPage(page);
23+
await budgetDiscussionDetailsPage.goto(proposalId);
4524

46-
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
47-
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
48-
await expect(
49-
budgetDiscussionDetailsPage.currentPage.getByTestId(
50-
`poll-${choice.toLowerCase()}-count`
51-
)
52-
).toHaveText(`${choice}: (100%)`);
53-
// opposite of random choice vote
54-
const oppositeVote = pollVotes.filter((vote) => vote !== choice)[0];
55-
await expect(
56-
budgetDiscussionDetailsPage.currentPage.getByTestId(
57-
`poll-${oppositeVote.toLowerCase()}-count`
58-
)
59-
).toHaveText(`${oppositeVote}: (0%)`);
60-
});
61-
62-
test("11L. Should allow registered DRep to change vote on a proposal", async () => {
63-
const pollVotes = ["Yes", "No"];
64-
const choice = faker.helpers.arrayElement(pollVotes);
65-
66-
await budgetDiscussionDetailsPage.voteOnPoll(choice);
67-
await budgetDiscussionDetailsPage.changePollVote();
25+
await budgetDiscussionDetailsPage.verifyIdentityBtn.click();
26+
});
6827

69-
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
70-
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
28+
test("11K. Should allow registered DRep to vote on a proposal", async () => {
29+
const pollVotes = ["Yes", "No"];
30+
const choice = faker.helpers.arrayElement(pollVotes);
31+
32+
await budgetDiscussionDetailsPage.voteOnPoll(choice);
33+
34+
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
35+
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
36+
await expect(
37+
budgetDiscussionDetailsPage.currentPage.getByTestId(
38+
`poll-${choice.toLowerCase()}-count`
39+
)
40+
).toHaveText(`${choice}: (100%)`);
41+
// opposite of random choice vote
42+
const oppositeVote = pollVotes.filter((vote) => vote !== choice)[0];
43+
await expect(
44+
budgetDiscussionDetailsPage.currentPage.getByTestId(
45+
`poll-${oppositeVote.toLowerCase()}-count`
46+
)
47+
).toHaveText(`${oppositeVote}: (0%)`);
48+
});
7149

72-
// vote must be changed
73-
await expect(
74-
budgetDiscussionDetailsPage.currentPage.getByTestId(
75-
`poll-${choice.toLowerCase()}-count`
76-
)
77-
).toHaveText(`${choice}: (0%)`, { timeout: 60_000 });
78-
// opposite of random choice vote
79-
const oppositeVote = pollVotes.filter((vote) => vote !== choice)[0];
80-
await expect(
81-
budgetDiscussionDetailsPage.currentPage.getByTestId(
82-
`poll-${oppositeVote.toLowerCase()}-count`
83-
)
84-
).toHaveText(`${oppositeVote}: (100%)`);
50+
test("11L. Should allow registered DRep to change vote on a proposal", async () => {
51+
test.slow();
52+
const pollVotes = ["Yes", "No"];
53+
const choice = faker.helpers.arrayElement(pollVotes);
54+
55+
await budgetDiscussionDetailsPage.voteOnPoll(choice);
56+
await budgetDiscussionDetailsPage.changePollVote();
57+
58+
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
59+
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
60+
61+
// vote must be changed
62+
await expect(
63+
budgetDiscussionDetailsPage.currentPage.getByTestId(
64+
`poll-${choice.toLowerCase()}-count`
65+
)
66+
).toHaveText(`${choice}: (0%)`, { timeout: 60_000 });
67+
// opposite of random choice vote
68+
const oppositeVote = pollVotes.filter((vote) => vote !== choice)[0];
69+
await expect(
70+
budgetDiscussionDetailsPage.currentPage.getByTestId(
71+
`poll-${oppositeVote.toLowerCase()}-count`
72+
)
73+
).toHaveText(`${oppositeVote}: (100%)`);
74+
});
8575
});
8676

87-
test("11M. Should display DRep tag, name and ID when a registered DRep comments on a proposal", async () => {
77+
test("11M. Should display DRep tag, name and ID when a registered DRep comments on a proposal", async ({
78+
page,
79+
}) => {
8880
const comment = faker.lorem.paragraph(2);
81+
const budgetDiscussionPage = new BudgetDiscussionPage(page);
82+
await budgetDiscussionPage.goto();
83+
const budgetDiscussionDetailsPage =
84+
await budgetDiscussionPage.viewFirstProposal();
8985
await budgetDiscussionDetailsPage.addComment(comment);
9086

9187
await expect(
@@ -103,11 +99,11 @@ test.describe("Budget proposal dRep behaviour", () => {
10399
).toBeVisible();
104100

105101
await expect(dRepCommentedCard.getByTestId("given-name")).toHaveText(
106-
wallet.givenName
102+
dRep01Wallet.givenName
107103
);
108104

109105
await expect(dRepCommentedCard.getByTestId("drep-id")).toHaveText(
110-
wallet.dRepId
106+
dRep01Wallet.dRepId
111107
);
112108
});
113109
});

tests/govtool-frontend/playwright/tests/dRep.setup.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { functionWaitedAssert } from "@helpers/waitedLoop";
1414
import { StaticWallet } from "@types";
1515

1616
const REGISTER_DREP_WALLETS_COUNT = 6;
17-
const DREP_WALLETS_COUNT = 12;
17+
const DREP_WALLETS_COUNT = 9;
1818

1919
let dRepDeposit: number;
2020

@@ -41,7 +41,17 @@ setup("Register DRep of static wallets", async () => {
4141
try {
4242
// Submit metadata to obtain a URL and generate hash value.
4343
const metadataPromises = dRepWallets.map(async (dRepWallet) => {
44-
return { ...(await uploadMetadataAndGetJsonHash()), wallet: dRepWallet };
44+
const metadataResponse = await uploadMetadataAndGetJsonHash();
45+
const givenName = metadataResponse.givenName;
46+
const index = dRepWallets.indexOf(dRepWallet);
47+
dRepWallets[index] = {
48+
...dRepWallet,
49+
givenName,
50+
};
51+
return {
52+
...metadataResponse,
53+
wallet: dRepWallet,
54+
};
4555
});
4656

4757
const metadataAndDRepWallets = await Promise.all(metadataPromises);

0 commit comments

Comments
 (0)