Skip to content

Commit 160aaf1

Browse files
JosephRana11kneerose
authored andcommitted
feat: update proposal tests to include hardfork proposal
1 parent 93b97f5 commit 160aaf1

File tree

8 files changed

+116
-7
lines changed

8 files changed

+116
-7
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: 59 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,9 @@ export default class ProposalSubmissionPage {
6163
readonly motionOfNoConfidenceBtn = this.page.getByTestId(
6264
"motion of no confidence-button"
6365
);
66+
readonly hardForkBtn = this.page.getByTestId(
67+
"hard fork-button"
68+
)
6469
readonly editSubmissionButton = this.page.getByTestId(
6570
"edit-submission-button"
6671
);
@@ -129,6 +134,8 @@ export default class ProposalSubmissionPage {
129134
);
130135
readonly linkTextContent = this.page.getByTestId("link-0-text-content");
131136
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")
132139

133140
constructor(private readonly page: Page) {}
134141

@@ -176,9 +183,15 @@ export default class ProposalSubmissionPage {
176183
if (governanceProposal.proposal_links != null) {
177184
await this.fillProposalLinks(governanceProposal.proposal_links);
178185
}
186+
187+
if(governanceProposal.gov_action_type_id == 4){
188+
await this.fillHardForkFields(governanceProposal)
189+
}
179190
}
180191

181192
async fillupForm(governanceProposal: ProposalCreateRequest) {
193+
194+
console.log(governanceProposal.gov_action_type_id)
182195
await this.governanceActionType.click();
183196

184197
if (governanceProposal.gov_action_type_id === 0) {
@@ -190,8 +203,10 @@ export default class ProposalSubmissionPage {
190203
if (governanceProposal.has_guardrails) {
191204
await this.guardrailsScriptCheckbox.click();
192205
}
193-
} else {
206+
} else if (governanceProposal.gov_action_type_id === 3) {
194207
await this.motionOfNoConfidenceBtn.click();
208+
} else {
209+
await this.hardForkBtn.click()
195210
}
196211

197212
await this.fillupFormWithTypeSelected(governanceProposal);
@@ -242,6 +257,11 @@ export default class ProposalSubmissionPage {
242257
}
243258
}
244259

260+
async fillHardForkFields(hardForkProposal : ProposalCreateRequest){
261+
await this.minorInput.fill(hardForkProposal.prop_min_version.toString())
262+
await this.majorInput.fill(hardForkProposal.prop_major_version.toString())
263+
}
264+
245265
async getAllDrafts() {
246266
await expect(
247267
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
@@ -349,6 +369,27 @@ export default class ProposalSubmissionPage {
349369
}).toBeHidden();
350370
}
351371

372+
if (governanceProposal.gov_action_type_id === 4) {
373+
const isMajorErrorVisible = await this.page
374+
.getByTestId(formErrors.majorError)
375+
.isVisible();
376+
const isMinorErrorVisible = await this.page
377+
.getByTestId(formErrors.minorError)
378+
.isVisible();
379+
380+
await expect(this.page.getByTestId(formErrors.majorError), {
381+
message: isMajorErrorVisible
382+
? 'Major version error should be hidden'
383+
: 'Major version error is correctly hidden'
384+
}).toBeHidden();
385+
386+
await expect(this.page.getByTestId(formErrors.minorError), {
387+
message: isMinorErrorVisible
388+
? 'Minor version error should be hidden'
389+
: 'Minor version error is correctly hidden'
390+
}).toBeHidden();
391+
}
392+
352393
await expect(this.page.getByTestId(formErrors.link), {
353394
message:
354395
isLinkErrorVisible &&
@@ -461,6 +502,11 @@ export default class ProposalSubmissionPage {
461502
}).toBeVisible();
462503
}
463504

505+
if (governanceProposal.gov_action_type_id === 4){
506+
await expect(this.page.getByTestId(formErrors.majorError)).toBeVisible()
507+
await expect(this.page.getByTestId(formErrors.minorError)).toBeVisible()
508+
}
509+
464510
await expect(this.continueBtn).toBeDisabled();
465511
}
466512

@@ -516,6 +562,11 @@ export default class ProposalSubmissionPage {
516562
}
517563
}
518564
}
565+
if (proposalType == ProposalType.hardFork){
566+
proposal.prop_min_version = faker.number.float({min:0 , max:100}).toString()
567+
proposal.prop_major_version = faker.number.float({min:0 , max:100}).toString()
568+
}
569+
519570
return proposal;
520571
}
521572

