From c4d77ee96186d3b05f506ed299654820b5557292 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 10 Dec 2024 12:19:24 +0545 Subject: [PATCH] refactor: proposal info content testIds --- .../lib/pages/proposalSubmissionPage.ts | 16 ++++- .../proposalSubmission.loggedin.spec.ts | 68 +++++++++---------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts index 47c40117f..ce6d5977f 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts @@ -70,7 +70,21 @@ export default class ProposalSubmissionPage { readonly closeDraftSuccessModalBtn = this.page.getByTestId("close-button"); readonly linkTextInput = this.page.getByTestId("link-0-text-input"); readonly linkUrlInput = this.page.getByTestId("link-0-url-input"); - + + // content + readonly governanceActionTypeContent = this.page.getByTestId( + "governance-action-type-content" + ); + readonly titleContent = this.page.getByTestId("title-content"); + readonly abstractContent = this.page.getByTestId("abstract-content"); + readonly motivationContent = this.page.getByTestId("motivation-content"); + readonly rationaleContent = this.page.getByTestId("rationale-content"); + readonly receivingAddressContent = this.page.getByTestId( + "receiving-address-0-content" + ); + readonly amountContent = this.page.getByTestId("amount-0-content"); + readonly linkTextContent = this.page.getByTestId("link-0-text-content"); + readonly linkUrlContent = this.page.getByTestId("link-0-url-content"); constructor(private readonly page: Page) {} diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts index f28603e2a..f870e5881 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts @@ -140,22 +140,22 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.submitBtn.click(); await expect(page.getByTestId("submit-as-GA-button")).toBeVisible(); - await expect(page.getByTestId("title-content")).toHaveText( + await expect(proposalSubmissionPage.titleContent).toHaveText( proposal.prop_name ); await expect( - page.getByTestId("governance-action-type-content") + proposalSubmissionPage.governanceActionTypeContent ).toHaveText(type); - await expect(page.getByTestId("abstract-content")).toHaveText( + await expect(proposalSubmissionPage.abstractContent).toHaveText( proposal.prop_abstract ); - await expect(page.getByTestId("motivation-content")).toHaveText( + await expect(proposalSubmissionPage.motivationContent).toHaveText( proposal.prop_motivation ); - await expect(page.getByTestId("rationale-content")).toHaveText( + await expect(proposalSubmissionPage.rationaleContent).toHaveText( proposal.prop_rationale ); - await expect(page.getByTestId("link-0-text-content")).toHaveText( + await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposal.proposal_links[0].prop_link_text ); }); @@ -187,28 +187,28 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.continueBtn.click(); await expect( - page.getByTestId("governance-action-type-content") + proposalSubmissionPage.governanceActionTypeContent ).toHaveText(type); - await expect(page.getByTestId("title-content")).toHaveText( + await expect(proposalSubmissionPage.titleContent).toHaveText( proposal.prop_name ); - await expect(page.getByTestId("abstract-content")).toHaveText( + await expect(proposalSubmissionPage.abstractContent).toHaveText( proposal.prop_abstract ); - await expect(page.getByTestId("motivation-content")).toHaveText( + await expect(proposalSubmissionPage.motivationContent).toHaveText( proposal.prop_motivation ); - await expect(page.getByTestId("rationale-content")).toHaveText( + await expect(proposalSubmissionPage.rationaleContent).toHaveText( proposal.prop_rationale ); - await expect(page.getByTestId("link-0-text-content")).toHaveText( + await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposal.proposal_links[0].prop_link_text ); if (type === ProposalType.treasury) { await expect( - page.getByTestId("receiving-address-content") + proposalSubmissionPage.receivingAddressContent ).toHaveText(proposal.prop_receiving_address); - await expect(page.getByTestId("amount-content")).toHaveText( + await expect(proposalSubmissionPage.amountContent).toHaveText( proposal.prop_amount ); } @@ -387,20 +387,20 @@ test.describe("Info Proposal Draft", () => { await proposalSubmissionPage.titleInput.fill(newTitle); await proposalSubmissionPage.continueBtn.click(); - await expect(page.getByTestId("governance-action-type-content")).toHaveText( + await expect(proposalSubmissionPage.governanceActionTypeContent).toHaveText( ProposalType.info ); - await expect(page.getByTestId("title-content")).toHaveText(newTitle); - await expect(page.getByTestId("abstract-content")).toHaveText( + await expect(proposalSubmissionPage.titleContent).toHaveText(newTitle); + await expect(proposalSubmissionPage.abstractContent).toHaveText( proposalFormValue.prop_abstract ); - await expect(page.getByTestId("motivation-content")).toHaveText( + await expect(proposalSubmissionPage.motivationContent).toHaveText( proposalFormValue.prop_motivation ); - await expect(page.getByTestId("rationale-content")).toHaveText( + await expect(proposalSubmissionPage.rationaleContent).toHaveText( proposalFormValue.prop_rationale ); - await expect(page.getByTestId("link-0-text-content")).toHaveText( + await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposalFormValue.proposal_links[0].prop_link_text ); }); @@ -421,22 +421,22 @@ test.describe("Info Proposal Draft", () => { await proposalSubmissionPage.submitBtn.click(); await expect(page.getByTestId("submit-as-GA-button")).toBeVisible(); - await expect(page.getByTestId("title-content")).toHaveText( + await expect(proposalSubmissionPage.titleContent).toHaveText( proposalFormValue.prop_name ); - await expect(page.getByTestId("governance-action-type-content")).toHaveText( + await expect(proposalSubmissionPage.governanceActionTypeContent).toHaveText( ProposalType.info ); - await expect(page.getByTestId("abstract-content")).toHaveText( + await expect(proposalSubmissionPage.abstractContent).toHaveText( proposalFormValue.prop_abstract ); - await expect(page.getByTestId("motivation-content")).toHaveText( + await expect(proposalSubmissionPage.motivationContent).toHaveText( proposalFormValue.prop_motivation ); - await expect(page.getByTestId("rationale-content")).toHaveText( + await expect(proposalSubmissionPage.rationaleContent).toHaveText( proposalFormValue.prop_rationale ); - await expect(page.getByTestId("link-0-text-content")).toHaveText( + await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposalFormValue.proposal_links[0].prop_link_text ); }); @@ -459,26 +459,26 @@ test.describe("Treasury Proposal Draft", () => { await proposalSubmissionPage.titleInput.fill(newTitle); await proposalSubmissionPage.continueBtn.click(); - await expect(page.getByTestId("governance-action-type-content")).toHaveText( + await expect(proposalSubmissionPage.governanceActionTypeContent).toHaveText( ProposalType.treasury ); - await expect(page.getByTestId("title-content")).toHaveText(newTitle); - await expect(page.getByTestId("abstract-content")).toHaveText( + await expect(proposalSubmissionPage.titleContent).toHaveText(newTitle); + await expect(proposalSubmissionPage.abstractContent).toHaveText( proposalFormValue.prop_abstract ); - await expect(page.getByTestId("motivation-content")).toHaveText( + await expect(proposalSubmissionPage.motivationContent).toHaveText( proposalFormValue.prop_motivation ); - await expect(page.getByTestId("rationale-content")).toHaveText( + await expect(proposalSubmissionPage.rationaleContent).toHaveText( proposalFormValue.prop_rationale ); - await expect(page.getByTestId("receiving-address-content")).toHaveText( + await expect(proposalSubmissionPage.receivingAddressContent).toHaveText( proposalFormValue.prop_receiving_address ); - await expect(page.getByTestId("amount-content")).toHaveText( + await expect(proposalSubmissionPage.amountContent).toHaveText( proposalFormValue.prop_amount ); - await expect(page.getByTestId("link-0-text-content")).toHaveText( + await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposalFormValue.proposal_links[0].prop_link_text ); });