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
1 change: 1 addition & 0 deletions tests/govtool-frontend/playwright/lib/constants/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const proposal06AuthFile = ".auth/proposal06.json";
export const proposal07AuthFile = ".auth/proposal07.json";
export const proposal08AuthFile = ".auth/proposal08.json";
export const proposal09AuthFile = ".auth/proposal09.json";
export const proposal10AuthFile = ".auth/proposal10.json";

export const proposalSubmissionAuthFile = ".auth/proposalSubmission.json";

Expand Down
11 changes: 6 additions & 5 deletions tests/govtool-frontend/playwright/lib/constants/staticWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export const proposal06Wallet: StaticWallet = staticWallets[15];
export const proposal07Wallet: StaticWallet = staticWallets[16];
export const proposal08Wallet: StaticWallet = staticWallets[17];
export const proposal09Wallet: StaticWallet = staticWallets[18];
export const proposal10Wallet: StaticWallet = staticWallets[19];

export const budgetProposal01Wallet: StaticWallet = staticWallets[19];
export const budgetProposal02Wallet: StaticWallet = staticWallets[20];
export const budgetProposal03Wallet: StaticWallet = staticWallets[21];
export const budgetProposal04Wallet: StaticWallet = staticWallets[22];
export const budgetProposal05Wallet: StaticWallet = staticWallets[23];
export const budgetProposal01Wallet: StaticWallet = staticWallets[20];
export const budgetProposal02Wallet: StaticWallet = staticWallets[21];
export const budgetProposal03Wallet: StaticWallet = staticWallets[22];
export const budgetProposal04Wallet: StaticWallet = staticWallets[23];
export const budgetProposal05Wallet: StaticWallet = staticWallets[24];

export const adaHolderWallets = [
adaHolder01Wallet,
Expand Down
7 changes: 7 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
proposal07Wallet,
proposal08Wallet,
proposal09Wallet,
proposal10Wallet,
} from "@constants/staticWallets";
import {
proposal05AuthFile,
proposal07AuthFile,
proposal08AuthFile,
proposal09AuthFile,
proposal10AuthFile,
} from "@constants/auth";

