Skip to content

Commit 70fc945

Browse files
babinkarmacharya79samshara
authored andcommitted
Add value assertions for Event type Field Report
1 parent c11fe18 commit 70fc945

File tree

3 files changed

+99
-15
lines changed

3 files changed

+99
-15
lines changed

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"lint": "yarn biome lint ./tests/* ./utils/*",
1717
"biome:check": "biome check ./tests/* ./utils/*",
1818
"biome:ci": "biome ci ./tests/* ./utils/*",
19-
"biome:fix": "biome check --write ./tests/* ./utils/*"
19+
"biome:fix": "biome check --apply ./tests/* ./utils/*"
2020
},
2121
"dependencies": {
2222
"@togglecorp/fujs": "^2.1.1",

packages/e2e-tests/tests/field-report/fieldReport.spec.ts

Lines changed: 96 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,21 @@ test.describe('Field Report', () => {
147147
await page
148148
.locator('label')
149149
.filter({ hasText: actionHuman })
150-
.first()
150+
.nth(0)
151151
.click();
152152
await page
153153
.locator('label')
154154
.filter({ hasText: actionShelter })
155-
.first()
155+
.nth(0)
156156
.click();
157157
await page
158158
.locator('label')
159159
.filter({ hasText: actionEvacuation })
160-
.first()
160+
.nth(0)
161161
.click();
162162
await page
163163
.getByPlaceholder('Brief description of the action')
164-
.first()
164+
.nth(0)
165165
.fill(nationalSocietySummary);
166166
// Action Taken by IFRC
167167
await page
@@ -214,7 +214,7 @@ test.describe('Field Report', () => {
214214
await page
215215
.locator('label')
216216
.filter({ hasText: interventionOptionOne })
217-
.first()
217+
.nth(0)
218218
.click();
219219
await page.locator('input[name="dref_amount"]').fill(drefRequested);
220220
//Emergency Appeal
@@ -284,7 +284,7 @@ test.describe('Field Report', () => {
284284
.getByText('Start Date', { exact: true })
285285
.locator('..');
286286
await expect(frDate).toHaveText(`Start Date${date}`);
287-
// Assertions to verify whether the data inserted on the form are displayed on the UI // Numeric Details
287+
// Numeric Details Assertions
288288
const numericDetails = [
289289
{ label: 'Injured (RC)', value: formatNumber(numInjured) },
290290
{
@@ -375,7 +375,7 @@ test.describe('Field Report', () => {
375375
.locator('..')
376376
.locator('..');
377377
await expect(bulletin).toContainText(informationBulletin);
378-
// Assertions for actions taken by National Society, Federation and RCRC
378+
// Actions taken by National Society, Federation and RCRC Assertions
379379
const sections = [
380380
{
381381
childText: 'Actions taken by National Society',
@@ -450,7 +450,7 @@ test.describe('Field Report', () => {
450450
`Emergency Response Units${interventionOptionTwo}`,
451451
);
452452

453-
// Assertions to verify the contacts
453+
// Contacts Assertions
454454
const details = [
455455
{
456456
label: 'Originator',
@@ -499,7 +499,7 @@ test.describe('Field Report', () => {
499499
.locator('label')
500500
.filter({ hasText: 'EventFirst report for this disaster' });
501501
await expect(statusValue).toBeChecked();
502-
// Assertions for Country, Region, Disaster Type, Date and Title
502+
// Assertions for Country, Region, Disaster Type, Date and Title value
503503
const countryValue = page.locator('input[name="country"]');
504504
await expect(countryValue).toHaveValue(country);
505505
const regionValue = page.locator('input[name="districts"]');
@@ -569,12 +569,12 @@ test.describe('Field Report', () => {
569569
const label = page
570570
.locator('label')
571571
.filter({ hasText: action })
572-
.first();
572+
.nth(0);
573573
await expect(label).toBeChecked();
574574
}
575575
const nsValue = page
576576
.getByPlaceholder('Brief description of the action')
577-
.first();
577+
.nth(0);
578578
await expect(nsValue).toHaveText(nationalSocietySummary);
579579
// Assertions for Actions Taken by IFRC Value
580580
const ifrcActions = [actionHealth, actionShelter, actionCamp];
@@ -607,10 +607,94 @@ test.describe('Field Report', () => {
607607
.locator('label')
608608
.filter({ hasText: informationBulletin });
609609
await expect(bulletinValue).toBeChecked();
610-
// Assertions for Actions Taken by Others Value
611610
const actionsOtherValue = page.locator(
612611
'textarea[name="actions_others"]',
613612
);
614613
await expect(actionsOtherValue).toHaveText(actionOther);
614+
await page.getByRole('button', { name: 'Continue' }).click();
615+
// Response Page
616+
// Assertions for Planned Assertions value
617+
// DREF Requested
618+
const drefValue = page
619+
.locator('label')
620+
.filter({ hasText: interventionOptionOne })
621+
.nth(0);
622+
await expect(drefValue).toBeChecked();
623+
const drefSummaryValue = page.locator('input[name="dref_amount"]');
624+
await expect(drefSummaryValue).toHaveValue(drefRequested);
625+
// Emmergency Appeal
626+
const emergencyAppealValue = page
627+
.locator('label')
628+
.filter({ hasText: interventionOptionTwo })
629+
.nth(1);
630+
await expect(emergencyAppealValue).toBeChecked();
631+
const emergencyAppealSummaryValue = page.locator(
632+
'input[name="appeal_amount"]',
633+
);
634+
await expect(emergencyAppealSummaryValue).toHaveValue(emergencyAppeal);
635+
// Rapid Response Personnel
636+
const rapidResponseValue = page
637+
.locator('label')
638+
.filter({ hasText: interventionOptionThree })
639+
.nth(2);
640+
await expect(rapidResponseValue).toBeChecked();
641+
const rapidResponseSummaryValue = page.locator(
642+
'input[name="num_fact"]',
643+
);
644+
await expect(rapidResponseSummaryValue).toHaveValue(rapidResponse);
645+
// Emergency Response Unit
646+
const emergencyResponseValue = page
647+
.locator('label')
648+
.filter({ hasText: interventionOptionTwo })
649+
.nth(3);
650+
await expect(emergencyResponseValue).toBeChecked();
651+
const emergencyResponseSummaryValue = page.locator(
652+
'input[name="num_ifrc_staff"]',
653+
);
654+
await expect(emergencyResponseSummaryValue).toHaveValue(
655+
emergencyResponse,
656+
);
657+
// Contacts
658+
// Assertion for Originator Contacts value
659+
const originatorNameValue = page.locator('input[name="name"]').nth(0);
660+
await expect(originatorNameValue).toHaveValue(originatorName);
661+
const orginatorTitleValue = page.locator('input[name="title"]').nth(0);
662+
await expect(orginatorTitleValue).toHaveValue(originatorTitle);
663+
const originatorEmailValue = page.locator('input[name="email"]').nth(0);
664+
await expect(originatorEmailValue).toHaveValue(originatorEmail);
665+
const originatorPhoneValue = page.locator('input[name="phone"]').nth(0);
666+
await expect(originatorPhoneValue).toHaveValue(originatorPhone);
667+
// Assertion for Emergency Appeal values
668+
const nationalNameValue = page.locator('input[name="name"]').nth(1);
669+
await expect(nationalNameValue).toHaveValue(nationalName);
670+
const nationalTitleValue = page.locator('input[name="title"]').nth(1);
671+
await expect(nationalTitleValue).toHaveValue(nationalTitle);
672+
const nationalEmailValue = page.locator('input[name="email"]').nth(1);
673+
await expect(nationalEmailValue).toHaveValue(nationalEmail);
674+
const nationalPhoneValue = page.locator('input[name="phone"]').nth(1);
675+
await expect(nationalPhoneValue).toHaveValue(nationalPhone);
676+
// Assertions for Rapid Response Personnel Values
677+
const ifrcNameValue = page.locator('input[name="name"]').nth(2);
678+
await expect(ifrcNameValue).toHaveValue(ifrcName);
679+
const ifrcTitleValue = page.locator('input[name="title"]').nth(2);
680+
await expect(ifrcTitleValue).toHaveValue(ifrcTitle);
681+
const ifrcEmailValue = page.locator('input[name="email"]').nth(2);
682+
await expect(ifrcEmailValue).toHaveValue(ifrcEmail);
683+
const ifrcPhoneValue = page.locator('input[name="phone"]').nth(2);
684+
await expect(ifrcPhoneValue).toHaveValue(ifrcPhone);
685+
// Assertions for Emergency Response Units Values
686+
const mediaNameValue = page.locator('input[name="name"]').nth(3);
687+
await expect(mediaNameValue).toHaveValue(mediaName);
688+
const mediaTitleValue = page.locator('input[name="title"]').nth(3);
689+
await expect(mediaTitleValue).toHaveValue(mediaTitle);
690+
const mediaEmailValue = page.locator('input[name="email"]').nth(3);
691+
await expect(mediaEmailValue).toHaveValue(mediaEmail);
692+
const mediaPhoneValue = page.locator('input[name="phone"]').nth(3);
693+
await expect(mediaPhoneValue).toHaveValue(mediaPhone);
694+
// Assertions for Field Report Visibility Value
695+
const frVisibilityValue = page
696+
.locator('label')
697+
.filter({ hasText: visibiltyOptTwo });
698+
await expect(frVisibilityValue).toBeChecked();
615699
});
616700
});

packages/e2e-tests/utils/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export async function login(page: Page, username: string, password: string) {
44

55
//FIXME: page.fill is discouraged. We should use locator based fill.
66
// @ifrc/go-ui should be updated to support locators
7-
await page.fill('input[name="username"]', username);
8-
await page.fill('input[name="password"]', password);
7+
await page.locator('input[name="username"]').fill(username);
8+
await page.locator('input[name="password"]').fill(password);
99

1010
await page.getByRole('button', { name: 'Login' }).click();
1111
// Wait until the page receives the cookies.

0 commit comments

Comments
 (0)