Skip to content

Commit

Permalink
Merge pull request #1217 from IntersectMBO/fix/proposal-submission-wa…
Browse files Browse the repository at this point in the history
…llet-issue

Fix/proposal submission wallet issue
  • Loading branch information
NabinKawan authored Jun 12, 2024
2 parents d359595 + b12e03d commit 4c9f2b9
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions tests/govtool-frontend/playwright/lib/walletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions tests/govtool-frontend/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"] },
Expand Down Expand Up @@ -92,6 +105,7 @@ export default defineConfig({
"**/*.loggedin.spec.ts",
"**/*.dRep.spec.ts",
"**/*.tx.spec.ts",
"**/*.proposal.spec.ts",
],
},
{
Expand All @@ -102,6 +116,7 @@ export default defineConfig({
"**/*.dRep.spec.ts",
"**/*.delegation.spec.ts",
"**/*.tx.spec.ts",
"**/*.proposal.spec.ts",
"**/walletConnect.spec.ts",
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);

Expand All @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 ({
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});

This file was deleted.

Loading

0 comments on commit 4c9f2b9

Please sign in to comment.