Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/govtool-frontend/playwright/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ FAUCET_ADDRESS=
FAUCET_PAYMENT_PRIVATE=
FAUCET_STAKE_PRIVATE=

IS_HARDFORK_PROPOSAL_ENABLED=false

CI=true
TEST_WORKERS=6 // Number of workers to run in parallel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const environments = {
(process.env.SCHEDULED_WORKFLOW &&
process.env.SCHEDULED_WORKFLOW == "true") ||
false,
isHardforkProposalEnabled:
process.env.IS_HARDFORK_PROPOSAL_ENABLED === "true" || false,
};

export default environments;
19 changes: 19 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import environments from "@constants/environments";
import { ProposalType } from "@types";
export const parseVotingPowerAndPercentage = (
combinedString: string
): { votingPower: string; percentage: string } => {
Expand Down Expand Up @@ -27,3 +28,21 @@ export const getWalletConfigForFaucet = () => {
address: environments.faucet.address || "",
};
};


export const getProposalType = () => {
return Object.values(ProposalType).filter(
(type) =>
!(
environments.isHardforkProposalEnabled === false &&
type === ProposalType.hardFork
)
);
};

export const getProposalWalletCount = (): number => {
if (environments.isScheduled) {
return 1;
}
return environments.isHardforkProposalEnabled ? 6 : 5;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { faker } from "@faker-js/faker";
import { isBootStrapingPhase } from "@helpers/cardano";
import { ShelleyWallet } from "@helpers/crypto";
import { expectWithInfo } from "@helpers/exceptionHandler";
import { getProposalType } from "@helpers/index";
import {
downloadMetadata,
uploadScriptAndGenerateUrl,
Expand Down Expand Up @@ -615,8 +616,8 @@ export default class ProposalSubmissionPage {

async createProposal(
receivingAddress: string,
proposalType: ProposalType = Object.values(ProposalType)[
Math.floor(Math.random() * Object.values(ProposalType).length)
proposalType: ProposalType = getProposalType()[
Math.floor(Math.random() * getProposalType().length)
]
): Promise<number> {
await this.addLinkBtn.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ProposalType } from "@types";
import walletManager from "lib/walletManager";
import { valid as mockValid, invalid as mockInvalid } from "@mock/index";
import { rewardAddressBech32 } from "@helpers/shellyWallet";
import { getWalletConfigForFaucet } from "@helpers/index";
import { getProposalType, getWalletConfigForFaucet } from "@helpers/index";
import { faker } from "@faker-js/faker";
import { proposalSubmissionAuthFile } from "@constants/auth";
import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage";
Expand All @@ -28,7 +28,7 @@ test.beforeEach(async () => {
await skipIfTemporyWalletIsNotAvailable("proposalSubmissionWallets.json");
});

Object.values(ProposalType).forEach((proposalType, index) => {
getProposalType().forEach((proposalType, index) => {
test(`7H_${index + 1}. Should submit a ${proposalType.toLocaleLowerCase()} proposal as governance action`, async ({
page,
browser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
skipIfMainnet,
} from "@helpers/cardano";
import { ShelleyWallet } from "@helpers/crypto";
import { getProposalType } from "@helpers/index";
import { createNewPageWithWallet } from "@helpers/page";
import { rewardAddressBech32 } from "@helpers/shellyWallet";
import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage";
Expand All @@ -42,12 +43,13 @@ test.describe("Proposal created logged state", () => {
});

test.describe("Accept valid data", () => {
Object.values(ProposalType).map((type: ProposalType, index) => {
getProposalType().map((type: ProposalType, index) => {
test(`7E_${index + 1}. Should accept valid data in ${type.toLowerCase()} proposal form`, async ({
page,
}) => {
await skipIfNotInfoAndBootstrapping(type);


test.slow(); // Brute-force testing with 50 random data

const proposalSubmissionPage = new ProposalSubmissionPage(page);
Expand Down Expand Up @@ -99,7 +101,7 @@ test.describe("Proposal created logged state", () => {
});

test.describe("Reject invalid data", () => {
Object.values(ProposalType).map((type: ProposalType, index) => {
getProposalType().map((type: ProposalType, index) => {
test(`7F_${index + 1}. Should reject invalid data in ${type.toLowerCase()} Proposal form`, async ({
page,
}) => {
Expand Down Expand Up @@ -128,7 +130,7 @@ test.describe("Proposal created logged state", () => {
});

test.describe("Create a proposal with proper data", () => {
Object.values(ProposalType).map((type: ProposalType, index) => {
getProposalType().map((type: ProposalType, index) => {
test(`7G_${index + 1}. Should create a proposal with proper ${type.toLowerCase()} data`, async ({
page,
wallet,
Expand Down Expand Up @@ -203,7 +205,7 @@ test.describe("Proposal created logged state", () => {
});

test.describe("Review fillup form", () => {
Object.values(ProposalType).map((type: ProposalType, index) => {
getProposalType().map((type: ProposalType, index) => {
test(`7I_${index + 1}. Should valid review submission in ${type.toLowerCase()} Proposal form`, async ({
page,
}) => {
Expand Down Expand Up @@ -278,7 +280,7 @@ test.describe("Proposal created logged state", () => {
});

test.describe("Verify Proposal form", () => {
Object.values(ProposalType).map((type: ProposalType, index) => {
getProposalType().map((type: ProposalType, index) => {
test(`7D_${index + 1}. Verify ${type.toLocaleLowerCase()} proposal form`, async ({
page,
}) => {
Expand Down Expand Up @@ -378,9 +380,7 @@ test.describe("Proposal Draft", () => {
});
const proposalSubmissionPage = new ProposalSubmissionPage(page);
const proposalType =
Object.values(ProposalType)[
Math.floor(Math.random() * Object.values(ProposalType).length)
];
getProposalType()[Math.floor(Math.random() * getProposalType().length)];
await proposalSubmissionPage.createDraft(proposalType);
const getAllDrafts = await proposalSubmissionPage.getAllDrafts();

Expand All @@ -395,9 +395,7 @@ test.describe("Proposal Draft", () => {
});

const proposalType =
Object.values(ProposalType)[
Math.floor(Math.random() * Object.values(ProposalType).length)
];
getProposalType()[Math.floor(Math.random() * getProposalType().length)];

const proposalSubmissionPage = new ProposalSubmissionPage(page);
const createProposalType = (await isBootStrapingPhase())
Expand Down Expand Up @@ -470,7 +468,7 @@ test.describe("Proposal Draft", () => {
);
});

Object.values(ProposalType).map((proposalType, index) => {
getProposalType().map((proposalType, index) => {
test(`7M_${index + 1}. Should edit a ${proposalType.toLowerCase()} proposal draft`, async ({
browser,
}) => {
Expand Down Expand Up @@ -567,9 +565,7 @@ test.describe("Proposal Draft", () => {
test.slow();

const proposalType =
Object.values(ProposalType)[
Math.floor(Math.random() * Object.values(ProposalType).length)
];
getProposalType()[Math.floor(Math.random() * getProposalType().length)];

const proposalSubmissionPage = new ProposalSubmissionPage(page);
const { proposalFormValue } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { faker } from "@faker-js/faker";
import { test } from "@fixtures/proposal";
import { setAllureEpic } from "@helpers/allure";
import { isBootStrapingPhase } from "@helpers/cardano";
import { getProposalType } from "@helpers/index";
import { injectLogger } from "@helpers/page";
import { extractProposalIdFromUrl } from "@helpers/string";
import { functionWaitedAssert } from "@helpers/waitedLoop";
Expand Down Expand Up @@ -55,9 +56,7 @@ test.describe("Filter and sort proposals", () => {

// proposal type filter
await proposalDiscussionPage.applyAndValidateFilters(
isBootStraping
? BOOTSTRAP_PROPOSAL_TYPE_FILTERS
: Object.values(ProposalType),
isBootStraping ? BOOTSTRAP_PROPOSAL_TYPE_FILTERS : getProposalType(),
proposalDiscussionPage._validateTypeFiltersInProposalCard
);

Expand Down Expand Up @@ -171,7 +170,7 @@ test("8D. Should show the view-all categorized proposed governance actions.", as
browser,
}) => {
await Promise.all(
Object.values(ProposalType).map(async (proposalType: string) => {
getProposalType().map(async (proposalType: string) => {
const context = await browser.newContext();
const page = await context.newPage();
injectLogger(page);
Expand Down
7 changes: 5 additions & 2 deletions tests/govtool-frontend/playwright/tests/proposal.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import { test as setup } from "@fixtures/walletExtension";
import kuberService from "@services/kuberService";
import walletManager from "lib/walletManager";
import { functionWaitedAssert } from "@helpers/waitedLoop";
import { getWalletConfigForFaucet } from "@helpers/index";
import {
getProposalWalletCount,
getWalletConfigForFaucet,
} from "@helpers/index";
import { createKeyFromPrivateKeyHex } from "@helpers/crypto";

const PROPOSAL_WALLETS_COUNT = environments.isScheduled ? 1 : 6;
const PROPOSAL_WALLETS_COUNT = getProposalWalletCount();

let govActionDeposit: number;

Expand Down
Loading