From 90d84cec982a2733bb395a507ead09514a72acd8 Mon Sep 17 00:00:00 2001 From: kneerose Date: Sat, 19 Jul 2025 09:57:46 +0545 Subject: [PATCH] fix: update comment count display to show "99+" for counts exceeding 99 --- .../tests/11-proposal-budget/proposalBudget.spec.ts | 9 ++++++--- .../8-proposal-discussion/proposalDiscussion.spec.ts | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.spec.ts b/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.spec.ts index 81954b640..0f198ef4d 100644 --- a/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.spec.ts +++ b/tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.spec.ts @@ -247,19 +247,22 @@ test("11E. Should view comments with count indications on a budget proposal", as const actualTotalComments = await budgetDiscussionDetailsPage.totalComments.textContent(); - const expectedTotalComments = - proposalResponse.data.attributes.prop_comments_number.toString(); + let expectedTotalComments = + proposalResponse.data.attributes.prop_comments_number; const isEqual = actualTotalComments === expectedTotalComments; const currentPageUrl = budgetDiscussionDetailsPage.currentPage.url(); const proposalId = extractProposalIdFromUrl(currentPageUrl); + if (expectedTotalComments > 99) { + expectedTotalComments = "99+"; + } await expect( budgetDiscussionDetailsPage.totalComments, !isEqual && `Total comments do not match in ${environments.frontendUrl}/budget_discussion/${proposalId}` - ).toHaveText(expectedTotalComments); + ).toHaveText(expectedTotalComments.toString()); }); test.describe("Restricted access to interact budget proposal", () => { 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 011627afa..d15193669 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 @@ -293,8 +293,12 @@ test.describe("Mocked proposal", () => { }); test("8F. Should display all comments with count indication.", async () => { + let commentCount = mockProposal.data.attributes.prop_comments_number; + if (commentCount > 99) { + commentCount = "99+"; + } await expect(proposalDiscussionDetailsPage.commentCount).toHaveText( - mockProposal.data.attributes.prop_comments_number.toString(), + commentCount.toString(), { timeout: 60_000 } ); });