Skip to content

Commit 7886412

Browse files
authored
Merge pull request #3841 from IntersectMBO/feat/add-hardfork-tests
Feat: add hardfork tests
2 parents 51b35e9 + 5737b24 commit 7886412

File tree

10 files changed

+131
-533
lines changed

10 files changed

+131
-533
lines changed

tests/govtool-frontend/playwright/lib/constants/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const proposal06AuthFile = ".auth/proposal06.json";
2020
export const proposal07AuthFile = ".auth/proposal07.json";
2121
export const proposal08AuthFile = ".auth/proposal08.json";
2222
export const proposal09AuthFile = ".auth/proposal09.json";
23+
export const proposal10AuthFile = ".auth/proposal10.json";
2324

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

tests/govtool-frontend/playwright/lib/constants/staticWallets.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ export const proposal06Wallet: StaticWallet = staticWallets[15];
2525
export const proposal07Wallet: StaticWallet = staticWallets[16];
2626
export const proposal08Wallet: StaticWallet = staticWallets[17];
2727
export const proposal09Wallet: StaticWallet = staticWallets[18];
28+
export const proposal10Wallet: StaticWallet = staticWallets[19];
2829

29-
export const budgetProposal01Wallet: StaticWallet = staticWallets[19];
30-
export const budgetProposal02Wallet: StaticWallet = staticWallets[20];
31-
export const budgetProposal03Wallet: StaticWallet = staticWallets[21];
32-
export const budgetProposal04Wallet: StaticWallet = staticWallets[22];
33-
export const budgetProposal05Wallet: StaticWallet = staticWallets[23];
30+
export const budgetProposal01Wallet: StaticWallet = staticWallets[20];
31+
export const budgetProposal02Wallet: StaticWallet = staticWallets[21];
32+
export const budgetProposal03Wallet: StaticWallet = staticWallets[22];
33+
export const budgetProposal04Wallet: StaticWallet = staticWallets[23];
34+
export const budgetProposal05Wallet: StaticWallet = staticWallets[24];
3435

3536
export const adaHolderWallets = [
3637
adaHolder01Wallet,

tests/govtool-frontend/playwright/lib/helpers/auth.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import {
1313
proposal07Wallet,
1414
proposal08Wallet,
1515
proposal09Wallet,
16+
proposal10Wallet,
1617
} from "@constants/staticWallets";
1718
import {
1819
proposal05AuthFile,
1920
proposal07AuthFile,
2021
proposal08AuthFile,
2122
proposal09AuthFile,
23+
proposal10AuthFile,
2224
} from "@constants/auth";
2325

2426
interface CreateUserProps {
@@ -122,5 +124,10 @@ export const getDraftProposalWalletAndState = (proposalType: string) => {
122124
storageState: proposal09AuthFile,
123125
wallet: proposal09Wallet,
124126
};
127+
case ProposalType.hardFork:
128+
return {
129+
storageState: proposal10AuthFile,
130+
wallet: proposal10Wallet,
131+
};
125132
}
126133
};

tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const formErrors = {
3030
constitutionalUrl: "prop-constitution-url-text-error",
3131
guardrailsScriptUrl: "prop-guardrails-script-url-input-error",
3232
link: "link-0-url-input-error",
33+
majorError: "major-error",
34+
minorError: "minor-error",
3335
};
3436

