From e4e2a99aeba6c352baa6d85c549ecc4483288716 Mon Sep 17 00:00:00 2001 From: Nabin Kawan Date: Fri, 31 May 2024 14:53:58 +0545 Subject: [PATCH 1/4] Align dRep directory tests with cardano-test-plans --- .../playwright/lib/pages/dRepDirectoryPage.ts | 11 +++- .../2-delegation/delegation.drep.spec.ts | 55 +++++++++++------ .../2-delegation/delegation.loggedin.spec.ts | 17 ------ .../tests/2-delegation/delegation.spec.ts | 4 +- ...delegationFunctionality.delegation.spec.ts | 60 ++++++++++++++++++- 5 files changed, 108 insertions(+), 39 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts index 4714b507d..395cb9128 100644 --- a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts @@ -119,7 +119,7 @@ export default class DRepDirectoryPage { } } getDRepCard(dRepId: string) { - return this.page.getByRole("list").getByTestId(`${dRepId}-copy-id-button`); + return this.page.getByTestId(`${dRepId}-drep-card`); } async getAllListedDRepIds() { @@ -130,4 +130,13 @@ export default class DRepDirectoryPage { .locator('[data-testid$="-copy-id-button"]') .all(); } + + async getAllListedDReps() { + await this.page.waitForTimeout(2_000); + + return await this.page + .getByRole("list") + .locator('[data-testid$="-drep-card"]') + .all(); + } } diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts index 47b2a446b..8b1eabf79 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts @@ -34,20 +34,6 @@ test("2C. Should open wallet connection popup on delegate in disconnected state" await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); }); -test("2L. Should copy DRepId", async ({ page, context }) => { - await context.grantPermissions(["clipboard-read", "clipboard-write"]); - - const dRepDirectory = new DRepDirectoryPage(page); - await dRepDirectory.goto(); - - await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId); - await page.getByTestId(`${dRep01Wallet.dRepId}-copy-id-button`).click(); - await expect(page.getByText("Copied to clipboard")).toBeVisible(); - - const copiedText = await page.evaluate(() => navigator.clipboard.readText()); - expect(copiedText).toEqual(dRep01Wallet.dRepId); -}); - test("2N. Should show DRep information on details page", async ({ page, browser, @@ -90,7 +76,9 @@ test("2N. Should show DRep information on details page", async ({ await dRepPage.getByTestId(`${wallet.dRepId}-view-details-button`).click(); // Verification - await expect(dRepPage.getByTestId("copy-drep-id-button")).toHaveText(wallet.dRepId); + await expect(dRepPage.getByTestId("copy-drep-id-button")).toHaveText( + wallet.dRepId + ); await expect(dRepPage.getByText("Active", { exact: true })).toBeVisible(); await expect(dRepPage.locator("dl").getByText("₳ 0")).toBeVisible(); await expect(dRepPage.getByText(email, { exact: true })).toBeVisible(); @@ -119,13 +107,18 @@ test("2P. Should enable sharing of DRep details", async ({ page, context }) => { test("2Q. Should include DRep status and voting power on the DRep card", async ({ page, }) => { - test.skip(); // Cannot access dRep card - const dRepDirectory = new DRepDirectoryPage(page); await dRepDirectory.goto(); + await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId); const dRepCard = dRepDirectory.getDRepCard(dRep01Wallet.dRepId); - await expect(dRepCard).toHaveText("20"); + + await expect( + dRepCard.getByTestId(`${dRep01Wallet.dRepId}-voting-power`) + ).toBeVisible(); + await expect( + dRepCard.getByTestId(`${dRep01Wallet.dRepId}-Active-pill`) + ).toBeVisible(); }); test.describe("Insufficient funds", () => { @@ -173,3 +166,29 @@ test("2J. Should search by DRep id", async ({ page }) => { dRep01Wallet.dRepId ); }); + +test("2D. Should show delegation options in connected state", async ({ + page, +}) => { + const dRepDirectoryPage = new DRepDirectoryPage(page); + await dRepDirectoryPage.goto(); + + // Verifying automatic delegation options + await dRepDirectoryPage.automaticDelegationOptionsDropdown.click(); + await expect(dRepDirectoryPage.abstainDelegationCard).toBeVisible(); + await expect(dRepDirectoryPage.signalNoConfidenceCard).toBeVisible(); + + expect(await dRepDirectoryPage.delegateBtns.count()).toBeGreaterThanOrEqual( + 2 + ); +}); + +test("2M. Should access dRep directory page on disconnected state", async ({ + page, +}) => { + const dRepDirectoryPage = new DRepDirectoryPage(page); + await dRepDirectoryPage.goto(); + + const dRepCards = await dRepDirectoryPage.getAllListedDReps(); + expect(dRepCards.length).toBeGreaterThan(1); +}); diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.loggedin.spec.ts index 04c34f1e5..d259065a9 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.loggedin.spec.ts @@ -2,7 +2,6 @@ import { user01Wallet } from "@constants/staticWallets"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { isMobile } from "@helpers/mobile"; -import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { expect } from "@playwright/test"; test.use({ storageState: ".auth/user01.json", wallet: user01Wallet }); @@ -23,19 +22,3 @@ test("2B. Should access DRep Directory page", async ({ page }) => { ).toBeVisible(); } }); - -test("2D. Should show delegation options in connected state", async ({ - page, -}) => { - const dRepDirectoryPage = new DRepDirectoryPage(page); - await dRepDirectoryPage.goto(); - - // Verifying automatic delegation options - await dRepDirectoryPage.automaticDelegationOptionsDropdown.click(); - await expect(dRepDirectoryPage.abstainDelegationCard).toBeVisible(); - await expect(dRepDirectoryPage.signalNoConfidenceCard).toBeVisible(); - - expect(await dRepDirectoryPage.delegateBtns.count()).toBeGreaterThanOrEqual( - 2 - ); -}); diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts index 6850072df..d11b21ec0 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -7,7 +7,7 @@ test.beforeEach(async () => { await setAllureEpic("2. Delegation"); }); -test("2M. Should sort DReps", async ({ page }) => { +test("2K_2. Should sort DReps", async ({ page }) => { test.slow(); enum SortOption { @@ -55,7 +55,7 @@ test("2O. Should load more DReps on show more", async ({ page }) => { } }); -test("2K. Should filter DReps", async ({ page }) => { +test("2K_1. Should filter DReps", async ({ page }) => { const dRepFilterOptions: DRepStatus[] = ["Active", "Inactive", "Retired"]; const dRepDirectory = new DRepDirectoryPage(page); diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts index 7dbe92672..20b2ef766 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts @@ -29,6 +29,8 @@ test.describe("Delegate to others", () => { wallet: adaHolder01Wallet, }); + test.describe.configure({ mode: "serial" }); + test("2A. Should show delegated DRep Id (on Dashboard, and DRep Directory) after delegation", async ({ page, }, testInfo) => { @@ -53,6 +55,32 @@ test.describe("Delegate to others", () => { await page.goto("/dashboard"); await expect(page.getByText(dRepId)).toBeVisible(); }); + + test("2H. Should prompt to change delegation after delegation", async ({ + page, + }) => { + await page.goto("/"); + + await expect( + page.getByTestId("delegate-to-another-drep-button") + ).toBeVisible(); + }); + + test("2L. Should copy delegated DRepId", async ({ page, context }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + + const dRepDirectory = new DRepDirectoryPage(page); + await dRepDirectory.goto(); + + await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId); + await page.getByTestId(`${dRep01Wallet.dRepId}-copy-id-button`).click(); + await expect(page.getByText("Copied to clipboard")).toBeVisible(); + + const copiedTextDRepDirectory = await page.evaluate(() => + navigator.clipboard.readText() + ); + expect(copiedTextDRepDirectory).toEqual(dRep01Wallet.dRepId); + }); }); test.describe("Change delegation", () => { @@ -83,7 +111,7 @@ test.describe("Change delegation", () => { }); }); -test.describe("Delegate to myself", () => { +test.describe("Register DRep state", () => { let dRepPage: Page; let wallet: StaticWallet; @@ -103,6 +131,7 @@ test.describe("Delegate to myself", () => { test("2E. Should register as Sole voter", async ({}, testInfo) => { test.setTimeout(testInfo.timeout + environments.txTimeOut); + const wallet = await walletManager.popWallet("registeredDRep"); const dRepId = wallet.dRepId; await dRepPage.goto("/"); @@ -155,6 +184,35 @@ test.describe("Delegate to myself", () => { }); }); +test("2G. Should delegate to myself", async ({ page, browser }, testInfo) => { + test.setTimeout(testInfo.timeout + environments.txTimeOut); + + const wallet = await walletManager.popWallet("registeredDRep"); + const dRepId = wallet.dRepId; + + const dRepAuth = await createTempDRepAuth(page, wallet); + const dRepPage = await createNewPageWithWallet(browser, { + storageState: dRepAuth, + wallet, + enableStakeSigning: true, + }); + + const dRepDirectoryPage = new DRepDirectoryPage(dRepPage); + await dRepDirectoryPage.goto(); + + await dRepDirectoryPage.delegateToDRep(dRepId); + + await expect( + dRepPage.getByTestId(`${dRepId}-delegate-button')`) + ).not.toBeVisible(); + await expect(dRepPage.getByTestId(`${dRepId}-copy-id-button`)).toHaveCount( + 1, + { + timeout: 20_000, + } + ); +}); + test.describe("Multiple delegations", () => { test.use({ storageState: ".auth/adaHolder05.json", From b74a075c7ad3f8449a1679acd1674143769bc53a Mon Sep 17 00:00:00 2001 From: niraj Date: Fri, 31 May 2024 15:58:47 +0545 Subject: [PATCH 2/4] Align drepRegistration and governance action tests with cardano-test-plans --- .../playwright/global-setup.ts | 16 ++-- .../lib/pages/governanceActionsPage.ts | 1 + .../dRepRegistration.dRep.spec.ts | 25 ++++-- .../dRepRegistration.loggedin.spec.ts | 76 ++++++++++--------- .../proposalVisibility.dRep.spec.ts | 42 +++++++++- .../proposalFunctionality.dRep.spec.ts | 59 ++++++++------ 6 files changed, 143 insertions(+), 76 deletions(-) diff --git a/tests/govtool-frontend/playwright/global-setup.ts b/tests/govtool-frontend/playwright/global-setup.ts index d08dc0bfd..b45c1ecec 100644 --- a/tests/govtool-frontend/playwright/global-setup.ts +++ b/tests/govtool-frontend/playwright/global-setup.ts @@ -5,6 +5,9 @@ import { loadAmountFromFaucet } from "@services/faucetService"; import kuberService from "@services/kuberService"; import walletManager from "lib/walletManager"; +const REGISTER_DREP_WALLETS = 9; +const DREP_WALLETS = 9; + async function generateWallets(num: number) { return await Promise.all( Array.from({ length: num }, () => @@ -14,8 +17,8 @@ async function generateWallets(num: number) { } async function globalSetup() { - const registeredDRepWallets = await generateWallets(9); - const registerDRepWallets = await generateWallets(9); + const dRepWallets = await generateWallets(DREP_WALLETS); + const registerDRepWallets = await generateWallets(REGISTER_DREP_WALLETS); // faucet setup const res = await loadAmountFromFaucet(faucetWallet.address); @@ -23,15 +26,14 @@ async function globalSetup() { // initialize wallets const initializeRes = await kuberService.initializeWallets([ - ...registeredDRepWallets, + ...dRepWallets, ...registerDRepWallets, ]); await pollTransaction(initializeRes.txId, initializeRes.lockInfo); // register dRep - const registrationRes = await kuberService.multipleDRepRegistration( - registeredDRepWallets - ); + const registrationRes = + await kuberService.multipleDRepRegistration(dRepWallets); await pollTransaction(registrationRes.txId, registrationRes.lockInfo); // transfer 600 ADA for dRep registration @@ -42,7 +44,7 @@ async function globalSetup() { await pollTransaction(transferRes.txId, transferRes.lockInfo); // save to file - await walletManager.writeWallets(registeredDRepWallets, "registeredDRep"); + await walletManager.writeWallets(dRepWallets, "registeredDRep"); await walletManager.writeWallets(registerDRepWallets, "registerDRep"); } diff --git a/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts b/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts index 159b1545f..98680483f 100644 --- a/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts @@ -8,6 +8,7 @@ export default class GovernanceActionsPage { readonly filterBtn = this.page.getByTestId("filters-button"); readonly sortBtn = this.page.getByTestId("sort-button"); readonly votedTab = this.page.getByTestId("voted-tab"); + readonly searchInput = this.page.getByTestId("search-input"); constructor(private readonly page: Page) {} 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 d42a722a5..4d76f072b 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 @@ -24,9 +24,20 @@ test.describe("Logged in DReps", () => { page, }) => { await page.goto("/"); + + await expect(page.getByTestId("voting-power-chips")).toBeVisible(); + await expect(page.getByTestId("dRep-id-display")).toContainText( dRep01Wallet.dRepId ); // BUG: testId -> dRep-id-display-dashboard (It is taking sidebar dRep-id) + + await page.goto(`${environments.frontendUrl}/governance_actions`); + await page + .locator('[data-testid^="govaction-"][data-testid$="-view-detail"]') + .first() + .click(); + + await expect(page.getByTestId("vote-button")).toBeVisible(); }); test("3H. Should Update DRep data", async ({ page }, testInfo) => { @@ -84,7 +95,7 @@ test.describe("Temporary DReps", () => { ).toBeVisible(); }); - test("3I. Should verify retire as DRep", async ({ page, browser }) => { + test("3J. Should verify retire as DRep", async ({ page, browser }) => { const wallet = await walletManager.popWallet("registeredDRep"); const tempDRepAuth = await createTempDRepAuth(page, wallet); @@ -99,11 +110,11 @@ test.describe("Temporary DReps", () => { await dRepPage.getByTestId("continue-retirement-button").click(); await expect( - dRepPage.getByTestId("retirement-transaction-error-modal") + dRepPage.getByTestId("retirement-transaction-submitted-modal") ).toBeVisible(); }); - test("3J. Verify DRep behavior in retired state", async ({ + test("3K. Verify DRep behavior in retired state", async ({ page, browser, }, testInfo) => { @@ -125,8 +136,12 @@ test.describe("Temporary DReps", () => { dRepPage.getByTestId("retirement-transaction-submitted-modal") ).toBeVisible(); dRepPage.getByTestId("confirm-modal-button").click(); + await waitForTxConfirmation(dRepPage); - await expect(dRepPage.getByText("Voting power:₳")).not.toBeVisible(); + + await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible(); + + await expect(dRepPage.getByTestId("dRep-id-display")).not.toBeVisible(); const governanceActionsPage = new GovernanceActionsPage(dRepPage); await governanceActionsPage.goto(); @@ -135,7 +150,7 @@ test.describe("Temporary DReps", () => { await expect(govActionDetailsPage.voteBtn).not.toBeVisible(); }); - test("3K. Should display 'In Progress' status on dashboard until blockchain confirms DRep registration", async ({ + test("3I. Should display 'In Progress' status on dashboard until blockchain confirms DRep registration", async ({ page, browser, }, testInfo) => { diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts index 8b85c0943..94ab385ac 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts @@ -34,43 +34,45 @@ test("3D. Verify DRep registration form", async ({ page }) => { await expect(dRepRegistrationPage.continueBtn).toBeVisible(); }); -test("3E. Should accept valid data in DRep form", async ({ page }) => { - test.slow(); - - const dRepRegistrationPage = new DRepRegistrationPage(page); - await dRepRegistrationPage.goto(); - - for (let i = 0; i < 100; i++) { - await dRepRegistrationPage.validateForm( - faker.internet.displayName(), - faker.internet.email(), - faker.lorem.paragraph(), - faker.internet.url() - ); - } - - for (let i = 0; i < 6; i++) { - await expect(dRepRegistrationPage.addLinkBtn).toBeVisible(); - await dRepRegistrationPage.addLinkBtn.click(); - } - - await expect(dRepRegistrationPage.addLinkBtn).toBeHidden(); -}); - -test("3L. Should reject invalid data in DRep form", async ({ page }) => { - test.slow(); - - const dRepRegistrationPage = new DRepRegistrationPage(page); - await dRepRegistrationPage.goto(); - - for (let i = 0; i < 100; i++) { - await dRepRegistrationPage.inValidateForm( - mockInvalid.name(), - mockInvalid.email(), - faker.lorem.paragraph(40), - mockInvalid.url() - ); - } +test.describe("Validation of dRep Registration Form", () => { + test("3E.1 Should accept valid data in DRep form", async ({ page }) => { + test.slow(); + + const dRepRegistrationPage = new DRepRegistrationPage(page); + await dRepRegistrationPage.goto(); + + for (let i = 0; i < 100; i++) { + await dRepRegistrationPage.validateForm( + faker.internet.displayName(), + faker.internet.email(), + faker.lorem.paragraph(), + faker.internet.url() + ); + } + + for (let i = 0; i < 6; i++) { + await expect(dRepRegistrationPage.addLinkBtn).toBeVisible(); + await dRepRegistrationPage.addLinkBtn.click(); + } + + await expect(dRepRegistrationPage.addLinkBtn).toBeHidden(); + }); + + test("3E.2. Should reject invalid data in DRep form", async ({ page }) => { + test.slow(); + + const dRepRegistrationPage = new DRepRegistrationPage(page); + await dRepRegistrationPage.goto(); + + for (let i = 0; i < 100; i++) { + await dRepRegistrationPage.inValidateForm( + mockInvalid.name(), + mockInvalid.email(), + faker.lorem.paragraph(40), + mockInvalid.url() + ); + } + }); }); test("3F. Should create proper DRep registration request, when registered with data", async ({ 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 f58843ab8..501c0b1ce 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 @@ -1,3 +1,4 @@ +import environments from "@constants/environments"; import { dRep01Wallet } from "@constants/staticWallets"; import { createTempDRepAuth } from "@datafactory/createAuth"; import { faker } from "@faker-js/faker"; @@ -5,6 +6,7 @@ import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { lovelaceToAda } from "@helpers/cardano"; import { createNewPageWithWallet } from "@helpers/page"; +import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage"; import GovernanceActionsPage from "@pages/governanceActionsPage"; import { Page, expect } from "@playwright/test"; import { FilterOption, IProposal } from "@types"; @@ -27,9 +29,9 @@ test.describe("Logged in DRep", () => { const res = await votingPowerPromise; const votingPower = await res.json(); - await expect( - page.getByText(`₳ ${lovelaceToAda(votingPower)}`) - ).toBeVisible(); + await expect(page.getByTestId("voting-power-chips-value")).toHaveText( + `₳ ${lovelaceToAda(votingPower)}` + ); }); }); @@ -48,16 +50,48 @@ test.describe("Temporary DReps", async () => { }); }); - test("4J. Should include metadata anchor in the vote transaction", async () => { + test("4J. Should include metadata anchor in the vote transaction", async ({}, testInfo) => { + test.setTimeout(testInfo.timeout + environments.txTimeOut); + const govActionsPage = new GovernanceActionsPage(dRepPage); await govActionsPage.goto(); const govActionDetailsPage = await govActionsPage.viewFirstProposal(); await govActionDetailsPage.vote(faker.lorem.sentence(200)); + await govActionsPage.votedTab.click(); await govActionsPage.viewFirstVotedProposal(); expect(false, "No vote context displayed").toBe(true); }); + + test("4I. Should display the recent vote on same sameshot", async ({ + context, + }, testInfo) => { + test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut); + + const govActionsPage = new GovernanceActionsPage(dRepPage); + await govActionsPage.goto(); + + const govActionDetailsPage = await govActionsPage.viewFirstProposal(); + const urlList = dRepPage.url().split("/"); + const governanceActionId = urlList[urlList.length - 1]; + await govActionDetailsPage.vote(); + + await govActionsPage.votedTab.click(); + + await govActionsPage.searchInput.fill(governanceActionId); + + await dRepPage + .getByTestId(`govaction-${governanceActionId}-change-your-vote`) + .click(); + const votedActionDetailsPage = new GovernanceActionDetailsPage(dRepPage); + await votedActionDetailsPage.noVoteRadio.click(); + await votedActionDetailsPage.changeVoteBtn.click(); + + await govActionsPage.searchInput.fill(governanceActionId); + + await expect(dRepPage.getByTestId("my-vote").getByText("No")).toBeVisible(); + }); }); test.describe("Check vote count", () => { diff --git a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts index 262321a72..b150c807b 100644 --- a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts @@ -7,7 +7,7 @@ import { createNewPageWithWallet } from "@helpers/page"; import { waitForTxConfirmation } from "@helpers/transaction"; import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage"; import GovernanceActionsPage from "@pages/governanceActionsPage"; -import { expect } from "@playwright/test"; +import { Page, expect } from "@playwright/test"; import kuberService from "@services/kuberService"; import walletManager from "lib/walletManager"; @@ -32,8 +32,8 @@ test.describe("Proposal checks", () => { await expect(govActionDetailsPage.submittedDate).toBeVisible(); await expect(govActionDetailsPage.expiryDate).toBeVisible(); - await expect(govActionDetailsPage.externalModalBtn).toBeVisible(); await expect(govActionDetailsPage.contextBtn).toBeVisible(); + await expect(govActionDetailsPage.showVotesBtn).toBeVisible(); await expect(govActionDetailsPage.voteBtn).toBeVisible(); await expect(govActionDetailsPage.yesVoteRadio).toBeVisible(); @@ -41,9 +41,9 @@ test.describe("Proposal checks", () => { await expect(govActionDetailsPage.abstainRadio).toBeVisible(); }); - test("5B. Should view Vote button on governance action item on registered as DRep", async () => { - await expect(govActionDetailsPage.voteBtn).toBeVisible(); - }); + // test("5B. Should view Vote button on governance action item on registered as DRep", async () => { + // await expect(govActionDetailsPage.voteBtn).toBeVisible(); + // }); test("5C. Should show required field in proposal voting on registered as DRep", async () => { await expect(govActionDetailsPage.voteBtn).toBeVisible(); @@ -86,37 +86,46 @@ test.describe("Proposal checks", () => { // await expect(govActionDetailsPage.hashInputError).not.toBeVisible(); }); - test("5G. Should show warning to the users to visit the site at their own risk, when external url is opened", async () => { - await govActionDetailsPage.externalModalBtn.click(); - - await expect(govActionDetailsPage.externalLinkModal).toBeVisible(); - await expect( - govActionDetailsPage.currentPage.getByText("Be careful", { - exact: false, - }) - ).toBeVisible(); + test("5G. Should show warning in bad governance action proposal to the users to visit the site at their own risk, when external url is opened", async () => { + if (await govActionDetailsPage.externalModalBtn.isVisible()) { + await govActionDetailsPage.externalModalBtn.click(); + + await expect(govActionDetailsPage.externalLinkModal).toBeVisible(); + await expect( + govActionDetailsPage.currentPage.getByText("Be careful", { + exact: false, + }) + ).toBeVisible(); + } else { + expect(true, "Is not a bad or data missing proposal").toBeTruthy(); + } }); - test("5H. Should open a new tab, when external URL is opened", async ({ + test("5H. Should open a new tab in Bad governance action proposal, when external URL is opened", async ({ page, }) => { - await govActionDetailsPage.externalModalBtn.click(); - await govActionDetailsPage.continueModalBtn.click(); - - const existingPages = page.context().pages(); - expect(existingPages).toHaveLength(1); + if (await govActionDetailsPage.externalModalBtn.isVisible()) { + await govActionDetailsPage.externalModalBtn.click(); + await govActionDetailsPage.continueModalBtn.click(); + + const existingPages = page.context().pages(); + expect(existingPages).toHaveLength(1); + } else { + expect(true, "Is not a bad or data missing proposal").toBeTruthy(); + } }); }); test.describe("Perform voting", () => { let govActionDetailsPage: GovernanceActionDetailsPage; + let dRepPage: Page; test.beforeEach(async ({ page, browser }) => { const wallet = await walletManager.popWallet("registeredDRep"); const tempDRepAuth = await createTempDRepAuth(page, wallet); - const dRepPage = await createNewPageWithWallet(browser, { + dRepPage = await createNewPageWithWallet(browser, { storageState: tempDRepAuth, wallet, enableStakeSigning: true, @@ -138,6 +147,7 @@ test.describe("Perform voting", () => { govActionDetailsPage.currentPage ); await governanceActionsPage.goto(); + await dRepPage.waitForTimeout(5_000); await governanceActionsPage.votedTab.click(); await expect( govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("Yes") @@ -148,12 +158,14 @@ test.describe("Perform voting", () => { await waitForTxConfirmation(govActionDetailsPage.currentPage); await governanceActionsPage.votedTab.click(); + await expect( govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("No") - ).toBeVisible(); + ).toBeVisible({ timeout: 20_000 }); }); - test("5F. Should show notification of casted vote after vote", async ({}) => { + test("5F. Should show notification of casted vote after vote", async ({}, testInfo) => { + test.setTimeout(testInfo.timeout + environments.txTimeOut); await govActionDetailsPage.vote(); await expect(govActionDetailsPage.voteSuccessModal).toBeVisible(); }); @@ -168,6 +180,7 @@ test.describe("Perform voting", () => { govActionDetailsPage.currentPage ); await governanceActionsPage.goto(); + await dRepPage.waitForTimeout(5_000); await governanceActionsPage.votedTab.click(); await expect( govActionDetailsPage.currentPage.getByTestId("my-vote").getByText("Yes") From aa7dccdfeaa8b821ab7d839c6367665a6feb80d6 Mon Sep 17 00:00:00 2001 From: Nabin Kawan Date: Wed, 5 Jun 2024 11:04:27 +0545 Subject: [PATCH 3/4] chore: Skip test 4J, and Rename 4D to 4C.3 --- .../4-proposal-visibility/proposalVisibility.dRep.spec.ts | 2 ++ .../proposalVisibility.loggedin.spec.ts | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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 501c0b1ce..a07889e1c 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 @@ -51,6 +51,8 @@ test.describe("Temporary DReps", async () => { }); test("4J. Should include metadata anchor in the vote transaction", async ({}, testInfo) => { + test.skip(); // Skipped: Vote context is not displayed in UI to validate + test.setTimeout(testInfo.timeout + environments.txTimeOut); const govActionsPage = new GovernanceActionsPage(dRepPage); diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.loggedin.spec.ts index a2e109869..3ab84ee79 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.loggedin.spec.ts @@ -104,7 +104,7 @@ test("4C.2: Should sort Governance Action Type on governance actions page", asyn ); }); -test("4D: Should filter and sort Governance Action Type on governance actions page", async ({ +test("4C.3: Should filter and sort Governance Action Type on governance actions page", async ({ page, }) => { test.slow(); @@ -113,7 +113,9 @@ test("4D: Should filter and sort Governance Action Type on governance actions pa await govActionsPage.goto(); await govActionsPage.filterBtn.click(); - govActionsPage.filterProposalByNames([filterOptionNames[0]]); + + const choice = Math.floor(Math.random() * filterOptionNames.length); + await govActionsPage.filterProposalByNames([filterOptionNames[choice]]); await govActionsPage.sortBtn.click(); await govActionsPage.sortAndValidate( From eeb2244631ed350efe1df5184c30a3e0525d9abd Mon Sep 17 00:00:00 2001 From: Nabin Kawan Date: Wed, 5 Jun 2024 11:21:42 +0545 Subject: [PATCH 4/4] chore: Fix typo and Rename variables --- tests/govtool-frontend/playwright/global-setup.ts | 10 ++++++---- .../proposalVisibility.dRep.spec.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/govtool-frontend/playwright/global-setup.ts b/tests/govtool-frontend/playwright/global-setup.ts index b45c1ecec..de6657e48 100644 --- a/tests/govtool-frontend/playwright/global-setup.ts +++ b/tests/govtool-frontend/playwright/global-setup.ts @@ -5,8 +5,8 @@ import { loadAmountFromFaucet } from "@services/faucetService"; import kuberService from "@services/kuberService"; import walletManager from "lib/walletManager"; -const REGISTER_DREP_WALLETS = 9; -const DREP_WALLETS = 9; +const REGISTER_DREP_WALLETS_COUNT = 9; +const DREP_WALLETS_COUNT = 9; async function generateWallets(num: number) { return await Promise.all( @@ -17,8 +17,10 @@ async function generateWallets(num: number) { } async function globalSetup() { - const dRepWallets = await generateWallets(DREP_WALLETS); - const registerDRepWallets = await generateWallets(REGISTER_DREP_WALLETS); + const dRepWallets = await generateWallets(DREP_WALLETS_COUNT); + const registerDRepWallets = await generateWallets( + REGISTER_DREP_WALLETS_COUNT + ); // faucet setup const res = await loadAmountFromFaucet(faucetWallet.address); 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 a07889e1c..5a286c624 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 @@ -66,7 +66,7 @@ test.describe("Temporary DReps", async () => { expect(false, "No vote context displayed").toBe(true); }); - test("4I. Should display the recent vote on same sameshot", async ({ + test("4I. Should display the recent vote on same snapshot", async ({ context, }, testInfo) => { test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut);