From 6ee05fde091a8d9d8b4c6f4cb9e31916e4a20f62 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 18 Dec 2024 16:40:18 +0545 Subject: [PATCH 01/18] chore: add utility to fetch first active dRep from directory --- .../playwright/lib/helpers/dRep.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/govtool-frontend/playwright/lib/helpers/dRep.ts diff --git a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts new file mode 100644 index 000000000..5d7e3eff7 --- /dev/null +++ b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts @@ -0,0 +1,39 @@ +import DRepDirectoryPage from "@pages/dRepDirectoryPage"; +import { Page } from "@playwright/test"; + +export async function fetchFirstActiveDRepDetails(page: Page) { + let dRepGivenName: string; + let dRepId: string; + let dRepDirectoryPage: DRepDirectoryPage; + await page.route( + "**/drep/list?page=0&pageSize=10&sort=Random", + async (route) => { + const response = await route.fetch(); + const json = await response.json(); + const elements = json["elements"].filter( + (element) => element["givenName"] != null + ); + dRepGivenName = + elements[Math.floor(Math.random() * elements.length)]["givenName"]; + dRepId = json["elements"][0]["view"]; + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify(json), + }); + } + ); + + const responsePromise = page.waitForResponse( + "**/drep/list?page=0&pageSize=10&sort=Random" + ); + + dRepDirectoryPage = new DRepDirectoryPage(page); + await dRepDirectoryPage.goto(); + await dRepDirectoryPage.filterBtn.click(); + await page.getByTestId("Active-checkbox").click(); + await dRepDirectoryPage.searchInput.click(); + + await responsePromise; + return { dRepGivenName, dRepId, dRepDirectoryPage }; +} From 6d2ffe4300132405d962607ad9706ffb20a33c4d Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 18 Dec 2024 16:43:37 +0545 Subject: [PATCH 02/18] refactor(tests): streamline delegation tests and remove redundant cases --- .../2-delegation/delegation.drep.spec.ts | 142 ------------------ .../2-delegation/delegation.loggedin.spec.ts | 54 +++++++ .../tests/2-delegation/delegation.spec.ts | 64 ++++++++ 3 files changed, 118 insertions(+), 142 deletions(-) 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 c6ecf9c49..1c6561e29 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 @@ -1,16 +1,11 @@ import environments from "@constants/environments"; -import { dRep01Wallet, user01Wallet } from "@constants/staticWallets"; import { createTempDRepAuth } from "@datafactory/createAuth"; import { faker } from "@faker-js/faker"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { skipIfNotHardFork } from "@helpers/cardano"; import { ShelleyWallet } from "@helpers/crypto"; -import { isMobile, openDrawer } from "@helpers/mobile"; import { createNewPageWithWallet } from "@helpers/page"; -import extractDRepFromWallet from "@helpers/shellyWallet"; -import DRepDetailsPage from "@pages/dRepDetailsPage"; -import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import DRepRegistrationPage from "@pages/dRepRegistrationPage"; import { expect } from "@playwright/test"; import { LinkType } from "@types"; @@ -21,22 +16,6 @@ test.beforeEach(async () => { await skipIfNotHardFork(); }); -test("2C. Should open wallet connection popup on delegate in disconnected state", async ({ - page, -}) => { - await page.goto("/"); - if (isMobile(page)) { - openDrawer(page); - } - - await page.getByTestId("view-drep-directory-button").click(); - await page.getByTestId("search-input").fill(dRep01Wallet.dRepId); - await page - .getByTestId(`${dRep01Wallet.dRepId}-connect-to-delegate-button`) - .click(); - await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); -}); - test("2N. Should show DRep information on details page", async ({ page, browser, @@ -124,124 +103,3 @@ test("2N. Should show DRep information on details page", async ({ ).toHaveText(link.url); } }); - -test("2P. Should enable sharing of DRep details", async ({ page, context }) => { - await context.grantPermissions(["clipboard-read", "clipboard-write"]); - - const dRepDetailsPage = new DRepDetailsPage(page); - await dRepDetailsPage.goto(dRep01Wallet.dRepId); - - await dRepDetailsPage.shareLink(); - await expect(page.getByText("Copied to clipboard")).toBeVisible(); - - const copiedText = await page.evaluate(() => navigator.clipboard.readText()); - expect(copiedText).toEqual( - `${environments.frontendUrl}/drep_directory/${dRep01Wallet.dRepId}` - ); -}); - -test("2Q. Should include DRep status and voting power on the DRep card", async ({ - page, -}) => { - const dRepDirectory = new DRepDirectoryPage(page); - await dRepDirectory.goto(); - - await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId); - const dRepCard = dRepDirectory.getDRepCard(dRep01Wallet.dRepId); - - await expect( - dRepCard.getByTestId(`${dRep01Wallet.dRepId}-voting-power`) - ).toBeVisible(); - await expect( - dRepCard.getByTestId(`${dRep01Wallet.dRepId}-Active-pill`) - ).toBeVisible(); -}); - -test.describe("Insufficient funds", () => { - test.use({ storageState: ".auth/user01.json", wallet: user01Wallet }); - - test("2T. Should show warning message on delegation when insufficient funds", async ({ - page, - }) => { - const dRepDirectoryPage = new DRepDirectoryPage(page); - await dRepDirectoryPage.goto(); - - await dRepDirectoryPage.searchInput.fill(dRep01Wallet.dRepId); - const delegateBtn = page.getByTestId( - `${dRep01Wallet.dRepId}-delegate-button` - ); - await expect(delegateBtn).toBeVisible(); - await page.getByTestId(`${dRep01Wallet.dRepId}-delegate-button`).click(); - - await expect(dRepDirectoryPage.delegationErrorModal).toBeVisible({ - timeout: 10_000, - }); - }); -}); - -test("2I. Should check validity of DRep Id", async ({ page }) => { - const dRepDirectory = new DRepDirectoryPage(page); - await dRepDirectory.goto(); - - await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId); - await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toBeVisible(); - - const wallet = await ShelleyWallet.generate(); - const invalidDRepId = extractDRepFromWallet(wallet); - - await dRepDirectory.searchInput.fill(invalidDRepId); - await expect(dRepDirectory.getDRepCard(invalidDRepId)).not.toBeVisible(); -}); - -test("2J. Should search by DRep id and DRep givenname", async ({ page }) => { - let dRepGivenName = "test"; - - await page.route( - "**/drep/list?page=0&pageSize=10&sort=Random", - async (route) => { - const response = await route.fetch(); - const json = await response.json(); - const elements = json["elements"].filter( - (element) => element["givenName"] != null - ); - dRepGivenName = - elements[Math.floor(Math.random() * elements.length)]["givenName"]; - await route.fulfill({ - status: 200, - contentType: "application/json", - body: JSON.stringify(json), - }); - } - ); - - const responsePromise = page.waitForResponse( - "**/drep/list?page=0&pageSize=10&sort=Random" - ); - - const dRepDirectory = new DRepDirectoryPage(page); - await dRepDirectory.goto(); - - await responsePromise; - - // search by dRep Id - await dRepDirectory.searchInput.fill(dRep01Wallet.dRepId); - await expect(dRepDirectory.getDRepCard(dRep01Wallet.dRepId)).toBeVisible(); - - // search by dRep givenname - await dRepDirectory.searchInput.fill(dRepGivenName); - const searchDRepCards = await dRepDirectory.getAllListedDReps(); - - for (const dRepCard of searchDRepCards) { - expect((await dRepCard.innerText()).includes(dRepGivenName)); - } -}); - -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 4a9081968..44e447a6e 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,10 @@ import { user01Wallet } from "@constants/staticWallets"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { skipIfNotHardFork } from "@helpers/cardano"; +import { ShelleyWallet } from "@helpers/crypto"; +import { fetchFirstActiveDRepDetails } from "@helpers/dRep"; import { isMobile } from "@helpers/mobile"; +import extractDRepFromWallet from "@helpers/shellyWallet"; import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { expect } from "@playwright/test"; @@ -71,3 +74,54 @@ test("2X_2. Should include info button and voting power on the Signal-No-Confide await expect(dRepDirectoryPage.signalNoConfidenceInfoButton).toBeVisible(); }); + +test.describe("DRep dependent tests", () => { + let dRepGivenName = "test"; + let dRepId = "drep1ef7uslcjhjqrn4vv2y39c3yn345gzjsg7yufn76zye3v6fkz23q"; + let dRepDirectoryPage: DRepDirectoryPage; + + test.beforeEach(async ({ page }) => { + ({ dRepDirectoryPage, dRepId, dRepGivenName } = + await fetchFirstActiveDRepDetails(page)); + }); + + test("2T. Should show warning message on delegation when insufficient funds", async ({ + page, + }) => { + await dRepDirectoryPage.searchInput.fill(dRepId); + const delegateBtn = page.getByTestId(`${dRepId}-delegate-button`); + await expect(delegateBtn).toBeVisible(); + await page.getByTestId(`${dRepId}-delegate-button`).click(); + + await expect(dRepDirectoryPage.delegationErrorModal).toBeVisible({ + timeout: 10_000, + }); + }); + + test("2I. Should check validity of DRep Id", async () => { + await dRepDirectoryPage.searchInput.fill(dRepId); + await expect(dRepDirectoryPage.getDRepCard(dRepId)).toBeVisible(); + + const wallet = await ShelleyWallet.generate(); + const invalidDRepId = extractDRepFromWallet(wallet); + + await dRepDirectoryPage.searchInput.fill(invalidDRepId); + await expect( + dRepDirectoryPage.getDRepCard(invalidDRepId) + ).not.toBeVisible(); + }); + + test("2J. Should search by DRep id and DRep givenname", async () => { + // search by dRep Id + await dRepDirectoryPage.searchInput.fill(dRepId); + await expect(dRepDirectoryPage.getDRepCard(dRepId)).toBeVisible(); + + // search by dRep givenname + await dRepDirectoryPage.searchInput.fill(dRepGivenName); + const searchDRepCards = await dRepDirectoryPage.getAllListedDReps(); + + for (const dRepCard of searchDRepCards) { + expect((await dRepCard.innerText()).includes(dRepGivenName)); + } + }); +}); 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 980081980..729740620 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -1,5 +1,8 @@ +import environments from "@constants/environments"; import { setAllureEpic } from "@helpers/allure"; import { skipIfNotHardFork } from "@helpers/cardano"; +import { fetchFirstActiveDRepDetails } from "@helpers/dRep"; +import DRepDetailsPage from "@pages/dRepDetailsPage"; import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { expect, test } from "@playwright/test"; import { DRepStatus, IDRep } from "@types"; @@ -122,3 +125,64 @@ test("2K_1. Should filter DReps", async ({ page }) => { multipleFilterOptionNames.pop(); } }); + +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); +}); + +test.describe("DRep dependent tests", () => { + let dRepGivenName = "test"; + let dRepId = "drep1ef7uslcjhjqrn4vv2y39c3yn345gzjsg7yufn76zye3v6fkz23q"; + let dRepDirectoryPage: DRepDirectoryPage; + + test.beforeEach(async ({ page }) => { + ({ dRepDirectoryPage, dRepId, dRepGivenName } = + await fetchFirstActiveDRepDetails(page)); + }); + + test("2P. Should enable sharing of DRep details", async ({ + page, + context, + }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + + const dRepDetailsPage = new DRepDetailsPage(page); + await dRepDetailsPage.goto(dRepId); + + await dRepDetailsPage.shareLink(); + await expect(page.getByText("Copied to clipboard")).toBeVisible(); + + const copiedText = await page.evaluate(() => + navigator.clipboard.readText() + ); + expect(copiedText).toEqual( + `${environments.frontendUrl}/drep_directory/${dRepId}` + ); + }); + + test("2Q. Should include DRep status and voting power on the DRep card", async ({ + page, + }) => { + await dRepDirectoryPage.searchInput.fill(dRepId); + const dRepCard = dRepDirectoryPage.getDRepCard(dRepId); + + await expect(dRepCard.getByTestId(`${dRepId}-voting-power`)).toBeVisible(); + await expect( + dRepCard.locator(`[data-testid^="${dRepId}-"][data-testid$="-pill"]`) + ).toBeVisible(); + }); + + test("2C. Should open wallet connection popup on delegate in disconnected state", async ({ + page, + }) => { + await page.getByTestId("search-input").fill(dRepId); + await page.getByTestId(`${dRepId}-connect-to-delegate-button`).click(); + await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); + }); +}); From 16a56a9b0f00249049efb7fc41b78acab9166459 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 18 Dec 2024 20:03:11 +0545 Subject: [PATCH 03/18] fix: enhance dRep fetch logic for dynamic queries --- tests/govtool-frontend/playwright/lib/helpers/dRep.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts index 5d7e3eff7..33b6b1823 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts @@ -6,7 +6,7 @@ export async function fetchFirstActiveDRepDetails(page: Page) { let dRepId: string; let dRepDirectoryPage: DRepDirectoryPage; await page.route( - "**/drep/list?page=0&pageSize=10&sort=Random", + "**/drep/list?page=0&pageSize=10&sort=Random&**", async (route) => { const response = await route.fetch(); const json = await response.json(); @@ -25,15 +25,15 @@ export async function fetchFirstActiveDRepDetails(page: Page) { ); const responsePromise = page.waitForResponse( - "**/drep/list?page=0&pageSize=10&sort=Random" + "**/drep/list?page=0&pageSize=10&sort=Random&**" ); dRepDirectoryPage = new DRepDirectoryPage(page); await dRepDirectoryPage.goto(); await dRepDirectoryPage.filterBtn.click(); await page.getByTestId("Active-checkbox").click(); - await dRepDirectoryPage.searchInput.click(); - await responsePromise; + + await dRepDirectoryPage.searchInput.click(); return { dRepGivenName, dRepId, dRepDirectoryPage }; } From f6a7b8d70f33c60e3014df832ad9b0271a7fdb2c Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 18 Dec 2024 20:03:48 +0545 Subject: [PATCH 04/18] fix: add assertion instead of wait for timeout on dRepList --- .../govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts index 9c4ccceb3..54e960c70 100644 --- a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts @@ -147,7 +147,8 @@ export default class DRepDirectoryPage { } async getAllListedDReps() { - await this.page.waitForTimeout(5_000); // load until the dRep card load properly + // add assertion to wait until the search input is visible + await expect(this.searchInput).toBeVisible({ timeout: 10_000 }); return await this.page .getByRole("list") From 13545983584cda6111c9506ba7afd90155bf071d Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 19 Dec 2024 11:52:20 +0545 Subject: [PATCH 05/18] chore: relocate test 2L to delection spec --- .../tests/2-delegation/delegation.spec.ts | 18 +++++++++++++++--- .../delegationFunctionality.delegation.spec.ts | 18 ------------------ 2 files changed, 15 insertions(+), 21 deletions(-) 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 729740620..8cac54d43 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -137,13 +137,11 @@ test("2M. Should access dRep directory page on disconnected state", async ({ }); test.describe("DRep dependent tests", () => { - let dRepGivenName = "test"; let dRepId = "drep1ef7uslcjhjqrn4vv2y39c3yn345gzjsg7yufn76zye3v6fkz23q"; let dRepDirectoryPage: DRepDirectoryPage; test.beforeEach(async ({ page }) => { - ({ dRepDirectoryPage, dRepId, dRepGivenName } = - await fetchFirstActiveDRepDetails(page)); + ({ dRepDirectoryPage, dRepId } = await fetchFirstActiveDRepDetails(page)); }); test("2P. Should enable sharing of DRep details", async ({ @@ -185,4 +183,18 @@ test.describe("DRep dependent tests", () => { await page.getByTestId(`${dRepId}-connect-to-delegate-button`).click(); await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); }); + + test("2L. Should copy DRepId", async ({ page, context }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + + await dRepDirectoryPage.searchInput.fill(dRepId); + await page.getByTestId(`${dRepId}-copy-id-button`).click(); + await expect(page.getByText("Copied to clipboard")).toBeVisible({ + timeout: 10_000, + }); + const copiedTextDRepDirectory = await page.evaluate(() => + navigator.clipboard.readText() + ); + expect(copiedTextDRepDirectory).toEqual(dRepId); + }); }); 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 ed98314d0..2889c1217 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 @@ -74,24 +74,6 @@ test.describe("Delegate to others", () => { 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({ - timeout: 10_000, - }); - - const copiedTextDRepDirectory = await page.evaluate(() => - navigator.clipboard.readText() - ); - expect(copiedTextDRepDirectory).toEqual(dRep01Wallet.dRepId); - }); }); test.describe("Change delegation", () => { From 308eaf0469432af70566cb0798d7853bcf486c0a Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 10:16:26 +0545 Subject: [PATCH 06/18] refactor: move bad proposal tests 5G and 5H to independent tests --- .../proposalFunctionality.dRep.spec.ts | 55 ++----------------- .../proposalFunctionality.spec.ts | 49 +++++++++++++++++ 2 files changed, 54 insertions(+), 50 deletions(-) create mode 100644 tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.spec.ts 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 ef3771ad7..b017ad2b4 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 @@ -12,17 +12,13 @@ import GovernanceActionDetailsPage from "@pages/governanceActionDetailsPage"; import GovernanceActionsPage from "@pages/governanceActionsPage"; import { Page, expect } from "@playwright/test"; import kuberService from "@services/kuberService"; -import { - BootstrapGovernanceActionType, - GovernanceActionType, -} from "@types"; +import { BootstrapGovernanceActionType, GovernanceActionType } from "@types"; import walletManager from "lib/walletManager"; -const invalidInfinityProposals = require("../../lib/_mock/invalidInfinityProposals.json"); - test.beforeEach(async () => { await setAllureEpic("5. Proposal functionality"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test.describe("Proposal checks", () => { @@ -128,47 +124,6 @@ test.describe("Proposal checks", () => { }); }); -test.describe("Bad Proposals", () => { - test.use({ storageState: ".auth/dRep01.json", wallet: dRep01Wallet }); - - let govActionsPage: GovernanceActionsPage; - - test.beforeEach(async ({ page }) => { - await page.route("**/proposal/list?**", async (route) => - route.fulfill({ - body: JSON.stringify(invalidInfinityProposals), - }) - ); - - govActionsPage = new GovernanceActionsPage(page); - await govActionsPage.goto(); - }); - - 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 () => { - const govActionDetailsPage = await govActionsPage.viewFirstProposal(); - - await govActionDetailsPage.externalModalBtn.click(); - - await expect(govActionDetailsPage.externalLinkModal).toBeVisible(); - await expect( - govActionDetailsPage.currentPage.getByText("Be careful", { - exact: false, - }) - ).toBeVisible(); - }); - - test("5H. Should open a new tab in Bad governance action proposal, when external URL is opened", async ({ - page, - }) => { - const govActionDetailsPage = await govActionsPage.viewFirstProposal(); - - await govActionDetailsPage.externalModalBtn.click(); - await govActionDetailsPage.continueModalBtn.click(); - const existingPages = page.context().pages(); - expect(existingPages).toHaveLength(1); - }); -}); - test.describe("Perform voting", () => { let govActionDetailsPage: GovernanceActionDetailsPage; let dRepPage: Page; @@ -287,9 +242,9 @@ test.describe("Bootstrap phase", () => { test("5L. Should restrict dRep votes to Info Governance actions During Bootstrapping Phase", async ({ browser, }) => { - const voteBlacklistOptions = Object.keys(BootstrapGovernanceActionType).filter( - (option) => option !== GovernanceActionType.InfoAction - ); + const voteBlacklistOptions = Object.keys( + BootstrapGovernanceActionType + ).filter((option) => option !== GovernanceActionType.InfoAction); await Promise.all( voteBlacklistOptions.map(async (voteBlacklistOption) => { diff --git a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.spec.ts b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.spec.ts new file mode 100644 index 000000000..595566e79 --- /dev/null +++ b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.spec.ts @@ -0,0 +1,49 @@ +import { test } from "@fixtures/walletExtension"; +import { setAllureEpic } from "@helpers/allure"; +import { skipIfNotHardFork } from "@helpers/cardano"; +import GovernanceActionsPage from "@pages/governanceActionsPage"; +import { expect } from "@playwright/test"; +const invalidInfinityProposals = require("../../lib/_mock/invalidInfinityProposals.json"); + +test.beforeEach(async () => { + await setAllureEpic("5. Proposal functionality"); + await skipIfNotHardFork(); +}); +test.describe("Bad Proposals", () => { + let govActionsPage: GovernanceActionsPage; + + test.beforeEach(async ({ page }) => { + await page.route("**/proposal/list?**", async (route) => + route.fulfill({ + body: JSON.stringify(invalidInfinityProposals), + }) + ); + + govActionsPage = new GovernanceActionsPage(page); + await govActionsPage.goto(); + }); + + 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 () => { + const govActionDetailsPage = await govActionsPage.viewFirstProposal(); + + await govActionDetailsPage.externalModalBtn.click(); + + await expect(govActionDetailsPage.externalLinkModal).toBeVisible(); + await expect( + govActionDetailsPage.currentPage.getByText("Be careful", { + exact: false, + }) + ).toBeVisible(); + }); + + test("5H. Should open a new tab in Bad governance action proposal, when external URL is opened", async ({ + page, + }) => { + const govActionDetailsPage = await govActionsPage.viewFirstProposal(); + + await govActionDetailsPage.externalModalBtn.click(); + await govActionDetailsPage.continueModalBtn.click(); + const existingPages = page.context().pages(); + expect(existingPages).toHaveLength(1); + }); +}); From c8fd3a20c509761d92b170d73293670d35d8497d Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 10:19:36 +0545 Subject: [PATCH 07/18] fix: update networkId logic and utilize it in wallet connection tests --- .../playwright/lib/constants/environments.ts | 4 ++-- .../playwright/lib/fixtures/loadExtension.ts | 1 + .../tests/1-wallet-connect/walletConnect.spec.ts | 14 ++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/constants/environments.ts b/tests/govtool-frontend/playwright/lib/constants/environments.ts index 13622c431..411e80870 100644 --- a/tests/govtool-frontend/playwright/lib/constants/environments.ts +++ b/tests/govtool-frontend/playwright/lib/constants/environments.ts @@ -14,9 +14,9 @@ const environments = { apiUrl: `${SERVER_HOST_URL}/api`, docsUrl: process.env.DOCS_URL || "https://docs.gov.tools/cardano-govtool", pdfUrl: process.env.PDF_URL || "https://dev.api.pdf.gov.tools", - networkId: parseInt(process.env.NETWORK_ID) || 0, + networkId: NETWORK === "mainnet" ? 1 : 0, faucet: { - apiUrl:`https://faucet.${NETWORK}.world.dev.cardano.org`, + apiUrl: `https://faucet.${NETWORK}.world.dev.cardano.org`, apiKey: process.env.FAUCET_API_KEY || "", address: process.env.FAUCET_ADDRESS || diff --git a/tests/govtool-frontend/playwright/lib/fixtures/loadExtension.ts b/tests/govtool-frontend/playwright/lib/fixtures/loadExtension.ts index 34c508d5b..e61609671 100644 --- a/tests/govtool-frontend/playwright/lib/fixtures/loadExtension.ts +++ b/tests/govtool-frontend/playwright/lib/fixtures/loadExtension.ts @@ -19,6 +19,7 @@ export default async function loadDemosExtension( let walletConfig: CardanoTestWalletConfig = { enableStakeSigning, kuberApiUrl: environments.kuber.apiUrl, + networkId: environments.networkId, kuberApiKey: environments.kuber.apiKey, blockfrostApiKey: environments.blockfrostApiKey, blockfrostApiUrl: environments.blockfrostApiUrl, diff --git a/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.spec.ts b/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.spec.ts index 1361de324..557b55cd1 100644 --- a/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.spec.ts +++ b/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.spec.ts @@ -1,3 +1,4 @@ +import environments from "@constants/environments"; import createWallet from "@fixtures/createWallet"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; @@ -17,12 +18,13 @@ test("1A. Should connect wallet and choose stake-key to use", async ({ const shellyWallet = await ShelleyWallet.generate(); const extraPubStakeKey = convertBufferToHex(shellyWallet.stakeKey.public); const extraRewardAddress = convertBufferToHex( - shellyWallet.rewardAddressRawBytes(0) + shellyWallet.rewardAddressRawBytes(environments.networkId) ); await createWallet(page, { extraRegisteredPubStakeKeys: [extraPubStakeKey], extraRewardAddresses: [extraRewardAddress], + networkId: environments.networkId, }); const loginPage = new LoginPage(page); @@ -30,7 +32,9 @@ test("1A. Should connect wallet and choose stake-key to use", async ({ }); test("1C. Should disconnect Wallet When connected", async ({ page }) => { - await createWallet(page); + await createWallet(page, { + networkId: environments.networkId, + }); const loginPage = new LoginPage(page); await loginPage.login(); @@ -38,8 +42,10 @@ test("1C. Should disconnect Wallet When connected", async ({ page }) => { await loginPage.logout(); }); -test("1D. Should reject wallet connection in mainnet", async ({ page }) => { - const wrongNetworkId = 1; // mainnet network +test("1D. Should reject wallet connection if on different network", async ({ + page, +}) => { + const wrongNetworkId = environments.networkId == 0 ? 1 : 0; await createWallet(page, { networkId: wrongNetworkId, }); From aff8198c5eb3b36ca33f04f5262a644766ab1e22 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 10:20:55 +0545 Subject: [PATCH 08/18] fix: skip ada dependent test for mainnet --- .../playwright/tests/2-delegation/delegation.drep.spec.ts | 1 + .../2-delegation/delegationFunctionality.delegation.spec.ts | 1 + .../tests/3-drep-registration/dRepRegistration.dRep.spec.ts | 1 + .../tests/3-drep-registration/editDRep.dRep.spec.ts | 2 ++ .../4-proposal-visibility/proposalVisibility.dRep.spec.ts | 1 + .../tests/6-miscellaneous/miscellaneous.dRep.spec.ts | 1 + .../7-proposal-submission/proposalSubmission.ga.spec.ts | 1 + tests/govtool-frontend/playwright/tests/dRep.setup.ts | 1 + tests/govtool-frontend/playwright/tests/dRep.teardown.ts | 1 + .../govtool-frontend/playwright/tests/delegation.teardown.ts | 1 + tests/govtool-frontend/playwright/tests/faucet.setup.ts | 1 + tests/govtool-frontend/playwright/tests/faucet.teardown.ts | 5 +++-- tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts | 1 + 13 files changed, 16 insertions(+), 2 deletions(-) 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 1c6561e29..197a75945 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 @@ -14,6 +14,7 @@ import walletManager from "lib/walletManager"; test.beforeEach(async () => { await setAllureEpic("2. Delegation"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test("2N. Should show DRep information on details page", async ({ 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 2889c1217..4d7040415 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 @@ -24,6 +24,7 @@ import walletManager from "lib/walletManager"; test.beforeEach(async () => { await setAllureEpic("2. Delegation"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test.describe("Delegate to others", () => { 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 9f593c004..5687d9b76 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 @@ -18,6 +18,7 @@ import { GovernanceActionType } from "@types"; test.beforeEach(async () => { await setAllureEpic("3. DRep registration"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test.describe("Logged in DReps", () => { diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts index 656dc4714..0f20aad56 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts @@ -7,10 +7,12 @@ import { invalid as mockInvalid, valid as mockValid } from "@mock/index"; import { skipIfNotHardFork } from "@helpers/cardano"; import EditDRepPage from "@pages/editDRepPage"; import { expect } from "@playwright/test"; +import environments from "@constants/environments"; test.beforeEach(async () => { await setAllureEpic("3. DRep registration"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test.use({ wallet: dRep02Wallet, storageState: ".auth/dRep02.json" }); 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 bbd615d1b..4bdae4c5e 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 @@ -30,6 +30,7 @@ import { test.beforeEach(async () => { await setAllureEpic("4. Proposal visibility"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test.describe("Logged in DRep", () => { diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts index c0f38d48f..073d52d3a 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts @@ -8,6 +8,7 @@ import { expect } from "@playwright/test"; test.beforeEach(async () => { await setAllureEpic("6. Miscellaneous"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); test.use({ 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 b70e938d2..48eb5cb0a 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 @@ -14,6 +14,7 @@ import { proposalFaucetWallet } from "@constants/proposalFaucetWallet"; test.beforeEach(async () => { await setAllureEpic("7. Proposal submission"); await skipIfNotHardFork(); + test.skip(environments.networkId === 1); }); Object.values(ProposalType).forEach((proposalType, index) => { diff --git a/tests/govtool-frontend/playwright/tests/dRep.setup.ts b/tests/govtool-frontend/playwright/tests/dRep.setup.ts index 319f00ec7..96af045f9 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.setup.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.setup.ts @@ -23,6 +23,7 @@ setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Register DRep"); await skipIfNotHardFork(); + setup.skip(environments.networkId === 1); }); async function generateWallets(num: number) { diff --git a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts index 402d9a48b..6e22c44f9 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts @@ -11,6 +11,7 @@ cleanup.describe.configure({ timeout: environments.txTimeOut }); cleanup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Cleanup"); + cleanup.skip(environments.networkId === 1); }); cleanup("DRep de-registration", async () => { diff --git a/tests/govtool-frontend/playwright/tests/delegation.teardown.ts b/tests/govtool-frontend/playwright/tests/delegation.teardown.ts index 5759f1741..8a994c3b1 100644 --- a/tests/govtool-frontend/playwright/tests/delegation.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/delegation.teardown.ts @@ -11,6 +11,7 @@ cleanup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Cleanup"); await skipIfNotHardFork(); + cleanup.skip(environments.networkId === 1); }); cleanup(`Abstain delegation`, async () => { const stakePrivKeys = adaHolderWallets.map((wallet) => wallet.stake.private); diff --git a/tests/govtool-frontend/playwright/tests/faucet.setup.ts b/tests/govtool-frontend/playwright/tests/faucet.setup.ts index 2b872e8af..db1bd708e 100644 --- a/tests/govtool-frontend/playwright/tests/faucet.setup.ts +++ b/tests/govtool-frontend/playwright/tests/faucet.setup.ts @@ -11,6 +11,7 @@ setup.describe.configure({ timeout: environments.txTimeOut }); setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Faucet"); + setup.skip(environments.networkId === 1); }); setup("Faucet setup", async () => { diff --git a/tests/govtool-frontend/playwright/tests/faucet.teardown.ts b/tests/govtool-frontend/playwright/tests/faucet.teardown.ts index b32425873..1708d3211 100644 --- a/tests/govtool-frontend/playwright/tests/faucet.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/faucet.teardown.ts @@ -9,6 +9,7 @@ cleanup.describe.configure({ timeout: environments.txTimeOut }); cleanup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Cleanup"); + cleanup.skip(environments.networkId === 1); }); cleanup("Refund faucet", async () => { @@ -16,7 +17,7 @@ cleanup("Refund faucet", async () => { const faucetRemainingBalance = await kuberService.getBalance( faucetWallet.address ); - + const transferBalance = Math.floor(faucetRemainingBalance) - 3; const { txId, lockInfo } = await kuberService.transferADA( [environments.faucet.address], @@ -24,7 +25,7 @@ cleanup("Refund faucet", async () => { ); await pollTransaction(txId, lockInfo); } catch (err) { - console.log(err); + console.log(err); if (err.status === 400) { expect(true, "Failed to trasfer Ada").toBeTruthy(); } else { diff --git a/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts b/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts index 1a4b6500d..fa28c262d 100644 --- a/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts +++ b/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts @@ -10,6 +10,7 @@ setup.describe.configure({ mode: "serial", timeout: environments.txTimeOut }); setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Wallet bootstrap"); + setup.skip(environments.networkId === 1); }); setup("Initialize static wallets", async () => { From 6fff4887fb4c335008e8a29f98275d01d4ba3123 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 11:34:05 +0545 Subject: [PATCH 09/18] fix: add timeout to ensure dRep list renders correctly --- .../govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts index 54e960c70..535f55a52 100644 --- a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts @@ -147,6 +147,8 @@ export default class DRepDirectoryPage { } async getAllListedDReps() { + // wait for the dRep list to render properly + await this.page.waitForTimeout(3_000); // add assertion to wait until the search input is visible await expect(this.searchInput).toBeVisible({ timeout: 10_000 }); From 0eeb1a90005cf08fd68bdb15403c2da7ac04b2f1 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 12:06:03 +0545 Subject: [PATCH 10/18] chore: remove unnecessary assertions and add text assertions on delegation popup modal --- .../tests/2-delegation/delegation.loggedin.spec.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 44e447a6e..4490463c0 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 @@ -89,13 +89,14 @@ test.describe("DRep dependent tests", () => { page, }) => { await dRepDirectoryPage.searchInput.fill(dRepId); - const delegateBtn = page.getByTestId(`${dRepId}-delegate-button`); - await expect(delegateBtn).toBeVisible(); await page.getByTestId(`${dRepId}-delegate-button`).click(); await expect(dRepDirectoryPage.delegationErrorModal).toBeVisible({ timeout: 10_000, }); + await expect(dRepDirectoryPage.delegationErrorModal).toHaveText( + /UTxO Balance Insufficient/ + ); }); test("2I. Should check validity of DRep Id", async () => { From 72c64e9fa37cef464347b3730a8433c25fd39f73 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 12:40:50 +0545 Subject: [PATCH 11/18] fix: dynamically fetch proposal titles in governance actions for search --- .../proposalVisibility.loggedin.spec.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 1705c8ed6..bf80f2929 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 @@ -131,11 +131,29 @@ test("4C_3. Should filter and sort Governance Action Type on governance actions }); test("4L. Should search governance actions", async ({ page }) => { - const governanceActionTitle = "TreasuryTitle"; - const governanceActionPage = new GovernanceActionsPage(page); + let governanceActionTitle = "TreasuryTitle"; + await page.route("**/proposal/list?**", async (route) => { + const response = await route.fetch(); + const data = await response.json(); + const elementsWithTitle = data["elements"].filter( + (element) => element["title"] + ); + if (elementsWithTitle.length !== 0) { + governanceActionTitle = elementsWithTitle[0]["title"]; + } + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify(data), + }); + }); + const responsePromise = page.waitForResponse("**/proposal/list?**"); + const governanceActionPage = new GovernanceActionsPage(page); await governanceActionPage.goto(); + await responsePromise; + await governanceActionPage.searchInput.fill(governanceActionTitle); const proposalCards = await governanceActionPage.getAllProposals(); From 028c6c2c6cf659964584ec43ed92cb7671c918dd Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 12:49:10 +0545 Subject: [PATCH 12/18] fix: align proposal type creation logic with protocol version --- .../lib/pages/proposalSubmissionPage.ts | 2 +- .../proposalSubmission.loggedin.spec.ts | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts index 1689016ba..de947584c 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts @@ -184,7 +184,7 @@ export default class ProposalSubmissionPage { async getFirstDraft() { await expect( - this.page.locator('[data-testid^="draft-"][data-testid$="-card"]') + this.page.locator('[data-testid^="draft-"][data-testid$="-card"]').first() ).toBeVisible({ timeout: 10_000 }); // slow rendering return this.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 f870e5881..3695e2b97 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 @@ -12,6 +12,7 @@ import { setAllureEpic } from "@helpers/allure"; import { skipIfTreasuryAndBootstrapping, skipIfNotHardFork, + isBootStrapingPhase, } from "@helpers/cardano"; import { ShelleyWallet } from "@helpers/crypto"; import { createNewPageWithWallet } from "@helpers/page"; @@ -329,9 +330,11 @@ test.describe("Info Proposal Draft", () => { }); const proposalSubmissionPage = new ProposalSubmissionPage(page); - const { proposalFormValue } = await proposalSubmissionPage.createDraft( - ProposalType.treasury - ); + const createProposalType = (await isBootStrapingPhase()) + ? ProposalType.info + : ProposalType.treasury; + const { proposalFormValue } = + await proposalSubmissionPage.createDraft(createProposalType); const draftCard = proposalSubmissionPage.getFirstDraft(); const draftCardAllInnerText = await (await draftCard).allInnerTexts(); @@ -343,7 +346,7 @@ test.describe("Info Proposal Draft", () => { .click(); await expect(proposalSubmissionPage.governanceActionType).toHaveText( - ProposalType.treasury + createProposalType ); await expect(proposalSubmissionPage.titleInput).toHaveValue( proposalFormValue.prop_name @@ -357,12 +360,16 @@ test.describe("Info Proposal Draft", () => { await expect(proposalSubmissionPage.rationaleInput).toHaveValue( proposalFormValue.prop_rationale ); - await expect(proposalSubmissionPage.receivingAddressInput).toHaveValue( - proposalFormValue.prop_receiving_address - ); - await expect(proposalSubmissionPage.amountInput).toHaveValue( - proposalFormValue.prop_amount - ); + + if (createProposalType === ProposalType.treasury) { + await expect(proposalSubmissionPage.receivingAddressInput).toHaveValue( + proposalFormValue.prop_receiving_address + ); + await expect(proposalSubmissionPage.amountInput).toHaveValue( + proposalFormValue.prop_amount + ); + } + await expect(proposalSubmissionPage.linkUrlInput).toHaveValue( proposalFormValue.proposal_links[0].prop_link ); From a478bfb1401d1c4f36d06b62984445943a306296 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 14:39:42 +0545 Subject: [PATCH 13/18] fix: remove temporary workaround for blank proposals issue in proposal view --- .../playwright/lib/pages/proposalDiscussionPage.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts index 1734518e0..b44d9ca46 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalDiscussionPage.ts @@ -29,15 +29,7 @@ export default class ProposalDiscussionPage { async goto() { await this.page.goto(`${environments.frontendUrl}/proposal_discussion`); - // Temporary fix for blank proposals issue in proposal view during disconnected state - // This code handles the blank proposals error, which is causing failing tests. - // It will be removed once the underlying issue is resolved. - await this.page.getByTestId("logo-button").click(); - if (isMobile(this.page)) { - await this.page.getByTestId("open-drawer-button").click(); - } - await this.page.getByText("Proposals", { exact: true }).click(); - + // wait for the proposal cards to load await this.page.waitForTimeout(2_000); } From 0fd8fe54f9ceebb9b6d7907d4b49886db301e267 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 14:50:48 +0545 Subject: [PATCH 14/18] chore: increase timeout for identity verification button visibility --- tests/govtool-frontend/playwright/lib/helpers/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/lib/helpers/auth.ts b/tests/govtool-frontend/playwright/lib/helpers/auth.ts index ae839ebd4..fd4f43dc3 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/auth.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/auth.ts @@ -45,7 +45,7 @@ export async function createAuthWithUserName({ const proposalDiscussionPage = new ProposalDiscussionPage(page); await proposalDiscussionPage.goto(); - await proposalDiscussionPage.verifyIdentityBtn.click(); + await proposalDiscussionPage.verifyIdentityBtn.click({ timeout: 15_000 }); await proposalDiscussionPage.setUsername(mockValid.username()); From 5f2832b941f7f88ff1441150f43351d5130ca5f7 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 20 Dec 2024 14:58:48 +0545 Subject: [PATCH 15/18] feat: configure gov.tools inputs and align network variables for deployment --- .../workflows/test_integration_playwright.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 3f3c5fab1..e478aec0d 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -15,6 +15,7 @@ on: - "staging.govtool.byron.network" - "govtool.cardanoapi.io" - "preview.gov.tools" + - "gov.tools" workflow_run: workflows: ["Build and deploy GovTool to TEST server"] @@ -54,18 +55,27 @@ jobs: mkdir -p ./lib/_mock chmod +w ./lib/_mock npm run generate-wallets - if [[ "${{ env.NETWORK }}" == "preprod" ]]; then + + # Set network variables based on deployment input and environment + if [[ "${{inputs.deployment}}" == "gov.tools" ]]; then + export NETWORK='mainnet' + else + export NETWORK="${{ vars.NETWORK }}" + fi + + # Set API keys based on the network + if [[ "${{ vars.NETWORK }}" == "preprod" ]]; then export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREPROD }}" export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREPROD }}" - elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then + elif [[ "${{ vars.NETWORK }}" == "sanchonet" ]]; then export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_SANCHONET }}" export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_SANCHONET }}" else export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREVIEW }}" export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREVIEW }}" fi + npm test - - name: Upload report uses: actions/upload-artifact@v3 @@ -88,7 +98,6 @@ jobs: KUBER_API_KEY: ${{secrets.KUBER_API_KEY}} TEST_WORKERS: ${{vars.TEST_WORKERS}} CI: ${{vars.CI}} - NETWORK: ${{vars.NETWORK}} FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}} CARDANOAPI_METADATA_URL: ${{vars.CARDANOAPI_METADATA_URL}} PROPOSAL_FAUCET_PAYMENT_PRIVATE: ${{secrets.PROPOSAL_FAUCET_PAYMENT_PRIVATE}} From 67288706bbe10c04a2b988f9b6e9ec509a7a4aaa Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 23 Dec 2024 08:31:57 +0545 Subject: [PATCH 16/18] feat: add skipIfMainnet helper function to conditionally skip tests on mainnet --- .../playwright/lib/helpers/cardano.ts | 12 +++++++++++- .../tests/2-delegation/delegation.drep.spec.ts | 4 ++-- .../delegationFunctionality.delegation.spec.ts | 4 ++-- .../dRepRegistration.dRep.spec.ts | 4 ++-- .../tests/3-drep-registration/editDRep.dRep.spec.ts | 4 ++-- .../proposalVisibility.dRep.spec.ts | 3 ++- .../proposalFunctionality.dRep.spec.ts | 8 ++++++-- .../tests/6-miscellaneous/miscellaneous.dRep.spec.ts | 4 ++-- .../proposalSubmission.ga.spec.ts | 4 ++-- .../govtool-frontend/playwright/tests/dRep.setup.ts | 4 ++-- .../playwright/tests/dRep.teardown.ts | 3 ++- .../playwright/tests/delegation.teardown.ts | 4 ++-- .../playwright/tests/faucet.setup.ts | 3 ++- .../playwright/tests/faucet.teardown.ts | 3 ++- .../playwright/tests/wallet.bootstrap.ts | 3 ++- 15 files changed, 43 insertions(+), 24 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/helpers/cardano.ts b/tests/govtool-frontend/playwright/lib/helpers/cardano.ts index c501a05c6..37a06b2d1 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/cardano.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/cardano.ts @@ -1,4 +1,5 @@ -import test, { expect } from "@playwright/test"; +import environments from "@constants/environments"; +import test from "@playwright/test"; import kuberService from "@services/kuberService"; import { ProposalType, ProtocolParams } from "@types"; import { allure } from "allure-playwright"; @@ -45,3 +46,12 @@ export async function skipIfNotHardFork() { test.skip(); } } + +export async function skipIfMainnet() { + if (environments.networkId === 1) { + await allure.description( + "Ada spendable features are not available on mainnet." + ); + test.skip(); + } +} 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 197a75945..dcc9fcf8c 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 @@ -3,7 +3,7 @@ import { createTempDRepAuth } from "@datafactory/createAuth"; import { faker } from "@faker-js/faker"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { ShelleyWallet } from "@helpers/crypto"; import { createNewPageWithWallet } from "@helpers/page"; import DRepRegistrationPage from "@pages/dRepRegistrationPage"; @@ -14,7 +14,7 @@ import walletManager from "lib/walletManager"; test.beforeEach(async () => { await setAllureEpic("2. Delegation"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test("2N. Should show DRep information on details page", async ({ 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 4d7040415..cee19afa1 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 @@ -12,7 +12,7 @@ import { import { createTempDRepAuth } from "@datafactory/createAuth"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { createNewPageWithWallet } from "@helpers/page"; import { waitForTxConfirmation } from "@helpers/transaction"; import DRepDirectoryPage from "@pages/dRepDirectoryPage"; @@ -24,7 +24,7 @@ import walletManager from "lib/walletManager"; test.beforeEach(async () => { await setAllureEpic("2. Delegation"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test.describe("Delegate to others", () => { 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 5687d9b76..a898d7df6 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 @@ -5,7 +5,7 @@ import { faker } from "@faker-js/faker"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { ShelleyWallet } from "@helpers/crypto"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { createNewPageWithWallet } from "@helpers/page"; import { waitForTxConfirmation } from "@helpers/transaction"; import DRepRegistrationPage from "@pages/dRepRegistrationPage"; @@ -18,7 +18,7 @@ import { GovernanceActionType } from "@types"; test.beforeEach(async () => { await setAllureEpic("3. DRep registration"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test.describe("Logged in DReps", () => { diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts index 0f20aad56..27abd1a31 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts @@ -4,7 +4,7 @@ import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { ShelleyWallet } from "@helpers/crypto"; import { invalid as mockInvalid, valid as mockValid } from "@mock/index"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import EditDRepPage from "@pages/editDRepPage"; import { expect } from "@playwright/test"; import environments from "@constants/environments"; @@ -12,7 +12,7 @@ import environments from "@constants/environments"; test.beforeEach(async () => { await setAllureEpic("3. DRep registration"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test.use({ wallet: dRep02Wallet, storageState: ".auth/dRep02.json" }); 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 4bdae4c5e..8e532d35f 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 @@ -7,6 +7,7 @@ import { setAllureEpic } from "@helpers/allure"; import { isBootStrapingPhase, lovelaceToAda, + skipIfMainnet, skipIfNotHardFork, } from "@helpers/cardano"; import { createNewPageWithWallet } from "@helpers/page"; @@ -30,7 +31,7 @@ import { test.beforeEach(async () => { await setAllureEpic("4. Proposal visibility"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test.describe("Logged in DRep", () => { 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 b017ad2b4..1fb3059d6 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 @@ -4,7 +4,11 @@ import { createTempDRepAuth } from "@datafactory/createAuth"; import { faker } from "@faker-js/faker"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; -import { isBootStrapingPhase, skipIfNotHardFork } from "@helpers/cardano"; +import { + isBootStrapingPhase, + skipIfMainnet, + skipIfNotHardFork, +} from "@helpers/cardano"; import { encodeCIP129Identifier } from "@helpers/encodeDecode"; import { createNewPageWithWallet } from "@helpers/page"; import { waitForTxConfirmation } from "@helpers/transaction"; @@ -18,7 +22,7 @@ import walletManager from "lib/walletManager"; test.beforeEach(async () => { await setAllureEpic("5. Proposal functionality"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test.describe("Proposal checks", () => { diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts index 073d52d3a..cc299875e 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.dRep.spec.ts @@ -2,13 +2,13 @@ import environments from "@constants/environments"; import { dRep01Wallet } from "@constants/staticWallets"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { expect } from "@playwright/test"; test.beforeEach(async () => { await setAllureEpic("6. Miscellaneous"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); test.use({ 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 48eb5cb0a..1918b7a47 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 @@ -7,14 +7,14 @@ import { waitForTxConfirmation } from "@helpers/transaction"; import ProposalDiscussionPage from "@pages/proposalDiscussionPage"; import ProposalSubmissionPage from "@pages/proposalSubmissionPage"; import { expect } from "@playwright/test"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { ProposalType } from "@types"; import { proposalFaucetWallet } from "@constants/proposalFaucetWallet"; test.beforeEach(async () => { await setAllureEpic("7. Proposal submission"); await skipIfNotHardFork(); - test.skip(environments.networkId === 1); + await skipIfMainnet(); }); Object.values(ProposalType).forEach((proposalType, index) => { diff --git a/tests/govtool-frontend/playwright/tests/dRep.setup.ts b/tests/govtool-frontend/playwright/tests/dRep.setup.ts index 96af045f9..5da1f4f50 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.setup.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.setup.ts @@ -1,7 +1,7 @@ import environments from "@constants/environments"; import { dRepWallets } from "@constants/staticWallets"; import { setAllureEpic, setAllureStory } from "@helpers/allure"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { ShelleyWallet } from "@helpers/crypto"; import { uploadMetadataAndGetJsonHash } from "@helpers/metadata"; import { pollTransaction } from "@helpers/transaction"; @@ -23,7 +23,7 @@ setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Register DRep"); await skipIfNotHardFork(); - setup.skip(environments.networkId === 1); + await skipIfMainnet(); }); async function generateWallets(num: number) { diff --git a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts index 6e22c44f9..89be4b0f2 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts @@ -1,6 +1,7 @@ import environments from "@constants/environments"; import { dRepWallets } from "@constants/staticWallets"; import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { skipIfMainnet } from "@helpers/cardano"; import { pollTransaction } from "@helpers/transaction"; import { test as cleanup, expect } from "@playwright/test"; import kuberService from "@services/kuberService"; @@ -11,7 +12,7 @@ cleanup.describe.configure({ timeout: environments.txTimeOut }); cleanup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Cleanup"); - cleanup.skip(environments.networkId === 1); + await skipIfMainnet(); }); cleanup("DRep de-registration", async () => { diff --git a/tests/govtool-frontend/playwright/tests/delegation.teardown.ts b/tests/govtool-frontend/playwright/tests/delegation.teardown.ts index 8a994c3b1..26dbaa135 100644 --- a/tests/govtool-frontend/playwright/tests/delegation.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/delegation.teardown.ts @@ -1,7 +1,7 @@ import environments from "@constants/environments"; import { adaHolderWallets } from "@constants/staticWallets"; import { setAllureStory, setAllureEpic } from "@helpers/allure"; -import { skipIfNotHardFork } from "@helpers/cardano"; +import { skipIfMainnet, skipIfNotHardFork } from "@helpers/cardano"; import { pollTransaction } from "@helpers/transaction"; import { test as cleanup } from "@playwright/test"; import kuberService from "@services/kuberService"; @@ -11,7 +11,7 @@ cleanup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Cleanup"); await skipIfNotHardFork(); - cleanup.skip(environments.networkId === 1); + await skipIfMainnet(); }); cleanup(`Abstain delegation`, async () => { const stakePrivKeys = adaHolderWallets.map((wallet) => wallet.stake.private); diff --git a/tests/govtool-frontend/playwright/tests/faucet.setup.ts b/tests/govtool-frontend/playwright/tests/faucet.setup.ts index db1bd708e..bd5a501f1 100644 --- a/tests/govtool-frontend/playwright/tests/faucet.setup.ts +++ b/tests/govtool-frontend/playwright/tests/faucet.setup.ts @@ -1,6 +1,7 @@ import environments from "@constants/environments"; import { faucetWallet } from "@constants/staticWallets"; import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { skipIfMainnet } from "@helpers/cardano"; import { pollTransaction } from "@helpers/transaction"; import { test as setup } from "@playwright/test"; import { loadAmountFromFaucet } from "@services/faucetService"; @@ -11,7 +12,7 @@ setup.describe.configure({ timeout: environments.txTimeOut }); setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Faucet"); - setup.skip(environments.networkId === 1); + await skipIfMainnet(); }); setup("Faucet setup", async () => { diff --git a/tests/govtool-frontend/playwright/tests/faucet.teardown.ts b/tests/govtool-frontend/playwright/tests/faucet.teardown.ts index 1708d3211..f64398eeb 100644 --- a/tests/govtool-frontend/playwright/tests/faucet.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/faucet.teardown.ts @@ -1,6 +1,7 @@ import environments from "@constants/environments"; import { faucetWallet } from "@constants/staticWallets"; import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { skipIfMainnet } from "@helpers/cardano"; import { pollTransaction } from "@helpers/transaction"; import { test as cleanup, expect } from "@playwright/test"; import kuberService from "@services/kuberService"; @@ -9,7 +10,7 @@ cleanup.describe.configure({ timeout: environments.txTimeOut }); cleanup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Cleanup"); - cleanup.skip(environments.networkId === 1); + await skipIfMainnet(); }); cleanup("Refund faucet", async () => { diff --git a/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts b/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts index fa28c262d..72dd3e4d6 100644 --- a/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts +++ b/tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts @@ -1,5 +1,6 @@ import { adaHolderWallets, dRepWallets } from "@constants/staticWallets"; import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { skipIfMainnet } from "@helpers/cardano"; import { pollTransaction } from "@helpers/transaction"; import { expect, test as setup } from "@playwright/test"; import kuberService from "@services/kuberService"; @@ -10,7 +11,7 @@ setup.describe.configure({ mode: "serial", timeout: environments.txTimeOut }); setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Wallet bootstrap"); - setup.skip(environments.networkId === 1); + await skipIfMainnet(); }); setup("Initialize static wallets", async () => { From b1ee1eaba390fd363a216315afc14de1288e8198 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 23 Dec 2024 12:11:33 +0545 Subject: [PATCH 17/18] refactor: add cleanup logic for test-created proposals --- .../proposalSubmission.loggedin.spec.ts | 11 +++++++++++ .../proposalDiscussion.loggedin.spec.ts | 16 ---------------- 2 files changed, 11 insertions(+), 16 deletions(-) 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 3695e2b97..0a9697715 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 @@ -141,6 +141,8 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.submitBtn.click(); await expect(page.getByTestId("submit-as-GA-button")).toBeVisible(); + const proposalDetailsPage = new ProposalDiscussionDetailsPage(page); + await expect(proposalSubmissionPage.titleContent).toHaveText( proposal.prop_name ); @@ -159,6 +161,9 @@ test.describe("Proposal created logged state", () => { await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposal.proposal_links[0].prop_link_text ); + + // cleanup + await proposalDetailsPage.deleteProposal(); }); }); }); @@ -428,6 +433,9 @@ test.describe("Info Proposal Draft", () => { await proposalSubmissionPage.submitBtn.click(); await expect(page.getByTestId("submit-as-GA-button")).toBeVisible(); + const proposalDiscussionDetailsPage = new ProposalDiscussionDetailsPage( + page + ); await expect(proposalSubmissionPage.titleContent).toHaveText( proposalFormValue.prop_name ); @@ -446,6 +454,9 @@ test.describe("Info Proposal Draft", () => { await expect(proposalSubmissionPage.linkTextContent).toHaveText( proposalFormValue.proposal_links[0].prop_link_text ); + + //cleanup + proposalDiscussionDetailsPage.deleteProposal(); }); }); 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 fa9dbc999..36568db3b 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 @@ -3,10 +3,8 @@ import { proposal02Wallet, user01Wallet, } from "@constants/staticWallets"; -import { createTempUserAuth } from "@datafactory/createAuth"; import { faker } from "@faker-js/faker"; import { test } from "@fixtures/proposal"; -import { ShelleyWallet } from "@helpers/crypto"; import { createNewPageWithWallet } from "@helpers/page"; import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage"; import { Page, expect } from "@playwright/test"; @@ -133,20 +131,6 @@ test.describe("Proposal created with poll enabled (user auth)", () => { }); }); -test.describe("Proposal created logged out state", () => { - let userPage: Page; - - test.beforeEach(async ({ page, browser }) => { - const wallet = (await ShelleyWallet.generate()).json(); - const tempUserAuth = await createTempUserAuth(page, wallet); - - userPage = await createNewPageWithWallet(browser, { - storageState: tempUserAuth, - wallet, - }); - }); -}); - test.describe("Proposal created with poll enabled (proposal auth)", () => { test.use({ storageState: ".auth/user01.json", From 63b50c4f3ca286a65fe811f48cbef366e28fb234 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 23 Dec 2024 14:44:51 +0545 Subject: [PATCH 18/18] fix: remove unnecessary mainnet dummy dRep id --- .../playwright/tests/2-delegation/delegation.loggedin.spec.ts | 4 ++-- .../playwright/tests/2-delegation/delegation.spec.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 4490463c0..837c41011 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 @@ -76,8 +76,8 @@ test("2X_2. Should include info button and voting power on the Signal-No-Confide }); test.describe("DRep dependent tests", () => { - let dRepGivenName = "test"; - let dRepId = "drep1ef7uslcjhjqrn4vv2y39c3yn345gzjsg7yufn76zye3v6fkz23q"; + let dRepGivenName: string; + let dRepId: string; let dRepDirectoryPage: DRepDirectoryPage; test.beforeEach(async ({ page }) => { 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 8cac54d43..ddd37c318 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -137,7 +137,7 @@ test("2M. Should access dRep directory page on disconnected state", async ({ }); test.describe("DRep dependent tests", () => { - let dRepId = "drep1ef7uslcjhjqrn4vv2y39c3yn345gzjsg7yufn76zye3v6fkz23q"; + let dRepId: string; let dRepDirectoryPage: DRepDirectoryPage; test.beforeEach(async ({ page }) => {