3537
export default class ProposalSubmissionPage {
@@ -61,6 +63,7 @@ export default class ProposalSubmissionPage {
6163
readonly motionOfNoConfidenceBtn = this.page.getByTestId(
6264
"motion of no confidence-button"
6365
);
66+
readonly hardForkBtn = this.page.getByTestId("hard fork-button");
6467
readonly editSubmissionButton = this.page.getByTestId(
6568
"edit-submission-button"
6669
);
@@ -101,6 +104,12 @@ export default class ProposalSubmissionPage {
101104
readonly closeDraftSuccessModalBtn = this.page.getByTestId("close-button");
102105
readonly linkTextInput = this.page.getByTestId("link-0-text-input");
103106
readonly linkUrlInput = this.page.getByTestId("link-0-url-input");
107+
readonly previousGAHashInput = this.page.getByTestId(
108+
"previous-ga-hash-input"
109+
);
110+
readonly previousGAIdInput = this.page.getByTestId("previous-ga-id-input");
111+
readonly majorInput = this.page.getByTestId("major-input");
112+
readonly minorInput = this.page.getByTestId("minor-input");
104113

105114
// content
106115
readonly governanceActionTypeContent = this.page.getByTestId(
@@ -125,6 +134,8 @@ export default class ProposalSubmissionPage {
125134
);
126135
readonly linkTextContent = this.page.getByTestId("link-0-text-content");
127136
readonly linkUrlContent = this.page.getByTestId("link-0-url-content");
137+
readonly majorVersionContent = this.page.getByTestId("major-version-content");
138+
readonly minorVersionContent = this.page.getByTestId("minor-version-content");
128139

129140
constructor(private readonly page: Page) {}
130141

@@ -172,9 +183,14 @@ export default class ProposalSubmissionPage {
172183
if (governanceProposal.proposal_links != null) {
173184
await this.fillProposalLinks(governanceProposal.proposal_links);
174185
}
186+
187+
if (governanceProposal.gov_action_type_id == 4) {
188+
await this.fillHardForkFields(governanceProposal);
189+
}
175190
}
176191

177192
async fillupForm(governanceProposal: ProposalCreateRequest) {
193+
console.log(governanceProposal.gov_action_type_id);
178194
await this.governanceActionType.click();
179195

180196
if (governanceProposal.gov_action_type_id === 0) {
@@ -186,8 +202,10 @@ export default class ProposalSubmissionPage {
186202
if (governanceProposal.has_guardrails) {
187203
await this.guardrailsScriptCheckbox.click();
188204
}
189-
} else {
205+
} else if (governanceProposal.gov_action_type_id === 3) {
190206
await this.motionOfNoConfidenceBtn.click();
207+
} else {
208+
await this.hardForkBtn.click();
191209
}
192210

193211
await this.fillupFormWithTypeSelected(governanceProposal);
@@ -238,6 +256,11 @@ export default class ProposalSubmissionPage {
238256
}
239257
}
240258

259+
async fillHardForkFields(hardForkProposal: ProposalCreateRequest) {
260+
await this.minorInput.fill(hardForkProposal.prop_min_version.toString());
261+
await this.majorInput.fill(hardForkProposal.prop_major_version.toString());
262+
}
263+
241264
async getAllDrafts() {
242265
await expect(
243266
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
@@ -345,6 +368,27 @@ export default class ProposalSubmissionPage {
345368
}).toBeHidden();
346369
}
347370

371+
if (governanceProposal.gov_action_type_id === 4) {
372+
const isMajorErrorVisible = await this.page
373+
.getByTestId(formErrors.majorError)
374+
.isVisible();
375+
const isMinorErrorVisible = await this.page
376+
.getByTestId(formErrors.minorError)
377+
.isVisible();
378+
379+
await expect(this.page.getByTestId(formErrors.majorError), {
380+
message: isMajorErrorVisible
381+
? "Major version error should be hidden"
382+
: "Major version error is correctly hidden",
383+
}).toBeHidden();
384+
385+
await expect(this.page.getByTestId(formErrors.minorError), {
386+
message: isMinorErrorVisible
387+
? "Minor version error should be hidden"
388+
: "Minor version error is correctly hidden",
389+
}).toBeHidden();
390+
}
391+
348392
await expect(this.page.getByTestId(formErrors.link), {
349393
message:
350394
isLinkErrorVisible &&
@@ -457,6 +501,11 @@ export default class ProposalSubmissionPage {
457501
}).toBeVisible();
458502
}
459503

504+
if (governanceProposal.gov_action_type_id === 4) {
505+
await expect(this.page.getByTestId(formErrors.majorError)).toBeVisible();
506+
await expect(this.page.getByTestId(formErrors.minorError)).toBeVisible();
507+
}
508+
460509
await expect(this.continueBtn).toBeDisabled();
461510
}
462511

@@ -512,6 +561,15 @@ export default class ProposalSubmissionPage {
512561
}
513562
}
514563
}
564+
if (proposalType == ProposalType.hardFork) {
565+
proposal.prop_min_version = faker.number
566+
.float({ min: 0, max: 100 })
567+
.toString();
568+
proposal.prop_major_version = faker.number
569+
.float({ min: 0, max: 100 })
570+
.toString();
571+
}
572+
515573
return proposal;
516574
}
517575

@@ -546,6 +604,12 @@ export default class ProposalSubmissionPage {
546604
proposal.prop_guardrails_script_url = invalid.url();
547605
proposal.prop_guardrails_script_hash = faker.string.alphanumeric(64);
548606
}
607+
608+
if (proposalType === ProposalType.hardFork) {
609+
proposal.prop_min_version = invalid.amount();
610+
proposal.prop_major_version = invalid.amount();
611+
}
612+
549613
return proposal;
550614
}
551615

tests/govtool-frontend/playwright/lib/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export enum ProposalType {
8383
treasury = "Treasury requests",
8484
updatesToTheConstitution = "Updates to the Constitution",
8585
motionOfNoConfedence = "Motion of No Confidence",
86+
hardFork = "Hard fork",
8687
}
8788

8889
export enum BootstrapGovernanceActionType {
@@ -195,6 +196,8 @@ export type ProposalCreateRequest = {
195196
prop_guardrails_script_hash?: string;
196197
has_guardrails?: boolean;
197198
is_draft: boolean;
199+
prop_min_version?: string;
200+
prop_major_version?: string;
198201
};
199202
export type ProposedGovAction = {
200203
id: number;

0 commit comments

Comments
 (0)