Skip to content

Commit dad65fa

Browse files
committed
tests: create and view draft bidget proposal
1 parent 4a5bf1a commit dad65fa

File tree

4 files changed

+134
-56
lines changed

4 files changed

+134
-56
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const proposal08Wallet: StaticWallet = staticWallets[18];
2929
export const proposal09Wallet: StaticWallet = staticWallets[19];
3030

3131
export const budgetProposal01Wallet: StaticWallet = staticWallets[20];
32+
export const budgetProposal02Wallet: StaticWallet = staticWallets[21];
3233

3334
export const adaHolderWallets = [
3435
adaHolder01Wallet,

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

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ export default class BudgetDiscussionSubmissionPage {
3939
readonly createBudgetProposalBtn = this.page.getByTestId(
4040
"propose-a-budget-discussion-button"
4141
);
42+
readonly closeDraftBtn = this.page.getByTestId("close-button");
43+
readonly cancelBtn = this.page.getByTestId("cancel-button");
4244

4345
readonly continueBtn = this.page.getByTestId("continue-button");
4446
readonly addLinkBtn = this.page.getByTestId("add-link-button");
4547
readonly verifyIdentityBtn = this.page.getByTestId("verify-identity-button");
46-
readonly saveDraftBtn = this.page.getByTestId("save-draft-button");
48+
readonly saveDraftBtn = this.page.getByTestId("draft-button");
4749
readonly submitBtn = this.page.getByTestId("submit-button");
4850
readonly countryOfIncorporationBtn = this.page.getByTestId(
4951
"country-of-incorporation"
@@ -380,33 +382,36 @@ export default class BudgetDiscussionSubmissionPage {
380382

381383
async getAllDrafts() {
382384
await expect(
383-
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
385+
this.page
386+
.locator('[data-testid^="draft-"][data-testid$="-proposal"]')
387+
.first()
384388
).toBeVisible({ timeout: 60_000 }); // slow rendering
385389

386390
return await this.page
387-
.locator('[data-testid^="draft-"][data-testid$="-card"]')
391+
.locator('[data-testid^="draft-"][data-testid$="-proposal"]')
388392
.all();
389393
}
390394

391395
async getFirstDraft() {
392396
await expect(
393-
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]').first()
397+
this.page
398+
.locator('[data-testid^="draft-"][data-testid$="-proposal"]')
399+
.first()
394400
).toBeVisible({ timeout: 60_000 }); // slow rendering
395401

396402
return this.page
397-
.locator('[data-testid^="draft-"][data-testid$="-card"]')
403+
.locator('[data-testid^="draft-"][data-testid$="-proposal"]')
398404
.first();
399405
}
400406

401-
async viewFirstDraft() {
407+
async viewLastDraft() {
402408
await expect(
403-
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
409+
this.page
410+
.locator('[data-testid^="draft-"][data-testid$="-proposal"]')
411+
.last()
404412
).toBeVisible({ timeout: 60_000 }); // slow rendering
405413

406-
return await this.page
407-
.locator('[data-testid^="draft-"][data-testid$="-start-editing"]')
408-
.first()
409-
.click();
414+
return await this.page.getByTestId("draft-start-editing").last().click();
410415
}
411416

412417
generateValidBudgetProposalContactInformation(): BudgetProposalContactInformationProps {
@@ -521,6 +526,25 @@ export default class BudgetDiscussionSubmissionPage {
521526
};
522527
}
523528

529+
async createDraftBudgetProposal(fillAllDetails = false) {
530+
const budgetProposal = this.generateValidBudgetProposalInformation();
531+
532+
if (fillAllDetails) {
533+
await this.fillupForm(budgetProposal);
534+
} else {
535+
await this.fillupContactInformationForm(
536+
budgetProposal.contactInformation
537+
);
538+
}
539+
540+
await this.saveDraftBtn.click();
541+
await this.closeDraftBtn.click();
542+
await this.cancelBtn.click();
543+
await this.createBudgetProposalBtn.click();
544+
545+
return fillAllDetails ? budgetProposal : budgetProposal.contactInformation;
546+
}
547+
524548
async createBudgetProposal(): Promise<number> {
525549
const budgetProposalRequest: BudgetProposalProps =
526550
this.generateValidBudgetProposalInformation();
Lines changed: 87 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,101 @@
1-
import { budgetProposal01Wallet } from "@constants/staticWallets";
2-
import { test } from "@fixtures/walletExtension";
1+
import {
2+
budgetProposal01Wallet,
3+
budgetProposal02Wallet,
4+
} from "@constants/staticWallets";
5+
import { test } from "@fixtures/budgetProposal";
36
import { setAllureEpic } from "@helpers/allure";
7+
import { createNewPageWithWallet } from "@helpers/page";
48
import BudgetDiscussionSubmissionPage from "@pages/budgetDiscussionSubmissionPage";
59
import { expect } from "@playwright/test";
10+
import { BudgetProposalContactInformationProps } from "@types";
611

7-
test.beforeEach(async ({}) => {
12+
test.beforeEach(async () => {
813
await setAllureEpic("12. Proposal Budget Submission");
914
});
1015

11-
test.use({
12-
storageState: ".auth/budgetProposal01.json",
13-
wallet: budgetProposal01Wallet,
14-
});
16+
test.describe("Budget proposal 01 wallet", () => {
17+
test.use({
18+
storageState: ".auth/budgetProposal01.json",
19+
wallet: budgetProposal01Wallet,
20+
});
1521

16-
test("12B. Should access proposal creation page in connected state", async ({
17-
page,
18-
}) => {
19-
const budgetProposalSubmissionPage = new BudgetDiscussionSubmissionPage(page);
20-
await budgetProposalSubmissionPage.goto();
21-
await expect(
22-
budgetProposalSubmissionPage.beneficiaryFullNameInput
23-
).toBeVisible();
24-
});
22+
test("12B. Should access proposal creation page in connected state", async ({
23+
page,
24+
}) => {
25+
const budgetProposalSubmissionPage = new BudgetDiscussionSubmissionPage(
26+
page
27+
);
28+
await budgetProposalSubmissionPage.goto();
29+
await expect(
30+
budgetProposalSubmissionPage.beneficiaryFullNameInput
31+
).toBeVisible();
32+
});
2533

26-
test("12C. Should view draft proposal", async ({}) => {});
34+
test.describe("Budget proposal field verification", () => {
35+
test("12D_1. Should verify all field of “contact information” section", async ({}) => {});
36+
test("12D_2. Should verify all field of “proposal ownership” section", async ({}) => {});
37+
test("12D_3. Should verify all field of “problem statements and proposal benefits” section", async ({}) => {});
38+
test("12D_4. Should verify all field of “costing” section", async ({}) => {});
39+
test("12D_5. Should verify all field of “further information” section", async ({}) => {});
40+
test("12D_6. Should verify all field of “administration and auditing” section", async ({}) => {});
41+
test("12D_7. Should verify all field of “submit” section", async ({}) => {});
42+
});
2743

28-
test.describe("Budget proposal field verification", () => {
29-
test("12D_1. Should verify all field of “contact information” section", async ({}) => {});
30-
test("12D_2. Should verify all field of “proposal ownership” section", async ({}) => {});
31-
test("12D_3. Should verify all field of “problem statements and proposal benefits” section", async ({}) => {});
32-
test("12D_4. Should verify all field of “costing” section", async ({}) => {});
33-
test("12D_5. Should verify all field of “further information” section", async ({}) => {});
34-
test("12D_6. Should verify all field of “administration and auditing” section", async ({}) => {});
35-
test("12D_7. Should verify all field of “submit” section", async ({}) => {});
36-
});
44+
test.describe("Budget proposal field validation", () => {
45+
test("12E_1. Should accept valid data in “contact information” section", async ({}) => {});
46+
test("12E_2. Should accept valid data in “proposal ownership” section", async ({}) => {});
47+
test("12E_3. Should accept valid data in “problem statements and proposal benefits” section", async ({}) => {});
48+
test("12E_4. Should accept valid data in “costing” section", async ({}) => {});
49+
test("12E_5. Should accept valid data in “further information” section", async ({}) => {});
50+
test("12E_6. Should accept valid data in “administration and auditing” section", async ({}) => {});
51+
test("12E_7. Should accept valid data in “submit” section", async ({}) => {});
52+
test("12F_1. Should reject invalid data in “contact information” section", async ({}) => {});
53+
test("12F_2. Should reject invalid data in “proposal ownership” section", async ({}) => {});
54+
test("12F_3. Should reject invalid data in “problem statements and proposal benefits” section", async ({}) => {});
55+
test("12F_4. Should reject invalid data in “costing” section", async ({}) => {});
56+
test("12F_5. Should reject invalid data in “further information” section", async ({}) => {});
57+
test("12F_6. Should reject invalid data in “administration and auditing” section", async ({}) => {});
58+
test("12F_7. Should reject invalid data in “submit” section", async ({}) => {});
59+
});
3760

38-
test.describe("Budget proposal field validation", () => {
39-
test("12E_1. Should accept valid data in “contact information” section", async ({}) => {});
40-
test("12E_2. Should accept valid data in “proposal ownership” section", async ({}) => {});
41-
test("12E_3. Should accept valid data in “problem statements and proposal benefits” section", async ({}) => {});
42-
test("12E_4. Should accept valid data in “costing” section", async ({}) => {});
43-
test("12E_5. Should accept valid data in “further information” section", async ({}) => {});
44-
test("12E_6. Should accept valid data in “administration and auditing” section", async ({}) => {});
45-
test("12E_7. Should accept valid data in “submit” section", async ({}) => {});
46-
test("12F_1. Should reject invalid data in “contact information” section", async ({}) => {});
47-
test("12F_2. Should reject invalid data in “proposal ownership” section", async ({}) => {});
48-
test("12F_3. Should reject invalid data in “problem statements and proposal benefits” section", async ({}) => {});
49-
test("12F_4. Should reject invalid data in “costing” section", async ({}) => {});
50-
test("12F_5. Should reject invalid data in “further information” section", async ({}) => {});
51-
test("12F_6. Should reject invalid data in “administration and auditing” section", async ({}) => {});
52-
test("12F_7. Should reject invalid data in “submit” section", async ({}) => {});
61+
test("12G. Should validate and review submitted budget proposal", async ({}) => {});
5362
});
5463

55-
test("12G. Should validate and review submitted budget proposal", async ({}) => {});
56-
test("12H. Should save a budget proposal as a draft", async ({}) => {});
64+
test("12C. Should save and view draft proposal", async ({ browser }) => {
65+
const page = await createNewPageWithWallet(browser, {
66+
storageState: ".auth/budgetProposal02.json",
67+
wallet: budgetProposal02Wallet,
68+
});
69+
70+
const budgetSubmissionPage = new BudgetDiscussionSubmissionPage(page);
71+
await budgetSubmissionPage.goto();
72+
const draftContactInformationContent =
73+
(await budgetSubmissionPage.createDraftBudgetProposal()) as BudgetProposalContactInformationProps;
74+
const getAddDrafts = await budgetSubmissionPage.getAllDrafts();
75+
76+
expect(getAddDrafts.length).toBeGreaterThan(0);
77+
78+
await budgetSubmissionPage.viewLastDraft();
79+
80+
await expect(budgetSubmissionPage.beneficiaryFullNameInput).toHaveValue(
81+
draftContactInformationContent.beneficiaryFullName
82+
);
83+
await expect(budgetSubmissionPage.beneficiaryEmailInput).toHaveValue(
84+
draftContactInformationContent.beneficiaryEmail
85+
);
86+
await expect(budgetSubmissionPage.beneficiaryCountrySelect).toHaveText(
87+
draftContactInformationContent.beneficiaryCountry
88+
);
89+
await expect(budgetSubmissionPage.beneficiaryNationalitySelect).toHaveText(
90+
draftContactInformationContent.beneficiaryNationality
91+
);
92+
await expect(budgetSubmissionPage.submissionLeadFullNameInput).toHaveValue(
93+
draftContactInformationContent.submissionLeadFullName
94+
);
95+
await expect(budgetSubmissionPage.submissionLeadEmailInput).toHaveValue(
96+
draftContactInformationContent.submissionLeadEmail
97+
);
98+
});
5799

58-
test("12I. Should submit a valid budget proposal", async ({}) => {});
59-
test("12J. Should submit a valid draft budget proposal", async ({}) => {});
100+
test("12H. Should submit a valid budget proposal", async ({}) => {});
101+
test("12I. Should submit a valid draft budget proposal", async ({}) => {});

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
adaHolder05Wallet,
99
adaHolder06Wallet,
1010
budgetProposal01Wallet,
11+
budgetProposal02Wallet,
1112
dRep01Wallet,
1213
dRep02Wallet,
1314
dRep03Wallet,
@@ -55,6 +56,7 @@ const proposal08AuthFile = ".auth/proposal08.json";
5556
const proposal09AuthFile = ".auth/proposal09.json";
5657

5758
const budgetProposal01AuthFile = ".auth/budgetProposal01.json";
59+
const budgetProposal02AuthFile = ".auth/budgetProposal02.json";
5860

5961
setup.beforeEach(async () => {
6062
await setAllureEpic("Setup");
@@ -241,3 +243,12 @@ setup("Create Budget Proposal 01 auth", async ({ page, context }) => {
241243
auth: budgetProposal01AuthFile,
242244
});
243245
});
246+
247+
setup("Create Budget Proposal 02 auth", async ({ page, context }) => {
248+
await createAuthWithUserName({
249+
page,
250+
context,
251+
wallet: budgetProposal02Wallet,
252+
auth: budgetProposal02AuthFile,
253+
});
254+
});

0 commit comments

Comments
 (0)