Skip to content

Commit c99bc8c

Browse files
authored
Merge pull request #2390 from IntersectMBO/bugfix/vote-ada-format
Update governance action vote ada format
2 parents f110a6b + bc67776 commit c99bc8c

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

tests/govtool-frontend/playwright/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ allure-report/
1515
.logs/
1616
lib/_mock/registerDRepWallets.json
1717
lib/_mock/registeredDRepWallets.json
18+
lib/_mock/proposalSubmissionWallets.json
19+
lib/_mock/registerDRepCopyWallets.json
20+
lib/_mock/registeredDRepCopyWallets.json
1821
lib/_mock/wallets.json
1922
lib/_mock/proposals.json
2023
./lock_logs.txt
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const LOVELACE = 1000000;
2+
3+
export const correctVoteAdaFormat = (
4+
lovelace: number | undefined,
5+
locale: string | undefined = undefined
6+
) => {
7+
if (lovelace) {
8+
const ada = lovelace / LOVELACE;
9+
return ada.toLocaleString(locale, {
10+
minimumFractionDigits: 3,
11+
maximumFractionDigits: 3,
12+
});
13+
}
14+
return "0,000";
15+
};

tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from "@types";
2121
import walletManager from "lib/walletManager";
2222
import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage";
23+
import { correctVoteAdaFormat } from "@helpers/adaFormat";
2324

2425
test.beforeEach(async () => {
2526
await setAllureEpic("4. Proposal visibility");
@@ -77,7 +78,7 @@ test.describe("Logged in DRep", () => {
7778
}) => {
7879
for (let i = 0; i < 100; i++) {
7980
const invalidUrl = mockInvalid.url(false);
80-
await govActionDetailsPage.metadataUrlInput.fill(invalidUrl);
81+
await govActionDetailsPage.metadataUrlInput.fill(invalidUrl);
8182
if (invalidUrl.length <= 128) {
8283
await expect(page.getByTestId("invalid-url-error")).toBeVisible();
8384
} else {
@@ -161,24 +162,24 @@ test.describe("Check vote count", () => {
161162

162163
// check dRep votes
163164
await expect(govActionDetailsPage.dRepYesVotes).toHaveText(
164-
`₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}`
165+
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepYesVotes)}`
165166
);
166167
await expect(govActionDetailsPage.dRepAbstainVotes).toHaveText(
167-
`₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}`
168+
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepAbstainVotes)}`
168169
);
169170
await expect(govActionDetailsPage.dRepNoVotes).toHaveText(
170-
`₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}`
171+
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepNoVotes)}`
171172
);
172173

173174
// check sPos votes
174175
await expect(govActionDetailsPage.sPosYesVotes).toHaveText(
175-
`₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}`
176+
`₳ ${correctVoteAdaFormat(proposalToCheck.poolYesVotes)}`
176177
);
177178
await expect(govActionDetailsPage.sPosAbstainVotes).toHaveText(
178-
`₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}`
179+
`₳ ${correctVoteAdaFormat(proposalToCheck.poolAbstainVotes)}`
179180
);
180181
await expect(govActionDetailsPage.sPosNoVotes).toHaveText(
181-
`₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}`
182+
`₳ ${correctVoteAdaFormat(proposalToCheck.poolNoVotes)}`
182183
);
183184

184185
// check ccCommittee votes

tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { correctVoteAdaFormat } from "@helpers/adaFormat";
12
import { setAllureEpic } from "@helpers/allure";
2-
import { lovelaceToAda, skipIfNotHardFork } from "@helpers/cardano";
3+
import { skipIfNotHardFork } from "@helpers/cardano";
34
import GovernanceActionsPage from "@pages/governanceActionsPage";
45
import { expect, test } from "@playwright/test";
56
import { GrovernanceActionType, IProposal } from "@types";
@@ -57,24 +58,24 @@ test("4K. Should display correct vote counts on governance details page for disc
5758

5859
// check dRep votes
5960
await expect(govActionDetailsPage.dRepYesVotes).toHaveText(
60-
`₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}`
61+
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepYesVotes)}`
6162
);
6263
await expect(govActionDetailsPage.dRepAbstainVotes).toHaveText(
63-
`₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}`
64+
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepAbstainVotes)}`
6465
);
6566
await expect(govActionDetailsPage.dRepNoVotes).toHaveText(
66-
`₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}`
67+
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepNoVotes)}`
6768
);
6869

6970
// check sPos votes
7071
await expect(govActionDetailsPage.sPosYesVotes).toHaveText(
71-
`₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}`
72+
`₳ ${correctVoteAdaFormat(proposalToCheck.poolYesVotes)}`
7273
);
7374
await expect(govActionDetailsPage.sPosAbstainVotes).toHaveText(
74-
`₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}`
75+
`₳ ${correctVoteAdaFormat(proposalToCheck.poolAbstainVotes)}`
7576
);
7677
await expect(govActionDetailsPage.sPosNoVotes).toHaveText(
77-
`₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}`
78+
`₳ ${correctVoteAdaFormat(proposalToCheck.poolNoVotes)}`
7879
);
7980

8081
// check ccCommittee votes

0 commit comments

Comments
 (0)