From c4eb4f47ebebb625d89507720b9d4d07c9b7b960 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 19 May 2025 12:01:42 +0545 Subject: [PATCH 1/6] feat: add updateWalletGivenName method to WalletManager for updating wallet names --- .../govtool-frontend/playwright/lib/walletManager.ts | 10 ++++++++++ .../govtool-frontend/playwright/tests/dRep.setup.ts | 8 +++----- .../playwright/tests/proposal-budget.dRep.setup.ts | 12 +++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/walletManager.ts b/tests/govtool-frontend/playwright/lib/walletManager.ts index 53192e886..23842a22d 100644 --- a/tests/govtool-frontend/playwright/lib/walletManager.ts +++ b/tests/govtool-frontend/playwright/lib/walletManager.ts @@ -65,5 +65,15 @@ class WalletManager { return await LockInterceptor.intercept("tempWallets", popCb); } + + async updateWalletGivenName(address: string, givenName: string) { + const wallets: StaticWallet[] = (await getFile("wallets.json")) ?? []; + wallets.map((wallet: StaticWallet) => { + if (wallet.address === address) { + wallet.givenName = givenName; + } + }); + await createFile("wallets.json", wallets); + } } export default WalletManager.getInstance(); diff --git a/tests/govtool-frontend/playwright/tests/dRep.setup.ts b/tests/govtool-frontend/playwright/tests/dRep.setup.ts index afb3c798c..584120038 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.setup.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.setup.ts @@ -45,11 +45,9 @@ setup("Register DRep of static wallets", async () => { const metadataPromises = dRepWallets.map(async (dRepWallet) => { const metadataResponse = await uploadMetadataAndGetJsonHash(); const givenName = metadataResponse.givenName; - const index = dRepWallets.indexOf(dRepWallet); - dRepWallets[index] = { - ...dRepWallet, - givenName, - }; + + await walletManager.updateWalletGivenName(dRepWallet.address, givenName); + return { ...metadataResponse, wallet: dRepWallet, diff --git a/tests/govtool-frontend/playwright/tests/proposal-budget.dRep.setup.ts b/tests/govtool-frontend/playwright/tests/proposal-budget.dRep.setup.ts index 0a91e509a..78191ad17 100644 --- a/tests/govtool-frontend/playwright/tests/proposal-budget.dRep.setup.ts +++ b/tests/govtool-frontend/playwright/tests/proposal-budget.dRep.setup.ts @@ -11,6 +11,7 @@ import { expect } from "@playwright/test"; import { test as setup } from "@fixtures/walletExtension"; import kuberService from "@services/kuberService"; +import walletManager from "lib/walletManager"; setup.beforeEach(async () => { await setAllureEpic("Setup"); @@ -28,11 +29,12 @@ setup("Register DRep of proposal budget static wallets", async () => { async (dRepWallet) => { const metadataResponse = await uploadMetadataAndGetJsonHash(); const givenName = metadataResponse.givenName; - const index = dRepWallets.indexOf(dRepWallet); - dRepWallets[index] = { - ...dRepWallet, - givenName, - }; + + await walletManager.updateWalletGivenName( + dRepWallet.address, + givenName + ); + return { ...metadataResponse, wallet: dRepWallet, From bb4556e5eb2ac3d7dde346fd1f4e216ed1f21553 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 19 May 2025 12:01:54 +0545 Subject: [PATCH 2/6] fix: update DRep comment visibility checks in proposal budget tests --- .../proposalBudget.dRep.pb.spec.ts | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts b/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts index 8e38001f0..cc71001f4 100644 --- a/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts +++ b/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts @@ -100,25 +100,17 @@ test.describe("Budget proposal dRep behaviour", () => { .locator('[data-testid^="comment-"][data-testid$="-content-card"]') .first(); - await expect( - dRepCommentedCard.getByText("DRep", { exact: true }) - ).toBeVisible(); - - const isDRepGivenNameVisible = await dRepCommentedCard - .getByTestId("given-name") - .isVisible(); - - expect( - isDRepGivenNameVisible, - !isDRepGivenNameVisible && "Missing given-name testId" - ).toBeTruthy(); + await expect(dRepCommentedCard.getByTestId("dRep-tag")).toBeVisible(); - await expect(dRepCommentedCard.getByTestId("given-name")).toHaveText( - dRep03Wallet.givenName + await expect(dRepCommentedCard.getByTestId("dRep-given-name")).toHaveText( + dRep03Wallet.givenName, + { timeout: 60_000 } ); - await expect(dRepCommentedCard.getByTestId("drep-id")).toHaveText( - dRep03Wallet.dRepId - ); + const dRepIdWithoutDotted = ( + await dRepCommentedCard.getByTestId("dRep-id").textContent() + ).replace(/\./g, ""); + + expect(dRep03Wallet.dRepId).toContain(dRepIdWithoutDotted); }); }); From 891e91835282ebdc2a6092b0788bc3e3c1e6ac13 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 19 May 2025 12:10:15 +0545 Subject: [PATCH 3/6] fix: costing rejection test by focusing to display error message --- .../playwright/lib/pages/budgetDiscussionSubmissionPage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/budgetDiscussionSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/budgetDiscussionSubmissionPage.ts index b37520f54..bdb67e20c 100644 --- a/tests/govtool-frontend/playwright/lib/pages/budgetDiscussionSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/budgetDiscussionSubmissionPage.ts @@ -391,10 +391,10 @@ export default class BudgetDiscussionSubmissionPage { await this.usaToAdaCnversionRateInput.fill( costing.usdToAdaConversionRate.toString() ); - await this.costBreakdownInput.fill(costing.costBreakdown); await this.preferredCurrencyInput.fill( costing.AmountInPreferredCurrency.toString() ); + await this.costBreakdownInput.fill(costing.costBreakdown); } async fillupCostingForm(costing: BudgetCostingProps) { From d011b9a11bbbeb5633603faf1bcfaeddda912dee Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 19 May 2025 12:17:54 +0545 Subject: [PATCH 4/6] fix: trim whitespace in proposal title search assertion --- .../tests/8-proposal-discussion/proposalDiscussion.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts b/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts index e4303ae9b..cdecc19cc 100644 --- a/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts +++ b/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts @@ -119,7 +119,7 @@ test("8C. Should search the list of proposed governance actions.", async ({ const proposalTitle = await proposalCard .locator('[data-testid^="proposal-"][data-testid$="-title"]') .innerText(); - expect(proposalTitle).toContain(proposalName); + expect(proposalTitle.trim()).toContain(proposalName.trim()); } }, { From 0b23e80bce62dc96b345a0b0a65e8dbda94335ca Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 20 May 2025 13:10:24 +0545 Subject: [PATCH 5/6] fix: increase timeout for visibility checks in DRep tests --- .../tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts | 6 ++++-- .../tests/3-drep-registration/dRepRegistration.dRep.spec.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts b/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts index cc71001f4..db17b101a 100644 --- a/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts +++ b/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts @@ -35,7 +35,9 @@ test.describe("Budget proposal dRep behaviour", () => { await budgetDiscussionDetailsPage.voteOnPoll(choice); - await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible(); + await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible({ + timeout: 60_000, + }); await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible(); await expect( budgetDiscussionDetailsPage.currentPage.getByTestId( @@ -59,7 +61,7 @@ test.describe("Budget proposal dRep behaviour", () => { await budgetDiscussionDetailsPage.voteOnPoll(choice); await budgetDiscussionDetailsPage.changePollVote(); - await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible(); + await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible({timeout: 60_000}); await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible(); // vote must be changed diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts index 91fb769dd..1e1bdcbfa 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts @@ -222,7 +222,7 @@ test.describe("Temporary DReps", () => { await dRepPage.getByTestId("continue-retirement-button").click(); await expect( dRepPage.getByTestId("retirement-transaction-submitted-modal") - ).toBeVisible({ timeout: 15_000 }); + ).toBeVisible({ timeout: 60_000 }); dRepPage.getByTestId("confirm-modal-button").click(); await waitForTxConfirmation(dRepPage); From d4d80d4a0f9db3912c1f488ccbc4312873711023 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 20 May 2025 13:11:06 +0545 Subject: [PATCH 6/6] fix: handle unnecessary wait if title is already on response --- .../playwright/lib/pages/outcomesPage.ts | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts b/tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts index 031dfa5e9..9ac9a9e06 100644 --- a/tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts @@ -374,25 +374,30 @@ export default class OutComesPage { } async fetchOutcomeIdAndTitleFromNetwork( - governanceActionId: string, - governanceActionTitle: string - ) { + governanceActionId?: string, + governanceActionTitle?: string + ): Promise<{ governanceActionId: string; governanceActionTitle: string }> { let updatedGovernanceActionId = governanceActionId; let updatedGovernanceActionTitle = governanceActionTitle; + await this.page.route( "**/governance-actions?search=&filters=&sort=**", async (route) => { const response = await route.fetch(); const data: outcomeProposal[] = await response.json(); - if (!governanceActionId) { - if (data.length > 0) { - const randomIndexForId = Math.floor(Math.random() * data.length); - updatedGovernanceActionId = - data[randomIndexForId].tx_hash + - "#" + - data[randomIndexForId].index; + + if (!updatedGovernanceActionId && data.length > 0) { + const randomIndex = Math.floor(Math.random() * data.length); + updatedGovernanceActionId = `${data[randomIndex].tx_hash}#${data[randomIndex].index}`; + } + + if (!updatedGovernanceActionTitle) { + const itemWithTitle = data.find((item) => item.title != null); + if (itemWithTitle) { + updatedGovernanceActionTitle = itemWithTitle.title; } } + await route.fulfill({ status: 200, contentType: "application/json", @@ -410,31 +415,40 @@ export default class OutComesPage { await route.continue(); return; } + const data: outcomeMetadata = await response.json(); - if (!governanceActionTitle && data.data.title != null) { + if (!updatedGovernanceActionTitle && data.data.title) { updatedGovernanceActionTitle = data.data.title; } + await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(data), }); } catch (error) { + // Just return without handling the error return; } } ); - const responsePromise = this.page.waitForResponse( + const actionsResponsePromise = this.page.waitForResponse( "**/governance-actions?search=&filters=&sort=**" ); - const metadataResponsePromise = this.page.waitForResponse( - "**/governance-actions/metadata?**" - ); + await this.goto(); - await responsePromise; - await metadataResponsePromise; + await actionsResponsePromise; + + const needMetadataForTitle = !updatedGovernanceActionTitle; + const metadataResponsePromise = needMetadataForTitle + ? this.page.waitForResponse("**/governance-actions/metadata?**") + : Promise.resolve(null); + if (needMetadataForTitle) { + await metadataResponsePromise; + } + return { governanceActionId: updatedGovernanceActionId, governanceActionTitle: updatedGovernanceActionTitle,