Skip to content

Commit d399787

Browse files
authored
Merge pull request #2492 from IntersectMBO/bugfix/proposal-test
Proposal Draft Input Validation and Content Test Refactor
2 parents e073eb7 + c4d77ee commit d399787

File tree

2 files changed

+84
-35
lines changed

2 files changed

+84
-35
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ export default class ProposalSubmissionPage {
6868
);
6969
readonly amountInput = this.page.getByTestId("amount-0-text-input");
7070
readonly closeDraftSuccessModalBtn = this.page.getByTestId("close-button");
71+
readonly linkTextInput = this.page.getByTestId("link-0-text-input");
72+
readonly linkUrlInput = this.page.getByTestId("link-0-url-input");
73+
74+
// content
75+
readonly governanceActionTypeContent = this.page.getByTestId(
76+
"governance-action-type-content"
77+
);
78+
readonly titleContent = this.page.getByTestId("title-content");
79+
readonly abstractContent = this.page.getByTestId("abstract-content");
80+
readonly motivationContent = this.page.getByTestId("motivation-content");
81+
readonly rationaleContent = this.page.getByTestId("rationale-content");
82+
readonly receivingAddressContent = this.page.getByTestId(
83+
"receiving-address-0-content"
84+
);
85+
readonly amountContent = this.page.getByTestId("amount-0-content");
86+
readonly linkTextContent = this.page.getByTestId("link-0-text-content");
87+
readonly linkUrlContent = this.page.getByTestId("link-0-url-content");
7188