@@ -550,6 +601,13 @@ export default class ProposalSubmissionPage {
550601
proposal.prop_guardrails_script_url = invalid.url();
551602
proposal.prop_guardrails_script_hash = faker.string.alphanumeric(64);
552603
}
604+
605+
if (proposalType === ProposalType.hardFork){
606+
proposal.prop_min_version = invalid.amount()
607+
proposal.prop_major_version = invalid.amount()
608+
}
609+
610+
553611
return proposal;
554612
}
555613

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ export type ProposalCreateRequest = {
196196
prop_guardrails_script_hash?: string;
197197
has_guardrails?: boolean;
198198
is_draft: boolean;
199+
prop_min_version? : string;
200+
prop_major_version? : string;
199201
};
200202
export type ProposedGovAction = {
201203
id: number;

tests/govtool-frontend/playwright/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"test:headless:usersnap": "npx playwright test userSnap.spec.ts",
4545
"test:headless:misc": "npx playwright test miscellaneous",
4646
"format": "prettier . --write",
47-
"generate-wallets": "ts-node ./generate_wallets.ts 24",
47+
"generate-wallets": "ts-node ./generate_wallets.ts 25",
4848
"generate-faucet-wallet": "ts-node ./generate_faucet_wallet.ts"
4949
},
5050
"dependencies": {

tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.pd.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,18 @@ test.describe("Proposal created logged state", () => {
188188
).toHaveText(proposal.prop_guardrails_script_hash);
189189
}
190190

191+
if (type == ProposalType.hardFork){
192+
await expect(
193+
proposalSubmissionPage.majorVersionContent
194+
).toHaveText(proposal.prop_major_version)
195+
await expect(
196+
proposalSubmissionPage.minorVersionContent
197+
).toHaveText(proposal.prop_min_version)
198+
}
191199
// cleanup
192200
await proposalDetailsPage.deleteProposal();
193201
});
202+
194203
});
195204
});
196205

@@ -256,6 +265,16 @@ test.describe("Proposal created logged state", () => {
256265
proposalSubmissionPage.guardrailsScriptHashContent
257266
).toHaveText(proposal.prop_guardrails_script_hash);
258267
}
268+
269+
if (type === ProposalType.hardFork){
270+
await expect(
271+
proposalSubmissionPage.minorVersionContent
272+
).toHaveText(proposal.prop_min_version);
273+
await expect(
274+
proposalSubmissionPage.majorVersionContent
275+
).toHaveText(proposal.prop_major_version)
276+
}
277+
259278
});
260279
});
261280
});
@@ -435,6 +454,15 @@ test.describe("Proposal Draft", () => {
435454
).toHaveValue(proposalFormValue.prop_guardrails_script_hash);
436455
}
437456

457+
if (createProposalType === ProposalType.hardFork) {
458+
await expect(proposalSubmissionPage.majorInput).toHaveValue(
459+
proposalFormValue.prop_major_version
460+
)
461+
await expect(proposalSubmissionPage.minorInput).toHaveValue(
462+
proposalFormValue.prop_min_version
463+
)
464+
}
465+
438466
await expect(proposalSubmissionPage.linkUrlInput).toHaveValue(
439467
proposalFormValue.proposal_links[0].prop_link
440468
);
@@ -518,6 +546,15 @@ test.describe("Proposal Draft", () => {
518546
proposalSubmissionPage.guardrailsScriptHashContent
519547
).toHaveText(proposalFormValue.prop_guardrails_script_hash);
520548
}
549+
550+
if (proposalType === ProposalType.hardFork) {
551+
await expect(proposalSubmissionPage.majorVersionContent).toHaveText(
552+
proposalFormValue.prop_major_version
553+
)
554+
await expect(proposalSubmissionPage.minorVersionContent).toHaveText(
555+
proposalFormValue.prop_min_version
556+
)
557+
}
521558
});
522559
});
523560

tests/govtool-frontend/playwright/tests/proposal-discussion.auth.setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
proposal07Wallet,
1212
proposal08Wallet,
1313
proposal09Wallet,
14+
proposal10Wallet,
1415
} from "@constants/staticWallets";
1516
import {
1617
proposal01AuthFile,
@@ -22,6 +23,7 @@ import {
2223
proposal07AuthFile,
2324
proposal08AuthFile,
2425
proposal09AuthFile,
26+
proposal10AuthFile,
2527
} from "@constants/auth";
2628

2729
setup.beforeEach(async () => {
@@ -39,6 +41,7 @@ const proposalSetups = [
3941
{ name: "Proposal 07", wallet: proposal07Wallet, auth: proposal07AuthFile },
4042
{ name: "Proposal 08", wallet: proposal08Wallet, auth: proposal08AuthFile },
4143
{ name: "Proposal 09", wallet: proposal09Wallet, auth: proposal09AuthFile },
44+
{ name: "Proposal 10", wallet: proposal10Wallet, auth: proposal10AuthFile }
4245
];
4346

4447
for (const { name, wallet, auth } of proposalSetups) {

0 commit comments

Comments
 (0)