From 4441d19b1e13969549a57fa9f0dbbc940fc3cedd Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 19 Nov 2024 14:34:07 +0545 Subject: [PATCH 1/2] chore: add mock temp wallet on gitignore --- tests/govtool-frontend/playwright/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/govtool-frontend/playwright/.gitignore b/tests/govtool-frontend/playwright/.gitignore index 38697b044..8f2de676e 100644 --- a/tests/govtool-frontend/playwright/.gitignore +++ b/tests/govtool-frontend/playwright/.gitignore @@ -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 From bc67776262eb4ba492b79082f237ad80606abfd9 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 19 Nov 2024 16:29:56 +0545 Subject: [PATCH 2/2] chore: format vote ada for governance action --- .../playwright/lib/helpers/adaFormat.ts | 15 +++++++++++++++ .../proposalVisibility.dRep.spec.ts | 15 ++++++++------- .../proposalVisibility.spec.ts | 15 ++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 tests/govtool-frontend/playwright/lib/helpers/adaFormat.ts diff --git a/tests/govtool-frontend/playwright/lib/helpers/adaFormat.ts b/tests/govtool-frontend/playwright/lib/helpers/adaFormat.ts new file mode 100644 index 000000000..75444944b --- /dev/null +++ b/tests/govtool-frontend/playwright/lib/helpers/adaFormat.ts @@ -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"; +}; diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts index 6ac7a810b..dc6303276 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts @@ -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"); @@ -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 { @@ -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 diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts index 632760655..c36a339d7 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts @@ -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"; @@ -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