interface CreateUserProps {
Expand Down Expand Up @@ -122,5 +124,10 @@ export const getDraftProposalWalletAndState = (proposalType: string) => {
storageState: proposal09AuthFile,
wallet: proposal09Wallet,
};
case ProposalType.hardFork:
return {
storageState: proposal10AuthFile,
wallet: proposal10Wallet,
};
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const formErrors = {
constitutionalUrl: "prop-constitution-url-text-error",
guardrailsScriptUrl: "prop-guardrails-script-url-input-error",
link: "link-0-url-input-error",
majorError: "major-error",
minorError: "minor-error",
};

export default class ProposalSubmissionPage {
Expand Down Expand Up @@ -61,6 +63,7 @@ export default class ProposalSubmissionPage {
readonly motionOfNoConfidenceBtn = this.page.getByTestId(
"motion of no confidence-button"
);
readonly hardForkBtn = this.page.getByTestId("hard fork-button");
readonly editSubmissionButton = this.page.getByTestId(
"edit-submission-button"
);
Expand Down Expand Up @@ -101,6 +104,12 @@ export default class ProposalSubmissionPage {
readonly closeDraftSuccessModalBtn = this.page.getByTestId("close-button");
readonly linkTextInput = this.page.getByTestId("link-0-text-input");
readonly linkUrlInput = this.page.getByTestId("link-0-url-input");
readonly previousGAHashInput = this.page.getByTestId(
"previous-ga-hash-input"
);
readonly previousGAIdInput = this.page.getByTestId("previous-ga-id-input");
readonly majorInput = this.page.getByTestId("major-input");
readonly minorInput = this.page.getByTestId("minor-input");

// content
readonly governanceActionTypeContent = this.page.getByTestId(
Expand All @@ -125,6 +134,8 @@ export default class ProposalSubmissionPage {
);
readonly linkTextContent = this.page.getByTestId("link-0-text-content");
readonly linkUrlContent = this.page.getByTestId("link-0-url-content");
readonly majorVersionContent = this.page.getByTestId("major-version-content");
readonly minorVersionContent = this.page.getByTestId("minor-version-content");

constructor(private readonly page: Page) {}

Expand Down Expand Up @@ -172,9 +183,14 @@ export default class ProposalSubmissionPage {
if (governanceProposal.proposal_links != null) {
await this.fillProposalLinks(governanceProposal.proposal_links);
}

if (governanceProposal.gov_action_type_id == 4) {
await this.fillHardForkFields(governanceProposal);
}
}

async fillupForm(governanceProposal: ProposalCreateRequest) {
console.log(governanceProposal.gov_action_type_id);
await this.governanceActionType.click();

if (governanceProposal.gov_action_type_id === 0) {
Expand All @@ -186,8 +202,10 @@ export default class ProposalSubmissionPage {
if (governanceProposal.has_guardrails) {
await this.guardrailsScriptCheckbox.click();
}
} else {
} else if (governanceProposal.gov_action_type_id === 3) {
await this.motionOfNoConfidenceBtn.click();
} else {
await this.hardForkBtn.click();
}

await this.fillupFormWithTypeSelected(governanceProposal);
Expand Down Expand Up @@ -238,6 +256,11 @@ export default class ProposalSubmissionPage {
}
}

async fillHardForkFields(hardForkProposal: ProposalCreateRequest) {
await this.minorInput.fill(hardForkProposal.prop_min_version.toString());
await this.majorInput.fill(hardForkProposal.prop_major_version.toString());
}

async getAllDrafts() {
await expect(
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
Expand Down Expand Up @@ -345,6 +368,27 @@ export default class ProposalSubmissionPage {
}).toBeHidden();
}

if (governanceProposal.gov_action_type_id === 4) {
const isMajorErrorVisible = await this.page
.getByTestId(formErrors.majorError)
.isVisible();
const isMinorErrorVisible = await this.page
.getByTestId(formErrors.minorError)
.isVisible();

await expect(this.page.getByTestId(formErrors.majorError), {
message: isMajorErrorVisible
? "Major version error should be hidden"
: "Major version error is correctly hidden",
}).toBeHidden();

await expect(this.page.getByTestId(formErrors.minorError), {
message: isMinorErrorVisible
? "Minor version error should be hidden"
: "Minor version error is correctly hidden",
}).toBeHidden();
}

await expect(this.page.getByTestId(formErrors.link), {
message:
isLinkErrorVisible &&
Expand Down Expand Up @@ -457,6 +501,11 @@ export default class ProposalSubmissionPage {
}).toBeVisible();
}

if (governanceProposal.gov_action_type_id === 4) {
await expect(this.page.getByTestId(formErrors.majorError)).toBeVisible();
await expect(this.page.getByTestId(formErrors.minorError)).toBeVisible();
}

await expect(this.continueBtn).toBeDisabled();
}

Expand Down Expand Up @@ -512,6 +561,15 @@ export default class ProposalSubmissionPage {
}
}
}
if (proposalType == ProposalType.hardFork) {
proposal.prop_min_version = faker.number
.float({ min: 0, max: 100 })
.toString();
proposal.prop_major_version = faker.number
.float({ min: 0, max: 100 })
.toString();
}

return proposal;
}

Expand Down Expand Up @@ -546,6 +604,12 @@ export default class ProposalSubmissionPage {
proposal.prop_guardrails_script_url = invalid.url();
proposal.prop_guardrails_script_hash = faker.string.alphanumeric(64);
}

if (proposalType === ProposalType.hardFork) {
proposal.prop_min_version = invalid.amount();
proposal.prop_major_version = invalid.amount();
}

return proposal;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export enum ProposalType {
treasury = "Treasury requests",
updatesToTheConstitution = "Updates to the Constitution",
motionOfNoConfedence = "Motion of No Confidence",
hardFork = "Hard fork",
}

export enum BootstrapGovernanceActionType {
Expand Down Expand Up @@ -195,6 +196,8 @@ export type ProposalCreateRequest = {
prop_guardrails_script_hash?: string;
has_guardrails?: boolean;
is_draft: boolean;
prop_min_version?: string;
prop_major_version?: string;
};
export type ProposedGovAction = {
id: number;
Expand Down
Loading