diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts index 3ba8c0331..9496b587b 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts @@ -20,7 +20,7 @@ const formErrors = { export default class ProposalSubmissionPage { // modals readonly registrationSuccessModal = this.page.getByTestId( - "create-governance-action-submitted-modal" + "governance-action-submitted-modal" ); readonly registrationErrorModal = this.page.getByTestId( "create-governance-action-error-modal" diff --git a/tests/govtool-frontend/playwright/lib/walletManager.ts b/tests/govtool-frontend/playwright/lib/walletManager.ts index c13c9cf42..cd9183269 100644 --- a/tests/govtool-frontend/playwright/lib/walletManager.ts +++ b/tests/govtool-frontend/playwright/lib/walletManager.ts @@ -5,11 +5,7 @@ const path = require("path"); const baseFilePath = path.resolve(__dirname, "./_mock"); -export type Purpose = - | "registerDRep" - | "registeredDRep" - | "proposalSubmission" - | "adaHolder"; +export type Purpose = "registerDRep" | "registeredDRep" | "proposalSubmission"; /** * WalletManager class is responsible for managing a list of temporary wallets. diff --git a/tests/govtool-frontend/playwright/playwright.config.ts b/tests/govtool-frontend/playwright/playwright.config.ts index 74fbbe1cc..62e7c3287 100644 --- a/tests/govtool-frontend/playwright/playwright.config.ts +++ b/tests/govtool-frontend/playwright/playwright.config.ts @@ -52,6 +52,11 @@ export default defineConfig({ testMatch: "**/dRep.setup.ts", dependencies: environments.ci ? ["faucet setup"] : [], }, + { + name: "proposal setup", + testMatch: "**/proposal.setup.ts", + dependencies: environments.ci ? ["faucet setup"] : [], + }, { name: "wallet bootstrap", testMatch: "**/wallet.bootstrap.ts", @@ -63,6 +68,14 @@ export default defineConfig({ testMatch: "**/*.tx.spec.ts", dependencies: environments.ci ? ["auth setup", "wallet bootstrap"] : [], }, + { + name: "proposal", + use: { ...devices["Desktop Chrome"] }, + testMatch: "**/*.proposal.spec.ts", + dependencies: environments.ci + ? ["auth setup", "wallet bootstrap", "proposal setup"] + : [], + }, { name: "loggedin (desktop)", use: { ...devices["Desktop Chrome"] }, @@ -92,6 +105,7 @@ export default defineConfig({ "**/*.loggedin.spec.ts", "**/*.dRep.spec.ts", "**/*.tx.spec.ts", + "**/*.proposal.spec.ts", ], }, { @@ -102,6 +116,7 @@ export default defineConfig({ "**/*.dRep.spec.ts", "**/*.delegation.spec.ts", "**/*.tx.spec.ts", + "**/*.proposal.spec.ts", "**/walletConnect.spec.ts", ], }, diff --git a/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.loggedin.spec.ts index b1a23c363..f073d6cb2 100644 --- a/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/1-wallet-connect/walletConnect.loggedin.spec.ts @@ -8,7 +8,7 @@ test.beforeEach(async () => { await setAllureEpic("1. Wallet connect"); }); -test("1B: Should connect wallet with single stake key", async ({ page }) => { +test("1B. Should connect wallet with single stake key", async ({ page }) => { const loginPage = new LoginPage(page); await loginPage.goto(); await loginPage.isLoggedIn(); 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 e9ea95072..5e0149494 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 @@ -28,7 +28,7 @@ test("1A. Should connect wallet and choose stake-key to use", async ({ await loginPage.login(); }); -test("1C: Should disconnect Wallet When connected", async ({ page }) => { +test("1C. Should disconnect Wallet When connected", async ({ page }) => { await createWallet(page); const loginPage = new LoginPage(page); 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 2ee585c5e..ddfcf7e44 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 @@ -35,7 +35,7 @@ test("3D. Verify DRep registration form", async ({ page }) => { }); test.describe("Validation of dRep Registration Form", () => { - test("3E_1 Should accept valid data in DRep form", async ({ page }) => { + test("3E_1. Should accept valid data in DRep form", async ({ page }) => { test.slow(); const dRepRegistrationPage = new DRepRegistrationPage(page); 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 f543862e0..b5ff1317e 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 @@ -13,7 +13,7 @@ test.beforeEach(async () => { test.use({ wallet: dRep02Wallet, storageState: ".auth/dRep02.json" }); test.describe("Validation of edit dRep Form", () => { - test("3M_1 Should accept valid data in edit dRep form", async ({ page }) => { + test("3M_1. Should accept valid data in edit dRep form", async ({ page }) => { test.slow(); const editDRepPage = new EditDRepPage(page); 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 4053ad471..ebcbdcb4f 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 @@ -31,7 +31,7 @@ test.beforeEach(async () => { await setAllureEpic("4. Proposal visibility"); }); -test("4A_1: Should access Governance Actions page with connecting wallet", async ({ +test("4A_1. Should access Governance Actions page with connecting wallet", async ({ page, }) => { await page.goto("/"); @@ -43,7 +43,7 @@ test("4A_1: Should access Governance Actions page with connecting wallet", async await expect(page.getByText(/Governance Actions/i)).toHaveCount(2); }); -test("4B_1: Should restrict voting for users who are not registered as DReps (with wallet connected)", async ({ +test("4B_1. Should restrict voting for users who are not registered as DReps (with wallet connected)", async ({ page, }) => { const govActionsPage = new GovernanceActionsPage(page); @@ -53,7 +53,7 @@ test("4B_1: Should restrict voting for users who are not registered as DReps (wi await expect(govActionDetailsPage.voteBtn).not.toBeVisible(); }); -test("4C_1: Should filter Governance Action Type on governance actions page", async ({ +test("4C_1. Should filter Governance Action Type on governance actions page", async ({ page, }) => { test.slow(); @@ -80,7 +80,7 @@ test("4C_1: Should filter Governance Action Type on governance actions page", as } }); -test("4C_2: Should sort Governance Action Type on governance actions page", async ({ +test("4C_2. Should sort Governance Action Type on governance actions page", async ({ page, }) => { test.slow(); @@ -106,7 +106,7 @@ test("4C_2: Should sort Governance Action Type on governance actions page", asyn ); }); -test("4C_3: 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(); @@ -128,7 +128,7 @@ test("4C_3: Should filter and sort Governance Action Type on governance actions await govActionsPage.validateFilters([filterOptionNames[0]]); }); -test("4L: Should search governance actions", async ({ page }) => { +test("4L. Should search governance actions", async ({ page }) => { const governanceActionTitle = "TreasuryTitle"; const governanceActionPage = new GovernanceActionsPage(page); @@ -145,7 +145,7 @@ test("4L: Should search governance actions", async ({ page }) => { } }); -test("4M: Should show view-all categorized governance actions", async ({ +test("4M. Should show view-all categorized governance actions", async ({ page, }) => { await page.route("**/proposal/list?**", async (route) => 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 56dd8e9ff..9f98d47f6 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 @@ -8,7 +8,7 @@ test.beforeEach(async () => { await setAllureEpic("4. Proposal visibility"); }); -test("4A.2: Should access Governance Actions page without connecting wallet", async ({ +test("4A.2. Should access Governance Actions page without connecting wallet", async ({ page, }) => { await page.goto("/"); @@ -17,7 +17,7 @@ test("4A.2: Should access Governance Actions page without connecting wallet", as await expect(page.getByText(/Governance actions/i)).toHaveCount(2); }); -test("4B.2: Should restrict voting for users who are not registered as DReps (without wallet connected)", async ({ +test("4B.2. Should restrict voting for users who are not registered as DReps (without wallet connected)", async ({ page, }) => { const govActionsPage = new GovernanceActionsPage(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 6a04169e3..a78cbd007 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 @@ -2,6 +2,7 @@ import { user01Wallet } from "@constants/staticWallets"; import { faker } from "@faker-js/faker"; import { test } from "@fixtures/walletExtension"; import { setAllureEpic } from "@helpers/allure"; +import { ShelleyWallet } from "@helpers/crypto"; import { invalid } from "@mock/index"; import ProposalSubmissionPage from "@pages/proposalSubmissionPage"; import { expect } from "@playwright/test"; @@ -72,6 +73,37 @@ test.describe("Reject invalid data", () => { }); }); +test.describe("Proposal submission check", () => { + Object.values(ProposalType).map((type: ProposalType, index) => { + test(`7G_${index + 1}. Should open wallet connection popup, when registered with proper ${type.toLowerCase()} data`, async ({ + page, + wallet, + }) => { + const proposalSubmissionPage = new ProposalSubmissionPage(page); + + await proposalSubmissionPage.goto(); + + await page.getByTestId(`${type}-radio`).click(); + await proposalSubmissionPage.continueBtn.click(); + + const walletAddressBech32 = + ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + + const proposal: IProposalForm = + proposalSubmissionPage.generateValidProposalFormFields( + type, + walletAddressBech32 + ); + await proposalSubmissionPage.register({ ...proposal }); + await expect( + proposalSubmissionPage.registrationErrorModal.getByText( + "UTxO Balance Insufficient" + ) + ).toBeVisible(); + }); + }); +}); + test.describe("Review fillup form", () => { Object.values(ProposalType).map((type: ProposalType, index) => { test(`7I_${index + 1}. Should valid review submission in ${type.toLowerCase()} Proposal form`, async ({ @@ -111,7 +143,7 @@ test.describe("Review fillup form", () => { }); }); -test("7I. Should reject invalid proposal metadata", async ({ page }) => { +test("7L. Should reject invalid proposal metadata", async ({ page }) => { const invalidMetadataAnchor = "https://www.google.com"; const proposalSubmissionPage = new ProposalSubmissionPage(page); @@ -184,7 +216,9 @@ test.describe("Edit proposal form", () => { }); }); -test("7K_1. Should accept valid anchor proposal metadata", async ({ page }) => { +test("7K_1. Should accept valid metadata anchor on proposal submission", async ({ + page, +}) => { const invalidMetadataAnchor = "https://www.google.com"; const proposalSubmissionPage = new ProposalSubmissionPage(page); @@ -208,7 +242,9 @@ test("7K_1. Should accept valid anchor proposal metadata", async ({ page }) => { } }); -test("7K_2. Should reject valid anchor proposal metadata", async ({ page }) => { +test("7K_2. Should reject invalid metadata anchor on proposal submission", async ({ + page, +}) => { const invalidMetadataAnchor = "https://www.google.com"; const proposalSubmissionPage = new ProposalSubmissionPage(page); diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmissionFunctionality.proposal.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmissionFunctionality.proposal.spec.ts new file mode 100644 index 000000000..1cbf2d8ef --- /dev/null +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmissionFunctionality.proposal.spec.ts @@ -0,0 +1,44 @@ +import environments from "@constants/environments"; +import { createTempUserAuth } from "@datafactory/createAuth"; +import { test } from "@fixtures/walletExtension"; +import { setAllureEpic } from "@helpers/allure"; +import { createNewPageWithWallet } from "@helpers/page"; +import { waitForTxConfirmation } from "@helpers/transaction"; +import ProposalSubmissionPage from "@pages/proposalSubmissionPage"; +import { expect } from "@playwright/test"; +import { IProposalForm, ProposalType } from "@types"; +import walletManager from "lib/walletManager"; + +test.beforeEach(async () => { + await setAllureEpic("7. Proposal submission"); +}); + +test("7H. should submit a proposal", async ({ page, browser }, testInfo) => { + test.setTimeout(testInfo.timeout + environments.txTimeOut); + + const wallet = await walletManager.popWallet("proposalSubmission"); + + const tempUserAuth = await createTempUserAuth(page, wallet); + + const userPage = await createNewPageWithWallet(browser, { + storageState: tempUserAuth, + wallet, + }); + + const proposalSubmissionPage = new ProposalSubmissionPage(userPage); + await proposalSubmissionPage.goto(); + + await userPage.getByTestId(`${ProposalType.info}-radio`).click(); + await proposalSubmissionPage.continueBtn.click(); + + const proposal: IProposalForm = + proposalSubmissionPage.generateValidProposalFormFields(ProposalType.info); + + await proposalSubmissionPage.register({ ...proposal }); + + await expect(proposalSubmissionPage.registrationSuccessModal).toBeVisible({ + timeout: 10_000, + }); + + await waitForTxConfirmation(userPage); +}); diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmissionFunctionality.tx.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmissionFunctionality.tx.spec.ts deleted file mode 100644 index c2ed11e8d..000000000 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmissionFunctionality.tx.spec.ts +++ /dev/null @@ -1,92 +0,0 @@ -import environments from "@constants/environments"; -import { createTempUserAuth } from "@datafactory/createAuth"; -import { test } from "@fixtures/walletExtension"; -import { setAllureEpic } from "@helpers/allure"; -import { ShelleyWallet } from "@helpers/crypto"; -import { createNewPageWithWallet } from "@helpers/page"; -import { waitForTxConfirmation } from "@helpers/transaction"; -import ProposalSubmissionPage from "@pages/proposalSubmissionPage"; -import { Page, expect } from "@playwright/test"; -import { IProposalForm, ProposalType, StaticWallet } from "@types"; -import walletManager from "lib/walletManager"; - -test.beforeEach(async () => { - await setAllureEpic("7. Proposal submission"); -}); - -test.describe("Proposal submission check", () => { - let userPage: Page; - let wallet: StaticWallet; - - test.beforeEach(async ({ browser, page }, testInfo) => { - wallet = await walletManager.popWallet("adaHolder"); - - const tempUserAuth = await createTempUserAuth(page, wallet); - - userPage = await createNewPageWithWallet(browser, { - storageState: tempUserAuth, - wallet, - }); - }); - - Object.values(ProposalType).map((type: ProposalType, index) => { - test(`7G_${index + 1}. Should open wallet connection popup, when registered with proper ${type.toLowerCase()} data`, async ({ - page, - browser, - }, testInfo) => { - const proposalSubmissionPage = new ProposalSubmissionPage(userPage); - - await proposalSubmissionPage.goto(); - - await userPage.getByTestId(`${type}-radio`).click(); - await proposalSubmissionPage.continueBtn.click(); - - const walletAddressBech32 = - ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); - - const proposal: IProposalForm = - proposalSubmissionPage.generateValidProposalFormFields( - type, - walletAddressBech32 - ); - await proposalSubmissionPage.register({ ...proposal }); - await expect( - proposalSubmissionPage.registrationErrorModal.getByText( - "UTxO Balance Insufficient" - ) - ).toBeVisible(); - }); - }); -}); - -test("7H. should submit a proposal", async ({ page, browser }, testInfo) => { - test.setTimeout(testInfo.timeout + environments.txTimeOut); - - const wallet = await walletManager.popWallet("proposalSubmission"); - - const tempUserAuth = await createTempUserAuth(page, wallet); - - const userPage = await createNewPageWithWallet(browser, { - storageState: tempUserAuth, - wallet, - }); - - const proposalSubmissionPage = new ProposalSubmissionPage(userPage); - await proposalSubmissionPage.goto(); - - await userPage.getByTestId(`${ProposalType.info}-radio`).click(); - await proposalSubmissionPage.continueBtn.click(); - - const proposal: IProposalForm = - proposalSubmissionPage.generateValidProposalFormFields(ProposalType.info); - - await proposalSubmissionPage.register({ ...proposal }); - - await expect( - userPage.getByTestId("governance-action-submitted-modal") - ).toBeVisible(); - - await userPage.getByTestId("confirm-modal-button").click(); - - await waitForTxConfirmation(userPage); -}); diff --git a/tests/govtool-frontend/playwright/tests/proposal.setup.ts b/tests/govtool-frontend/playwright/tests/proposal.setup.ts new file mode 100644 index 000000000..9f7111499 --- /dev/null +++ b/tests/govtool-frontend/playwright/tests/proposal.setup.ts @@ -0,0 +1,49 @@ +import environments from "@constants/environments"; +import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { ShelleyWallet } from "@helpers/crypto"; +import { pollTransaction } from "@helpers/transaction"; +import { test as setup } from "@playwright/test"; +import kuberService from "@services/kuberService"; +import walletManager from "lib/walletManager"; + +const PROPOSAL_SUBMISSIONS_WALLETS_COUNT = 1; + +setup.beforeEach(async () => { + await setAllureEpic("Setup"); + await setAllureStory("proposal"); +}); + +async function generateWallets(num: number) { + return await Promise.all( + Array.from({ length: num }, () => + ShelleyWallet.generate().then((wallet) => wallet.json()) + ) + ); +} + +setup("Setup temporary proposal wallets", async () => { + setup.setTimeout(2 * environments.txTimeOut); + + const proposalSubmissionsWallets = await generateWallets( + PROPOSAL_SUBMISSIONS_WALLETS_COUNT + ); + + // initialize wallets + const initializeRes = await kuberService.initializeWallets([ + ...proposalSubmissionsWallets, + ]); + await pollTransaction(initializeRes.txId, initializeRes.lockInfo); + + // transfer 51_000 ADA for dRep registration + const amountOutputs = proposalSubmissionsWallets.map((wallet) => { + return { address: wallet.address, value: `${51_000}A` }; + }); + const transferRes = await kuberService.multipleTransferADA(amountOutputs); + await pollTransaction(transferRes.txId, transferRes.lockInfo); + + // save to file + await walletManager.writeWallets( + proposalSubmissionsWallets, + "proposalSubmission" + ); +});