From ec5cc289612bdeaba33eefa3ba162b63cdea74ad Mon Sep 17 00:00:00 2001 From: niraj Date: Thu, 11 Jul 2024 16:30:24 +0545 Subject: [PATCH] chore: Add pdf missing test ids --- .../pages/proposalDiscussionDetailsPage.ts | 48 +++---- .../lib/pages/proposalDiscussionPage.ts | 88 +++++------- .../lib/pages/proposalSubmissionPage.ts | 56 ++++---- .../miscellaneous.loggedin.spec.ts | 14 +- .../proposalSubmission.ga.spec.ts | 2 +- .../proposalSubmission.loggedin.spec.ts | 132 ++++++++++-------- .../proposalDiscussion.loggedin.spec.ts | 24 ++-- .../proposalDiscussion.spec.ts | 8 +- 8 files changed, 182 insertions(+), 190 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionDetailsPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionDetailsPage.ts index 36a878e52..db2b639a7 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionDetailsPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionDetailsPage.ts @@ -4,51 +4,41 @@ import { CommentResponse } from "@types"; export default class ProposalDiscussionDetailsPage { // Buttons - readonly likeBtn = this.page.getByRole("button", { - name: "proposal likes", - }); - readonly dislikeBtn = this.page.getByRole("button", { - name: "proposal dislikes", - }); + readonly likeBtn = this.page.getByTestId("like-button"); + readonly dislikeBtn = this.page.getByTestId("dislike-button"); readonly commentBtn = this.page.getByTestId("comment-button"); - readonly addPollBtn = this.page.getByRole("button", { name: "Add Poll" }); // BUG missing test id + readonly replyCommentBtn = this.page.getByTestId("reply-comment-button"); + readonly addPollBtn = this.page.getByTestId("add-poll-button"); readonly SubmitBtn = this.page.getByTestId("submit-button"); readonly menuBtn = this.page.getByTestId("menu-button"); readonly editProposalBtn = this.page.getByTestId("edit-proposal"); readonly deleteProposalBtn = this.page.getByTestId("delete-proposal"); readonly reviewVersionsBtn = this.page.getByTestId("review-versions"); - readonly closePollBtn = this.page.getByRole("button", { name: "Close Poll" }); // BUG missing test id - readonly sortBtn = this.page - .locator("div") - .filter({ hasText: /^Comments$/ }) - .getByRole("button"); // this.page.getByTestId("sort-button"); + readonly closePollBtn = this.page.getByTestId("close-poll-button"); + readonly sortBtn = this.page.getByTestId("sort-comments"); readonly proposeGovernanceAction = this.page.getByTestId("propose-GA-button"); readonly replyBtn = this.page.getByTestId("reply-button"); - readonly pollYesBtn = this.page.getByRole("button", { name: "Yes" }); //BUG missing test id - readonly pollNoBtn = this.page.getByRole("button", { name: "No" }); //BUG missing test id + readonly pollYesBtn = this.page.getByTestId("poll-yes-button"); + readonly pollNoBtn = this.page.getByTestId("poll-no-button"); readonly showReplyBtn = this.page.getByTestId("show-more-reply"); readonly closePollYesBtn = this.page.getByTestId("close-the-poll-button"); - readonly changeVoteBtn = this.page.getByRole("button", { - name: "Change Vote", - }); + readonly changeVoteBtn = this.page.getByTestId("change-vote-button"); readonly verifyIdentityBtn = this.page.getByRole("button", { name: "Verify your identity", - }); + }); // BUG readonly submitAsGABtn = this.page.getByTestId("submit-as-GA-button"); // Indicators - readonly likesCounts = this.page.getByTestId("likes-count"); - readonly dislikesCounts = this.page.getByTestId("dislikse-count"); + readonly likeCount = this.likeBtn.getByTestId("like-count"); + readonly dislikeCount = this.dislikeBtn.getByTestId("dislike-count"); readonly commentCount = this.page.getByTestId("comment-count"); // Cards readonly pollVoteCard = this.page.getByTestId("poll-vote-card"); readonly pollResultCard = this.page.getByTestId("poll-result-card"); - readonly commentCard = - this.proposeGovernanceAction.getByTestId("comment-card"); //inputs - readonly commentInput = this.page.getByRole("textbox"); + readonly commentInput = this.page.getByTestId("comment-input"); constructor(private readonly page: Page) {} @@ -68,13 +58,13 @@ export default class ProposalDiscussionDetailsPage { async addComment(comment: string) { await this.commentInput.fill(comment); - await this.page.getByTestId("comment-button").click(); + await this.commentBtn.click(); } async replyComment(reply: string) { - await this.page.getByRole("button", { name: "Reply" }).click(); - await this.page.getByPlaceholder("Add comment").fill(reply); - await this.page.getByTestId("reply-comment-button").click(); + await this.replyBtn.click(); + await this.page.getByTestId("reply-input").fill(reply); + await this.replyCommentBtn.click(); } async sortAndValidate( @@ -101,13 +91,13 @@ export default class ProposalDiscussionDetailsPage { } async voteOnPoll(vote: string) { - await this.page.getByRole("button", { name: `${vote}` }).click(); + await this.page.getByTestId(`poll-${vote.toLowerCase()}-button`).click(); } async deleteProposal() { await this.page.waitForTimeout(2_000); - await this.page.locator("#menu-button").click(); + await this.page.getByTestId("menu-button").click(); await this.page.getByTestId("delete-proposal").click(); await this.page.getByTestId("delete-proposal-yes-button").click(); } diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts index ff5e45d4a..1304af60a 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts @@ -8,26 +8,20 @@ import ProposalDiscussionDetailsPage from "./proposalDiscussionDetailsPage"; export default class ProposalDiscussionPage { // Buttons - readonly proposalCreateBtn = this.page.getByRole("button", { - name: "Propose a Governance Action", - }); - readonly continueBtn = this.page.getByRole("button", { name: "Continue" }); // #BUG test-id missing - readonly filterBtn = this.page.locator("#filters-button"); // this.page.getByTestId("filters-button"); - readonly shareBtn = this.page - .locator(".MuiCardHeader-action > .MuiButtonBase-root") - .first(); //this.page.getByTestId("share-button"); - readonly sortBtn = this.page.locator("button:nth-child(2)").first(); //this.page.getByTestId("sort-button"); - readonly searchInput = this.page.getByPlaceholder("Search..."); // this.page.getByTestId("search-input"); - readonly showAllBtn = this.page - .getByRole("button", { name: "Show all" }) - .first(); //this.page.getByTestId("show-all-button"); - readonly showLessBtn = this.page.getByRole("button", { name: "Show less" }); - readonly infoRadio = this.page.getByLabel("Info"); - readonly treasuryRadio = this.page.getByLabel("Treasury"); + readonly proposalCreateBtn = this.page.getByTestId( + "propose-a-governance-action-button" + ); + readonly continueBtn = this.page.getByTestId("continue-button"); + readonly filterBtn = this.page.getByTestId("filter-button"); + readonly sortBtn = this.page.getByTestId("sort-button"); + readonly searchInput = this.page.getByTestId("search-input"); + readonly showAllBtn = this.page.getByTestId("show-all-button").first(); //this.page.getByTestId("show-all-button"); readonly verifyIdentityBtn = this.page.getByRole("button", { name: "Verify your identity", - }); - readonly addLinkBtn = this.page.getByRole("button", { name: "Add link" }); + }); // BUG + readonly addLinkBtn = this.page.getByTestId("add-link-button"); + readonly infoRadio = this.page.getByTestId("Info-radio-wrapper"); + readonly treasuryRadio = this.page.getByTestId("Treasury-radio-wrapper"); constructor(private readonly page: Page) {} @@ -37,6 +31,7 @@ export default class ProposalDiscussionPage { } async closeUsernamePrompt() { + await this.page.waitForTimeout(5_000); await this.page .locator("div") .filter({ hasText: /^Hey, setup your username$/ }) @@ -54,35 +49,20 @@ export default class ProposalDiscussionPage { async getAllProposals() { await this.page.waitForTimeout(4_000); // waits for proposals to render - // BUG Select all elements with data-testid attribute - const elements = await this.page.$$("[data-testid]"); - - // Regex pattern to match IDs starting with "proposal" and ending with numbers - const pattern = /^proposal-\d+$/; - - // Extract the data-testid attributes - const proposalCards: Locator[] = []; - for (const element of elements) { - const dataTestId = await element.getAttribute("data-testid"); - if (pattern.test(dataTestId)) { - proposalCards.push(this.page.getByTestId(dataTestId)); - } - } - return proposalCards; - // BUG return this.page.locator('[data-testid$="-card"]').all(); + return this.page + .locator('[data-testid^="proposal-"][data-testid$="-card"]') + .all(); } async setUsername(name: string) { - await this.page.getByLabel("Username *").fill(name); + await this.page.getByTestId("username-input").fill(name); - const proceedBtn = this.page.getByRole("button", { - name: "Proceed with this username", - }); + const proceedBtn = this.page.getByTestId("proceed-button"); await proceedBtn.click(); await proceedBtn.click(); - await this.page.getByRole("button", { name: "Close" }).click(); + await this.page.getByTestId("close-button").click(); } async createProposal(): Promise { @@ -109,7 +89,7 @@ export default class ProposalDiscussionPage { await this.fillForm(proposalRequest); await this.continueBtn.click(); - await this.page.getByRole("button", { name: "Submit" }).click(); + await this.page.getByTestId("submit-button").click(); // Wait for redirection to `proposal-discussion-details` page await this.page.waitForTimeout(2_000); @@ -119,32 +99,34 @@ export default class ProposalDiscussionPage { } private async fillForm(data: ProposalCreateRequest) { - await this.page.getByLabel("Governance Action Type *").click(); - await this.page.getByRole("option", { name: "Info" }).click(); - await this.page.getByLabel("Title *").fill(data.prop_name); - await this.page.getByPlaceholder("Summary...").fill(data.prop_abstract); - await this.page.getByLabel("Motivation *").fill(data.prop_motivation); - await this.page.getByLabel("Rationale *").fill(data.prop_rationale); - - for (const link of data.proposal_links) { + await this.page.getByTestId("governance-action-type").click(); + await this.page.getByTestId("info-button").click(); + await this.page.getByTestId("title-input").fill(data.prop_name); + await this.page.getByTestId("abstract-input").fill(data.prop_abstract); + await this.page.getByTestId("motivation-input").fill(data.prop_motivation); + await this.page.getByTestId("rationale-input").fill(data.prop_rationale); + + for (let index = 0; index < data.proposal_links.length; index++) { await this.addLinkBtn.click(); await this.page - .getByPlaceholder("https://website.com") - .fill(link.prop_link); - await this.page.getByPlaceholder("Text").fill(link.prop_link_text); + .getByTestId(`link-${index}-url-input`) + .fill(data.proposal_links[index].prop_link); + await this.page + .getByTestId(`link-${index}-text-input`) + .fill(data.proposal_links[index].prop_link_text); } } async filterProposalByNames(names: string[]) { for (const name of names) { - await this.page.getByLabel(name).click(); + await this.page.getByLabel(name).click(); // test id is not in proper format for all filter type } } async unFilterProposalByNames(names: string[]) { for (const name of names) { - await this.page.getByLabel(name).click(); + await this.page.getByLabel(name).click(); // test id is not in proper format for all filter type } } diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts index ed318b068..103675b4e 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts @@ -28,41 +28,41 @@ export default class ProposalSubmissionPage { ); // buttons - readonly proposalCreateBtn = this.page.getByRole("button", { - name: "Propose a Governance Action", - }); + readonly proposalCreateBtn = this.page.getByTestId( + "propose-a-governance-action-button" + ); readonly registerBtn = this.page.getByTestId("register-button"); readonly skipBtn = this.page.getByTestId("skip-button"); readonly confirmBtn = this.page.getByTestId("confirm-modal-button"); - readonly continueBtn = this.page.getByRole("button", { name: "Continue" }); //BUG testid = continue-button - readonly addLinkBtn = this.page.getByRole("button", { name: "Add link" }); // BUG testid= add-link-button - readonly infoBtn = this.page.getByRole("option", { name: "Info" }); // BUG missing test id - readonly treasuryBtn = this.page.getByRole("option", { name: "Treasury" }); // BUG missing test id + readonly continueBtn = this.page.getByTestId("continue-button"); + readonly addLinkBtn = this.page.getByTestId("add-link-button"); + readonly infoBtn = this.page.getByTestId("info-button"); + readonly treasuryBtn = this.page.getByTestId("treasury-button"); readonly editSubmissionButton = this.page.getByTestId( "edit-submission-button" ); readonly verifyIdentityBtn = this.page.getByRole("button", { name: "Verify your identity", - }); + }); // BUG missing test id readonly governanceActionType = this.page.getByLabel( "Governance Action Type *" - ); // BUG missing test id + ); readonly saveDraftBtn = this.page.getByTestId("save-draft-button"); - readonly submitBtn = this.page.getByRole("button", { name: "Submit" }); // BUG missing test id - readonly createNewProposalBtn = this.page.getByRole("button", { - name: "Create new Proposal", - }); + readonly submitBtn = this.page.getByTestId("submit-button"); + readonly createNewProposalBtn = this.page.getByTestId( + "create-new-proposal-button" + ); // input fields - readonly titleInput = this.page.getByLabel("Title *"); // BUG testid = title-input - readonly abstractInput = this.page.getByLabel("Abstract *"); // BUG testid = abstract-input - readonly metadataUrlInput = this.page.getByPlaceholder("URL"); // BUG missing test id - readonly motivationInput = this.page.getByLabel("Motivation *"); // BUG testid = motivation-input - readonly rationaleInput = this.page.getByLabel("Rationale *"); // BUG testid = rationale-input - readonly linkInput = this.page.getByLabel("Link #1 URL"); // BUG testid = link-input - readonly linkText = this.page.getByLabel("Link #1 Text"); // BUG missing testid - readonly receivingAddressInput = this.page.getByLabel("Receiving address *"); // BUG missing testid + readonly titleInput = this.page.getByTestId("title-input"); + readonly abstractInput = this.page.getByTestId("abstract-input"); + readonly metadataUrlInput = this.page.getByTestId("url-input"); + readonly motivationInput = this.page.getByTestId("motivation-input"); + readonly rationaleInput = this.page.getByTestId("rationale-input"); + readonly receivingAddressInput = this.page.getByTestId( + "receiving-address-input" + ); readonly amountInput = this.page.getByTestId("amount-input"); readonly closeDraftSuccessModalBtn = this.page.getByTestId( "delete-proposal-yes-button" @@ -82,11 +82,7 @@ export default class ProposalSubmissionPage { } async fillUpValidMetadata() { - this.page - .getByRole("button", { - name: "data.jsonld", - }) - .click(); // BUG test id = metadata-download-button + this.page.getByTestId("download-button").click(); const dRepMetadata = await this.downloadVoteMetadata(); const url = await metadataBucketService.uploadMetadata( @@ -144,8 +140,12 @@ export default class ProposalSubmissionPage { if (i > 0) { await this.addLinkBtn.click(); } - await this.linkInput.fill(proposal_links[i].prop_link); - await this.linkText.fill(proposal_links[i].prop_link_text); + await this.page + .getByTestId(`link-${i}-url-input`) + .fill(proposal_links[i].prop_link); + await this.page + .getByTestId(`link-${i}-text-input`) + .fill(proposal_links[i].prop_link_text); } } diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts index 3bc367892..d0d6381e7 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts @@ -111,9 +111,9 @@ test.describe("Logged in user", () => { await page.goto("/"); await page.getByTestId("proposal-discussion-link").click(); await page.getByRole("button", { name: "Verify your identity" }).click(); // BUG: Test id missing - await expect(page.getByText("Hey, setup your usernameBy")).toBeVisible(); //BUG Add modal testid instead should be username-modal - await expect(page.getByLabel("Username *")).toBeVisible(); // BUG use testid instead + await expect(page.getByTestId("setup-username-modal")).toBeVisible(); + await expect(page.getByTestId("username-input")).toBeVisible(); }); }); @@ -143,11 +143,11 @@ test.describe("Temporary user", () => { test("6K. Should accept valid username.", async () => { for (let i = 0; i < 100; i++) { await userPage - .getByLabel("Username *") + .getByTestId("username-input") .fill(mockValid.username().toLowerCase()); await expect( - userPage.getByText("Invalid username. Only lower") + userPage.getByTestId("username-error-text") ).not.toBeVisible(); await expect(userPage.getByTestId("proceed-button")).toBeEnabled(); } @@ -156,12 +156,10 @@ test.describe("Temporary user", () => { test("6L. Should reject invalid username.", async () => { for (let i = 0; i < 100; i++) { await userPage - .getByLabel("Username *") + .getByTestId("username-input") .fill(mockInvalid.username().toLowerCase()); - await expect( - userPage.getByText("Invalid username. Only lower") - ).toBeVisible(); + await expect(userPage.getByTestId("username-error-text")).toBeVisible(); await expect(userPage.getByTestId("proceed-button")).toBeDisabled(); } }); diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.ga.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.ga.spec.ts index 6136de565..15c328baf 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.ga.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.ga.spec.ts @@ -44,7 +44,7 @@ test("7H. Should submit a proposal as governance action", async ({ await userPage.getByTestId("submit-as-GA-button").click(); - await userPage.click("input#submission-checkbox"); // BUG missing test id + await userPage.getByTestId("agree-checkbox").click(); proposalSubmissionPage.continueBtn.click(); await proposalSubmissionPage.fillUpValidMetadata(); 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 943887729..d057e7601 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 @@ -39,7 +39,7 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.goto(); await proposalSubmissionPage.governanceActionType.click(); - await page.getByRole("option", { name: type }).click(); + await page.getByTestId(`${type.toLocaleLowerCase()}-button`).click(); await proposalSubmissionPage.addLinkBtn.click(); for (let i = 0; i < 100; i++) { @@ -76,7 +76,7 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.goto(); await proposalSubmissionPage.governanceActionType.click(); - await page.getByRole("option", { name: type }).click(); + await page.getByTestId(`${type.toLocaleLowerCase()}-button`).click(); await proposalSubmissionPage.addLinkBtn.click(); const formFields: ProposalCreateRequest = @@ -114,11 +114,11 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.submitBtn.click(); await expect(page.getByTestId("submit-as-GA-button")).toBeVisible(); - await expect(page.getByText(type, { exact: true })).toBeVisible(); - await expect(page.getByText(proposal.prop_name)).toBeVisible(); - await expect(page.getByText(proposal.prop_abstract)).toBeVisible(); - await expect(page.getByText(proposal.prop_rationale)).toBeVisible(); - await expect(page.getByText(proposal.prop_motivation)).toBeVisible(); + await expect(page.getByText(type, { exact: true })).toBeVisible(); // BUG missing test id + await expect(page.getByText(proposal.prop_name)).toBeVisible(); // BUG missing test id + await expect(page.getByText(proposal.prop_abstract)).toBeVisible(); // BUG missing test id + await expect(page.getByText(proposal.prop_rationale)).toBeVisible(); // BUG missing test id + await expect(page.getByText(proposal.prop_motivation)).toBeVisible(); // BUG missing test id }); }); }); @@ -145,21 +145,31 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.fillupForm(proposal); await proposalSubmissionPage.continueBtn.click(); - await expect(page.getByText(proposal.prop_name)).toBeVisible(); - await expect(page.getByText(proposal.prop_abstract)).toBeVisible(); - await expect(page.getByText(proposal.prop_motivation)).toBeVisible(); - await expect(page.getByText(proposal.prop_rationale)).toBeVisible(); await expect( - page.getByText(proposal.proposal_links[0].prop_link_text) - ).toBeVisible(); - + page.getByTestId("governance-action-type-content") + ).toHaveText(type); + await expect(page.getByTestId("title-content")).toHaveText( + proposal.prop_name + ); + await expect(page.getByTestId("abstract-content")).toHaveText( + proposal.prop_abstract + ); + await expect(page.getByTestId("motivation-content")).toHaveText( + proposal.prop_motivation + ); + await expect(page.getByTestId("rationale-content")).toHaveText( + proposal.prop_rationale + ); + await expect(page.getByTestId("link-text-content")).toHaveText( + proposal.proposal_links[0].prop_link_text + ); if (type === ProposalType.treasury) { await expect( - page.getByText(proposal.prop_receiving_address) - ).toBeVisible(); - await expect( - page.getByText(proposal.prop_amount, { exact: true }) - ).toBeVisible(); + page.getByTestId("receiving-address-content") + ).toHaveText(proposal.prop_receiving_address); + await expect(page.getByTestId("amount-content")).toHaveText( + proposal.prop_amount + ); } }); }); @@ -204,8 +214,8 @@ test.describe("Proposal created logged state", () => { await proposalDiscussionDetailsPage.submitAsGABtn.click(); proposalSubmissionPage = new ProposalSubmissionPage(page); - await page.click("input#submission-checkbox"); // BUG missing test id - await page.getByRole("button", { name: "Continue" }).click(); + await page.getByTestId("agree-checkbox").click(); + await proposalSubmissionPage.continueBtn.click(); }); test.describe("Metadata anchor validation", () => { @@ -217,7 +227,7 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.metadataUrlInput.fill( faker.internet.url() ); - await expect(page.getByText("Invalid URL")).toBeHidden(); // BUG missing test ids + await expect(page.getByTestId("url-input-error-text")).toBeHidden(); } }); @@ -227,7 +237,7 @@ test.describe("Proposal created logged state", () => { test.slow(); // Brute-force testing with 100 random data for (let i = 0; i < 100; i++) { await proposalSubmissionPage.metadataUrlInput.fill(invalid.url()); - await expect(page.getByText("Invalid URL")).toBeVisible(); // BUG missing test ids + await expect(page.getByTestId("url-input-error-text")).toBeVisible(); } const sentenceWithoutSpace = faker.lorem @@ -240,7 +250,7 @@ test.describe("Proposal created logged state", () => { metadataAnchorGreaterThan128Bytes ); - await expect(page.getByText("Url must be less than 128")).toBeVisible(); // BUG missing test ids + await expect(page.getByTestId("url-input-error-text")).toBeVisible(); // BUG better to add different test id compare to invalid url testid }); }); @@ -317,19 +327,22 @@ test.describe("Temporary proposal users", () => { await proposalSubmissionPage.titleInput.fill(newTitle); await proposalSubmissionPage.continueBtn.click(); - await expect(userPage.getByText(newTitle)).toBeVisible(); await expect( - userPage.getByText(proposalFormValue.prop_abstract) - ).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.prop_motivation) - ).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.prop_rationale) - ).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.proposal_links[0].prop_link_text) - ).toBeVisible(); + userPage.getByTestId("governance-action-type-content") + ).toHaveText(ProposalType.info); + await expect(userPage.getByTestId("title-content")).toHaveText(newTitle); + await expect(userPage.getByTestId("abstract-content")).toHaveText( + proposalFormValue.prop_abstract + ); + await expect(userPage.getByTestId("motivation-content")).toHaveText( + proposalFormValue.prop_motivation + ); + await expect(userPage.getByTestId("rationale-content")).toHaveText( + proposalFormValue.prop_rationale + ); + await expect(userPage.getByTestId("link-text-content")).toHaveText( + proposalFormValue.proposal_links[0].prop_link_text + ); }); test("7N. Should submit a draft proposal", async ({}) => { @@ -340,19 +353,19 @@ test.describe("Temporary proposal users", () => { await expect(userPage.getByTestId("submit-as-GA-button")).toBeVisible(); await expect( userPage.getByText(ProposalType.info, { exact: true }) - ).toBeVisible(); + ).toBeVisible(); // BUG missing test id await expect( userPage.getByText(proposalFormValue.prop_name) - ).toBeVisible(); + ).toBeVisible(); // BUG missing test id await expect( userPage.getByText(proposalFormValue.prop_abstract) - ).toBeVisible(); + ).toBeVisible(); // BUG missing test id await expect( userPage.getByText(proposalFormValue.prop_rationale) - ).toBeVisible(); + ).toBeVisible(); // BUG missing test id await expect( userPage.getByText(proposalFormValue.prop_motivation) - ).toBeVisible(); + ).toBeVisible(); // BUG missing test id }); }); @@ -386,25 +399,28 @@ test.describe("Temporary proposal users", () => { await proposalSubmissionPage.titleInput.fill(newTitle); await proposalSubmissionPage.continueBtn.click(); - await expect(userPage.getByText(newTitle)).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.prop_abstract) - ).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.prop_motivation) - ).toBeVisible(); await expect( - userPage.getByText(proposalFormValue.prop_rationale) - ).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.prop_receiving_address) - ).toBeVisible(); - await expect( - userPage.getByText(proposalFormValue.prop_amount) - ).toBeVisible(); + userPage.getByTestId("governance-action-type-content") + ).toHaveText(ProposalType.treasury); + await expect(userPage.getByTestId("title-content")).toHaveText(newTitle); + await expect(userPage.getByTestId("abstract-content")).toHaveText( + proposalFormValue.prop_abstract + ); + await expect(userPage.getByTestId("motivation-content")).toHaveText( + proposalFormValue.prop_motivation + ); + await expect(userPage.getByTestId("rationale-content")).toHaveText( + proposalFormValue.prop_rationale + ); await expect( - userPage.getByText(proposalFormValue.proposal_links[0].prop_link_text) - ).toBeVisible(); + userPage.getByTestId("receiving-address-content") + ).toHaveText(proposalFormValue.prop_receiving_address); + await expect(userPage.getByTestId("amount-content")).toHaveText( + proposalFormValue.prop_amount + ); + await expect(userPage.getByTestId("link-text-content")).toHaveText( + proposalFormValue.proposal_links[0].prop_link_text + ); }); }); }); diff --git a/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.loggedin.spec.ts index d2a8d8fe8..5eda4f35d 100644 --- a/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.loggedin.spec.ts @@ -36,11 +36,11 @@ test.describe("Proposal created logged in state", () => { }) => { await proposalDiscussionDetailsPage.likeBtn.click(); await page.waitForTimeout(2_000); - await expect(page.getByText("10", { exact: true })).toBeVisible(); + await expect(proposalDiscussionDetailsPage.likeCount).toHaveText("1"); await proposalDiscussionDetailsPage.dislikeBtn.click(); await page.waitForTimeout(2_000); - await expect(page.getByText("01", { exact: true })).toBeVisible(); + await expect(proposalDiscussionDetailsPage.dislikeCount).toHaveText("1"); }); test("8J. Should sort the proposed governance action comments.", async ({ @@ -97,10 +97,14 @@ test.describe("Proposal created with poll enabled (user auth)", () => { await expect(proposalDiscussionDetailsPage.pollYesBtn).not.toBeVisible(); await expect(proposalDiscussionDetailsPage.pollNoBtn).not.toBeVisible(); - await expect(page.getByText(`${vote}: (100%)`)).toBeVisible(); + await expect( + page.getByTestId(`poll-${vote.toLowerCase()}-count`) + ).toHaveText(`${vote}: (100%)`); // opposite of random choice vote const oppositeVote = pollVotes[pollVotes.length - 1 - choice]; - await expect(page.getByText(`${oppositeVote}: (0%)`)).toBeVisible(); + await expect( + page.getByTestId(`poll-${oppositeVote.toLowerCase()}-count`) + ).toHaveText(`${oppositeVote}: (0%)`); }); test("8T. Should change vote on poll.", async ({ page }) => { @@ -111,18 +115,20 @@ test.describe("Proposal created with poll enabled (user auth)", () => { await proposalDiscussionDetailsPage.voteOnPoll(vote); await proposalDiscussionDetailsPage.changeVoteBtn.click(); - await page - .getByRole("button", { name: "Yes, change my Poll Vote" }) - .click(); + await page.getByTestId("change-poll-vote-yes-button").click(); await expect(proposalDiscussionDetailsPage.pollYesBtn).not.toBeVisible(); await expect(proposalDiscussionDetailsPage.pollNoBtn).not.toBeVisible(); // vote must be changed - await expect(page.getByText(`${vote}: (0%)`)).toBeVisible(); + await expect( + page.getByTestId(`poll-${vote.toLowerCase()}-count`) + ).not.toHaveText(`${vote}: (0%)`); // opposite of random choice vote const oppositeVote = pollVotes[pollVotes.length - 1 - choice]; - await expect(page.getByText(`${oppositeVote}: (100%)`)).toBeVisible(); + await expect( + page.getByTestId(`poll-${oppositeVote.toLowerCase()}-count`) + ).not.toHaveText(`${oppositeVote}: (100%)`); }); }); 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 c592ce381..4ef306784 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 @@ -109,7 +109,7 @@ test("8D.Should show the view-all categorized proposed governance actions.", asy const proposalCards = await proposalDiscussionPage.getAllProposals(); for (const proposalCard of proposalCards) { - await expect(proposalCard.getByText("Info", { exact: true })).toBeVisible(); + await expect(proposalCard.getByText("Info", { exact: true })).toBeVisible(); // BUG missing test id } }); @@ -172,9 +172,9 @@ test.describe("Mocked proposal", () => { }) => { await context.grantPermissions(["clipboard-read", "clipboard-write"]); - await page.locator("#share-button").click(); // BUG - await page.getByRole("button").click(); // BUG - await expect(page.getByText("Link copied")).toBeVisible(); // Bug + await page.getByTestId("share-button").click(); + await page.getByRole("button").click(); // BUG missing test id copy button + await expect(page.getByText("Link copied")).toBeVisible(); // BUG missing test id link copied text const copiedTextDRepDirectory = await page.evaluate(() => navigator.clipboard.readText()