Skip to content

Commit

Permalink
Merge pull request #2390 from IntersectMBO/bugfix/vote-ada-format
Browse files Browse the repository at this point in the history
Update governance action vote ada format
  • Loading branch information
kneerose authored Nov 19, 2024
2 parents f110a6b + bc67776 commit c99bc8c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ allure-report/
.logs/
lib/_mock/registerDRepWallets.json
lib/_mock/registeredDRepWallets.json
lib/_mock/proposalSubmissionWallets.json
lib/_mock/registerDRepCopyWallets.json
lib/_mock/registeredDRepCopyWallets.json
lib/_mock/wallets.json
lib/_mock/proposals.json
./lock_logs.txt
15 changes: 15 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/adaFormat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const LOVELACE = 1000000;

export const correctVoteAdaFormat = (
lovelace: number | undefined,
locale: string | undefined = undefined
) => {
if (lovelace) {
const ada = lovelace / LOVELACE;
return ada.toLocaleString(locale, {
minimumFractionDigits: 3,
maximumFractionDigits: 3,
});
}
return "0,000";
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from "@types";
import walletManager from "lib/walletManager";
import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage";
import { correctVoteAdaFormat } from "@helpers/adaFormat";

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

// check dRep votes
await expect(govActionDetailsPage.dRepYesVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepYesVotes)}`
);
await expect(govActionDetailsPage.dRepAbstainVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepAbstainVotes)}`
);
await expect(govActionDetailsPage.dRepNoVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepNoVotes)}`
);

// check sPos votes
await expect(govActionDetailsPage.sPosYesVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.poolYesVotes)}`
);
await expect(govActionDetailsPage.sPosAbstainVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.poolAbstainVotes)}`
);
await expect(govActionDetailsPage.sPosNoVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.poolNoVotes)}`
);

// check ccCommittee votes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { correctVoteAdaFormat } from "@helpers/adaFormat";
import { setAllureEpic } from "@helpers/allure";
import { lovelaceToAda, skipIfNotHardFork } from "@helpers/cardano";
import { skipIfNotHardFork } from "@helpers/cardano";
import GovernanceActionsPage from "@pages/governanceActionsPage";
import { expect, test } from "@playwright/test";
import { GrovernanceActionType, IProposal } from "@types";
Expand Down Expand Up @@ -57,24 +58,24 @@ test("4K. Should display correct vote counts on governance details page for disc

// check dRep votes
await expect(govActionDetailsPage.dRepYesVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepYesVotes)}`
);
await expect(govActionDetailsPage.dRepAbstainVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepAbstainVotes)}`
);
await expect(govActionDetailsPage.dRepNoVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.dRepNoVotes)}`
);

// check sPos votes
await expect(govActionDetailsPage.sPosYesVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.poolYesVotes)}`
);
await expect(govActionDetailsPage.sPosAbstainVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.poolAbstainVotes)}`
);
await expect(govActionDetailsPage.sPosNoVotes).toHaveText(
`₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}`
`₳ ${correctVoteAdaFormat(proposalToCheck.poolNoVotes)}`
);

// check ccCommittee votes
Expand Down

0 comments on commit c99bc8c

Please sign in to comment.