diff --git a/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts b/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts index 88953c3fa..48bd8d711 100644 --- a/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts +++ b/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts @@ -13,3 +13,25 @@ export const PRIVACY_POLICY = `https://docs.intersectmbo.org/legal/policies-and- export const TERMS_AND_CONDITIONS = `https://docs.intersectmbo.org/legal/policies-and-conditions/terms-of-use`; export const HELP_DOC_URL = `${environments.docsUrl}/support`; export const BOOTSTRAP_DOC_URL = `${environments.docsUrl}/faqs/bootstrapping-phase`; +export const REPO_URL = "https://github.com/IntersectMBO/govtool"; +export const DOCS_URL = environments.docsUrl.replace("cardano-govtool", ""); +export const GOVERNANCE_OVERVIEW_DOC_URL = + "https://docs.cardano.org/about-cardano/governance-overview"; + +// other cardano governance urls + +export const CCPortal = "https://constitution.gov.tools/en"; +export const intersectWebsite = "https://www.intersectmbo.org/"; +export const tempo = "https://tempo.vote/"; +export const sixteenNinetyFour = "https://www.1694.io/en"; +export const governanceSpace = "https://governancespace.com/en-us"; +export const syncAi = "https://www.syncgovhub.com/app"; +export const ekklesia = "https://2025budget.intersectmbo.org/"; +export const adaStat = "https://adastat.net/"; +export const cexplorer = "https://cexplorer.io/"; +export const cardanoScan = "https://cardanoscan.io/"; +export const cardanoBudget = "https://cardanobudget.com/"; +export const budgetCardanoAfrica = "https://budget.cardano.africa/"; +export const reachYourPeople = "https://www.ryp.io/"; +export const sixteenNinetyFourTools = "https://1694-tools.vercel.app/"; +export const sanchonetGovernanceExplorer = "https://sancho.cardanoconnect.io/"; diff --git a/tests/govtool-frontend/playwright/lib/constants/index.ts b/tests/govtool-frontend/playwright/lib/constants/index.ts index 407772241..79726d08f 100644 --- a/tests/govtool-frontend/playwright/lib/constants/index.ts +++ b/tests/govtool-frontend/playwright/lib/constants/index.ts @@ -61,3 +61,46 @@ export const InvalidMetadata: InvalidMetadataType[] = [ hash: "e71bf6171adda3754a87fff5c2d8d9e404eb3366428a5be13f7e76357a39004f", }, ]; + +export const connectToCardanoWalletSection = [ + { + testId: "home-card-discuss-budget-proposals", + urlPattern: /\/budget_discussion/, + label: "Discuss Budget Proposals", + }, + { + testId: "home-card-create-a-budget-proposal", + urlPattern: /\/budget_discussion/, + label: "Create a Budget Proposal", + }, + { + testId: "home-card-discuss-governance-actions", + urlPattern: /\/proposal_discussion/, + label: "Discuss Governance Actions", + }, + { + testId: "home-card-propose-a-governance-action", + urlPattern: /\/proposal_discussion\/propose/, + label: "Propose a Governance Action", + }, + { + testId: "home-card-register-to-vote", + urlPattern: /\/register_direct_voter/, + label: "Register to Vote", + }, + { + testId: "home-card-delegate-your-vote-to-a-drep", + urlPattern: /\/drep_directory/, + label: "Delegate Your Vote to a DRep", + }, + { + testId: "home-card-become-a-drep", + urlPattern: /\/register_drep/, + Label: "Become a DRep", + }, + { + testId: "home-card-vote-on-governance-actions", + urlPattern: /\governance_actions/, + label: "Vote on Governance Actions", + }, +]; diff --git a/tests/govtool-frontend/playwright/lib/pages/loginPage.ts b/tests/govtool-frontend/playwright/lib/pages/loginPage.ts index 13c95ecab..f530c0f83 100644 --- a/tests/govtool-frontend/playwright/lib/pages/loginPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/loginPage.ts @@ -6,7 +6,9 @@ import { isMobile, openDrawer } from "@helpers/mobile"; import { Page, expect } from "@playwright/test"; export default class LoginPage { - readonly connectWalletBtn = this.page.getByTestId("connect-wallet-button"); + readonly connectWalletBtn = this.page + .getByTestId("connect-wallet-button") + .first(); readonly demosWalletBtn = this.page.getByTestId("demos-wallet-button"); readonly acceptSanchoNetInfoBtn = this.page .getByTestId("confirm-modal-button") 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 557b55cd1..66eb07d3b 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 @@ -52,7 +52,7 @@ test("1D. Should reject wallet connection if on different network", async ({ await page.goto("/"); - await page.getByTestId("connect-wallet-button").click(); + await page.getByTestId("connect-wallet-button").first().click(); await page.getByTestId("demos-wallet-button").click(); await expect(page.getByTestId("wallet-connection-error-modal")).toHaveText( @@ -70,7 +70,7 @@ test("1E. Should hide incompatible wallets when connecting", async ({ }); await newPage.goto("/"); - await newPage.getByTestId("connect-wallet-button").click(); + await newPage.getByTestId("connect-wallet-button").first().click(); await expect(newPage.getByTestId("demos-wallet-button")).not.toBeVisible(); }); diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.spec.ts index 204762cb7..583bb9258 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.spec.ts @@ -11,6 +11,6 @@ test("3C. Should open wallet connection popup on DRep registration in disconnect }) => { await page.goto("/"); - await page.getByTestId("register-connect-wallet-button").click(); + await page.getByTestId("home-card-become-a-drep").click(); await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); }); 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 fd75c0b1d..c906eb47f 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 @@ -162,7 +162,9 @@ test.describe("Check vote count", () => { return data.elements; }) ) - ).flat(); + ) + .flat() + .filter((proposal): proposal is IProposal => proposal !== undefined); const uniqueProposalTypes = Array.from( new Map(proposals.map((proposal) => [proposal.type, proposal])).values() diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts index 1127032ab..727278efe 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts @@ -42,9 +42,9 @@ test("4A_2. Should access Governance Actions page without connecting wallet", as page, }) => { await page.goto("/"); - await page.getByTestId("move-to-governance-actions-button").click(); + await page.getByTestId("home-card-view-live-voting").click(); - await expect(page.getByText(/Governance actions/i)).toHaveCount(1); + await expect(page.getByText(/live voting/i)).toHaveCount(2); }); test("4B_2. Should restrict voting for users who are not registered as DReps (without wallet connected)", async ({ diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts index 08c1bca6e..aa851f5b9 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.loggedin.spec.ts @@ -8,8 +8,11 @@ import { REGISTER_DREP_DOC_URL, SIGNAL_NO_CONFIDENCE_VOTE_DOC_URL, } from "@constants/docsUrl"; +import environments from "@constants/environments"; +import { connectToCardanoWalletSection } from "@constants/index"; import { user01Wallet } from "@constants/staticWallets"; import { createTempUserAuth } from "@datafactory/createAuth"; +import createWallet from "@fixtures/createWallet"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { ShelleyWallet } from "@helpers/crypto"; @@ -29,7 +32,7 @@ test.describe("Logged in user", () => { wallet: user01Wallet, }); - test("6E. Should open Sanchonet docs in a new tab when clicking `Learn More` on dashboards in connected state.", async ({ + test("6E. Should open docs in a new tab when clicking `Learn More` on dashboards in connected state.", async ({ page, context, }) => { @@ -104,6 +107,28 @@ test.describe("Logged in user", () => { }); }); +test.describe("Temporary user for landing page connected behaviour", () => { + connectToCardanoWalletSection.forEach((section, index) => { + test(`6N_${index + 1}. Should navigate to specific page after wallet connection on clicking '${section.label}'`, async ({ + page, + }) => { + await createWallet(page, { + networkId: environments.networkId, + }); + await page.goto("/"); + await page.getByTestId(section.testId).click(); + await page.getByTestId("demos-wallet-button").click({ force: true }); + + await page + .getByTestId("confirm-modal-button") + .nth(0) + .click({ force: true }); + + await expect(page).toHaveURL(section.urlPattern); + }); + }); +}); + test.describe("Temporary user", () => { let userPage: Page; let proposalDiscussionPage: ProposalDiscussionPage; diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts index 6692c6c55..26b9f5cb6 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts @@ -1,18 +1,34 @@ import { - BOOTSTRAP_DOC_URL, - DELEGATION_DOC_URL, - DIRECT_VOTER_DOC_URL, + adaStat, + budgetCardanoAfrica, + cardanoBudget, + cardanoScan, + CCPortal, + cexplorer, + DOCS_URL, + ekklesia, FAQS_DOC_URL, + GOVERNANCE_OVERVIEW_DOC_URL, + governanceSpace, GUIDES_DOC_URL, HELP_DOC_URL, + intersectWebsite, PRIVACY_POLICY, - REGISTER_DREP_DOC_URL, + reachYourPeople, + REPO_URL, + sanchonetGovernanceExplorer, + sixteenNinetyFour, + sixteenNinetyFourTools, + syncAi, + tempo, TERMS_AND_CONDITIONS, } from "@constants/docsUrl"; +import { connectToCardanoWalletSection } from "@constants/index"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; import { isMobile, openDrawer } from "@helpers/mobile"; import { expect, Page } from "@playwright/test"; +import { connect } from "http2"; import environments from "lib/constants/environments"; test.beforeEach(async () => { @@ -22,62 +38,159 @@ test.beforeEach(async () => { test("6C. Navigation within the dApp", async ({ page, context }) => { await page.goto("/"); - if (isMobile(page)) { - await openDrawer(page); + const dashboardCards = [ + { + testId: "home-card-browse-the-drep-directory", + urlPattern: /\/drep_directory/, + }, + { + testId: "home-card-view-budget-proposals", + urlPattern: /\/budget_discussion/, + }, + { + testId: "home-card-see-proposed-governance-actions", + urlPattern: /\/proposal_discussion/, + }, + { + testId: "home-card-view-live-voting", + urlPattern: /\/governance_actions/, + }, + { testId: "home-card-view-voting-outcomes", urlPattern: /\/outcomes/ }, + ]; + + for (const card of dashboardCards) { + await page.getByTestId(card.testId).click(); + await expect(page).toHaveURL(card.urlPattern); + await page.goBack(); } - await page.getByTestId("governance-actions-link").click(); - await expect(page).toHaveURL(/\/governance_actions/); - if (isMobile(page)) { - await openDrawer(page); - } - const [guidesPage] = await Promise.all([ + // external links in dashboard cards + const [guidesPage2] = await Promise.all([ context.waitForEvent("page"), - page.getByTestId("guides-link").click(), + page.getByTestId("home-card-read-our-guides").click(), ]); - await expect(guidesPage).toHaveURL(GUIDES_DOC_URL); + await expect(guidesPage2).toHaveURL(GUIDES_DOC_URL); + + // Test navbar links navigation + const navbarLinks = [ + { testId: "dashboard-link", url: `${environments.frontendUrl}/` }, + { testId: "drep-directory-link", urlPattern: /\/drep_directory/ }, + { testId: "budget-discussion-link", urlPattern: /\/budget_discussion/ }, + { + testId: "proposed-governance-actions-link", + urlPattern: /\/proposal_discussion/, + }, + { testId: "governance-actions-link", urlPattern: /\/governance_actions/ }, + { testId: "governance-actions-outcomes-link", urlPattern: /\/outcomes/ }, + ]; + + for (const link of navbarLinks) { + if (isMobile(page)) { + await openDrawer(page); + } + await page.getByTestId(link.testId).click(); + + if (link.url) { + expect(page.url()).toEqual(link.url); + } else { + await expect(page).toHaveURL(link.urlPattern); + } + } - if (isMobile(page)) { - await openDrawer(page); + // Test external links in navbar + const externalLinks = [ + { testId: "guides-link", url: GUIDES_DOC_URL }, + { testId: "faqs-link", url: FAQS_DOC_URL }, + ]; + + for (const link of externalLinks) { + if (isMobile(page)) { + await openDrawer(page); + } + const [newPage] = await Promise.all([ + context.waitForEvent("page"), + page.getByTestId(link.testId).click(), + ]); + await expect(newPage).toHaveURL(link.url); } - const [faqsPage] = await Promise.all([ - context.waitForEvent("page"), - page.getByTestId("faqs-link").click(), - ]); +}); + +test("6D. Should open wallet popup when navigating from 'Connect a Cardano wallet to' sections on dashboard in disconnected state", async ({ + page, +}) => { + await page.goto("/"); - await expect(faqsPage).toHaveURL(FAQS_DOC_URL); + const sections = connectToCardanoWalletSection.map( + (section) => section.testId + ); + + for (const sectionTestId of sections) { + await page.getByTestId(sectionTestId).click(); + await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); + await page.getByTestId("close-modal-button").click(); + } +}); + +test("6G. Should navigate between other cardano governance resources", async ({ + page, +}) => { + await page.goto("/"); - if (isMobile(page)) { - await openDrawer(page); + const resources = [ + { testId: "useful-link-ccPortal", url: CCPortal }, + { testId: "useful-link-intersectWebsite", url: intersectWebsite }, + { testId: "useful-link-tempo", url: tempo }, + { testId: "useful-link-1694io", url: sixteenNinetyFour }, + { testId: "useful-link-governanceSpace", url: governanceSpace }, + { testId: "useful-link-syncAi", url: syncAi }, + { testId: "useful-link-ekklesia", url: ekklesia }, + { testId: "useful-link-adaStat", url: adaStat }, + { testId: "useful-link-cexplorer", url: cexplorer }, + { testId: "useful-link-cardanoScan", url: cardanoScan }, + { testId: "useful-link-cardanoBudget", url: cardanoBudget }, + { testId: "useful-link-budgetCardanoAfrica", url: budgetCardanoAfrica }, + { testId: "useful-link-reachYourPeople", url: reachYourPeople }, + { testId: "useful-link-1694Tools", url: sixteenNinetyFourTools }, + { + testId: "useful-link-sanchonetGovernanceExplorer", + url: sanchonetGovernanceExplorer, + }, + ]; + + for (let resource of resources) { + const [newPage] = await Promise.all([ + page.context().waitForEvent("page"), + page.getByTestId(resource.testId).click(), + ]); + await expect(newPage).toHaveURL(resource.url); + await newPage.close(); } - await page.getByTestId("dashboard-link").click(); - expect(page.url()).toEqual(`${environments.frontendUrl}/`); }); -test("6D. Should open Sanchonet docs in a new tab when clicking `Learn More` on dashboards in disconnected state.", async ({ +test("6H. Should navigate between repository and documentation links", async ({ page, context, }) => { await page.goto("/"); - const [delegationLearnMorepage] = await Promise.all([ + const [repoPage] = await Promise.all([ context.waitForEvent("page"), - page.getByTestId("delegate-learn-more-button").click(), + page.getByTestId("home-card-github-repo").click(), ]); - await expect(delegationLearnMorepage).toHaveURL(DELEGATION_DOC_URL); + await expect(repoPage).toHaveURL(REPO_URL); - const [registerLearnMorepage] = await Promise.all([ + const [docsPage] = await Promise.all([ context.waitForEvent("page"), - page.getByTestId("d-rep-learn-more-button").click(), + page.getByTestId("home-card-documentation").click(), ]); - await expect(registerLearnMorepage).toHaveURL(REGISTER_DREP_DOC_URL); + await expect(docsPage).toHaveURL(DOCS_URL); - const [directVoterLearnMorepage] = await Promise.all([ + const [governance_overview] = await Promise.all([ context.waitForEvent("page"), - page.getByTestId("direct-voter-learn-more-button").click(), + page.getByTestId("link-to-docs").click(), ]); - await expect(directVoterLearnMorepage).toHaveURL(DIRECT_VOTER_DOC_URL); + await expect(governance_overview).toHaveURL(GOVERNANCE_OVERVIEW_DOC_URL); }); test("6M. Should navigate between footer links", async ({ page, context }) => { diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.spec.ts index a7063eb8c..0939914a4 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.spec.ts @@ -10,6 +10,6 @@ test("7A. Should open wallet connection popup, when propose a governance action page, }) => { await page.goto("/"); - await page.getByTestId("propose-a-governance-action-button").click(); + await page.getByTestId("home-card-propose-a-governance-action").click(); await expect(page.getByTestId("connect-your-wallet-modal")).toBeVisible(); });