7289
constructor(private readonly page: Page) {}
7390

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

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,22 @@ test.describe("Proposal created logged state", () => {
140140
await proposalSubmissionPage.submitBtn.click();
141141

142142
await expect(page.getByTestId("submit-as-GA-button")).toBeVisible();
143-
await expect(page.getByTestId("title-content")).toHaveText(
143+
await expect(proposalSubmissionPage.titleContent).toHaveText(
144144
proposal.prop_name
145145
);
146146
await expect(
147-
page.getByTestId("governance-action-type-content")
147+
proposalSubmissionPage.governanceActionTypeContent
148148
).toHaveText(type);
149-
await expect(page.getByTestId("abstract-content")).toHaveText(
149+
await expect(proposalSubmissionPage.abstractContent).toHaveText(
150150
proposal.prop_abstract
151151
);
152-
await expect(page.getByTestId("motivation-content")).toHaveText(
152+
await expect(proposalSubmissionPage.motivationContent).toHaveText(
153153
proposal.prop_motivation
154154
);
155-
await expect(page.getByTestId("rationale-content")).toHaveText(
155+
await expect(proposalSubmissionPage.rationaleContent).toHaveText(
156156
proposal.prop_rationale
157157
);
158-
await expect(page.getByTestId("link-0-text-content")).toHaveText(
158+
await expect(proposalSubmissionPage.linkTextContent).toHaveText(
159159
proposal.proposal_links[0].prop_link_text
160160
);
161161
});
@@ -187,28 +187,28 @@ test.describe("Proposal created logged state", () => {
187187
await proposalSubmissionPage.continueBtn.click();
188188

189189
await expect(
190-
page.getByTestId("governance-action-type-content")
190+
proposalSubmissionPage.governanceActionTypeContent
191191
).toHaveText(type);
192-
await expect(page.getByTestId("title-content")).toHaveText(
192+
await expect(proposalSubmissionPage.titleContent).toHaveText(
193193
proposal.prop_name
194194
);
195-
await expect(page.getByTestId("abstract-content")).toHaveText(
195+
await expect(proposalSubmissionPage.abstractContent).toHaveText(
196196
proposal.prop_abstract
197197
);
198-
await expect(page.getByTestId("motivation-content")).toHaveText(
198+
await expect(proposalSubmissionPage.motivationContent).toHaveText(
199199
proposal.prop_motivation
200200
);
201-
await expect(page.getByTestId("rationale-content")).toHaveText(
201+
await expect(proposalSubmissionPage.rationaleContent).toHaveText(
202202
proposal.prop_rationale
203203
);
204-
await expect(page.getByTestId("link-0-text-content")).toHaveText(
204+
await expect(proposalSubmissionPage.linkTextContent).toHaveText(
205205
proposal.proposal_links[0].prop_link_text
206206
);
207207
if (type === ProposalType.treasury) {
208208
await expect(
209-
page.getByTestId("receiving-address-content")
209+
proposalSubmissionPage.receivingAddressContent
210210
).toHaveText(proposal.prop_receiving_address);
211-
await expect(page.getByTestId("amount-content")).toHaveText(
211+
await expect(proposalSubmissionPage.amountContent).toHaveText(
212212
proposal.prop_amount
213213
);
214214
}
@@ -330,13 +330,45 @@ test.describe("Info Proposal Draft", () => {
330330

331331
const proposalSubmissionPage = new ProposalSubmissionPage(page);
332332
const { proposalFormValue } = await proposalSubmissionPage.createDraft(
333-
ProposalType.info
333+
ProposalType.treasury
334334
);
335335
const draftCard = proposalSubmissionPage.getFirstDraft();
336336
const draftCardAllInnerText = await (await draftCard).allInnerTexts();
337337

338338
expect(draftCardAllInnerText.includes(proposalFormValue.prop_name));
339339
expect(draftCardAllInnerText.includes(proposalFormValue.prop_abstract));
340+
341+
(await draftCard)
342+
.locator('[data-testid^="draft-"][data-testid$="-start-editing"]')
343+
.click();
344+
345+
await expect(proposalSubmissionPage.governanceActionType).toHaveText(
346+
ProposalType.treasury
347+
);
348+
await expect(proposalSubmissionPage.titleInput).toHaveValue(
349+
proposalFormValue.prop_name
350+
);
351+
await expect(proposalSubmissionPage.abstractInput).toHaveValue(
352+
proposalFormValue.prop_abstract
353+
);
354+
await expect(proposalSubmissionPage.motivationInput).toHaveValue(
355+
proposalFormValue.prop_motivation
356+
);
357+
await expect(proposalSubmissionPage.rationaleInput).toHaveValue(
358+
proposalFormValue.prop_rationale
359+
);
360+
await expect(proposalSubmissionPage.receivingAddressInput).toHaveValue(
361+
proposalFormValue.prop_receiving_address
362+
);
363+
await expect(proposalSubmissionPage.amountInput).toHaveValue(
364+
proposalFormValue.prop_amount
365+
);
366+
await expect(proposalSubmissionPage.linkUrlInput).toHaveValue(
367+
proposalFormValue.proposal_links[0].prop_link
368+
);
369+
await expect(proposalSubmissionPage.linkTextInput).toHaveValue(
370+
proposalFormValue.proposal_links[0].prop_link_text
371+
);
340372
});
341373

342374
test("7M_1. Should edit a info proposal draft", async ({ browser }) => {
@@ -355,20 +387,20 @@ test.describe("Info Proposal Draft", () => {
355387
await proposalSubmissionPage.titleInput.fill(newTitle);
356388
await proposalSubmissionPage.continueBtn.click();
357389

358-
await expect(page.getByTestId("governance-action-type-content")).toHaveText(
390+
await expect(proposalSubmissionPage.governanceActionTypeContent).toHaveText(
359391
ProposalType.info
360392
);
361-
await expect(page.getByTestId("title-content")).toHaveText(newTitle);
362-
await expect(page.getByTestId("abstract-content")).toHaveText(
393+
await expect(proposalSubmissionPage.titleContent).toHaveText(newTitle);
394+
await expect(proposalSubmissionPage.abstractContent).toHaveText(
363395
proposalFormValue.prop_abstract
364396
);
365-
await expect(page.getByTestId("motivation-content")).toHaveText(
397+
await expect(proposalSubmissionPage.motivationContent).toHaveText(
366398
proposalFormValue.prop_motivation
367399
);
368-
await expect(page.getByTestId("rationale-content")).toHaveText(
400+
await expect(proposalSubmissionPage.rationaleContent).toHaveText(
369401
proposalFormValue.prop_rationale
370402
);
371-
await expect(page.getByTestId("link-0-text-content")).toHaveText(
403+
await expect(proposalSubmissionPage.linkTextContent).toHaveText(
372404
proposalFormValue.proposal_links[0].prop_link_text
373405
);
374406
});
@@ -389,22 +421,22 @@ test.describe("Info Proposal Draft", () => {
389421
await proposalSubmissionPage.submitBtn.click();
390422

391423
await expect(page.getByTestId("submit-as-GA-button")).toBeVisible();
392-
await expect(page.getByTestId("title-content")).toHaveText(
424+
await expect(proposalSubmissionPage.titleContent).toHaveText(
393425
proposalFormValue.prop_name
394426
);
395-
await expect(page.getByTestId("governance-action-type-content")).toHaveText(
427+
await expect(proposalSubmissionPage.governanceActionTypeContent).toHaveText(
396428
ProposalType.info
397429
);
398-
await expect(page.getByTestId("abstract-content")).toHaveText(
430+
await expect(proposalSubmissionPage.abstractContent).toHaveText(
399431
proposalFormValue.prop_abstract
400432
);
401-
await expect(page.getByTestId("motivation-content")).toHaveText(
433+
await expect(proposalSubmissionPage.motivationContent).toHaveText(
402434
proposalFormValue.prop_motivation
403435
);
404-
await expect(page.getByTestId("rationale-content")).toHaveText(
436+
await expect(proposalSubmissionPage.rationaleContent).toHaveText(
405437
proposalFormValue.prop_rationale
406438
);
407-
await expect(page.getByTestId("link-0-text-content")).toHaveText(
439+
await expect(proposalSubmissionPage.linkTextContent).toHaveText(
408440
proposalFormValue.proposal_links[0].prop_link_text
409441
);
410442
});
@@ -427,26 +459,26 @@ test.describe("Treasury Proposal Draft", () => {
427459
await proposalSubmissionPage.titleInput.fill(newTitle);
428460
await proposalSubmissionPage.continueBtn.click();
429461

430-
await expect(page.getByTestId("governance-action-type-content")).toHaveText(
462+
await expect(proposalSubmissionPage.governanceActionTypeContent).toHaveText(
431463
ProposalType.treasury
432464
);
433-
await expect(page.getByTestId("title-content")).toHaveText(newTitle);
434-
await expect(page.getByTestId("abstract-content")).toHaveText(
465+
await expect(proposalSubmissionPage.titleContent).toHaveText(newTitle);
466+
await expect(proposalSubmissionPage.abstractContent).toHaveText(
435467
proposalFormValue.prop_abstract
436468
);
437-
await expect(page.getByTestId("motivation-content")).toHaveText(
469+
await expect(proposalSubmissionPage.motivationContent).toHaveText(
438470
proposalFormValue.prop_motivation
439471
);
440-
await expect(page.getByTestId("rationale-content")).toHaveText(
472+
await expect(proposalSubmissionPage.rationaleContent).toHaveText(
441473
proposalFormValue.prop_rationale
442474
);
443-
await expect(page.getByTestId("receiving-address-content")).toHaveText(
475+
await expect(proposalSubmissionPage.receivingAddressContent).toHaveText(
444476
proposalFormValue.prop_receiving_address
445477
);
446-
await expect(page.getByTestId("amount-content")).toHaveText(
478+
await expect(proposalSubmissionPage.amountContent).toHaveText(
447479
proposalFormValue.prop_amount
448480
);
449-
await expect(page.getByTestId("link-0-text-content")).toHaveText(
481+
await expect(proposalSubmissionPage.linkTextContent).toHaveText(
450482
proposalFormValue.proposal_links[0].prop_link_text
451483
);
452484
});

0 commit comments

Comments
 (0)