Skip to content

Commit 488fa0b

Browse files
babinkarmacharya79samshara
authored andcommitted
Add value assertions for Event type Field Report
1 parent f7455f1 commit 488fa0b

File tree

2 files changed

+180
-85
lines changed

2 files changed

+180
-85
lines changed

packages/e2e-tests/tests/field-report/fieldReport.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
"title": "bio hazard",
88
"govRequest": "Yes",
99
"nationalsocietyRequest": "No",
10-
"num_injured": "8000",
11-
"gov_num_injured": "4000",
12-
"other_num_injured": "5000",
13-
"num_dead": "1200",
14-
"gov_num_dead": "800",
15-
"other_num_dead": "500",
16-
"num_missing": "6000",
17-
"gov_num_missing": "3000",
18-
"other_num_missing": "2500",
19-
"num_affected": "12000",
20-
"gov_num_affected": "8000",
21-
"other_num_affected": "4000",
22-
"num_displaced": "18000",
23-
"gov_num_displaced": "14000",
24-
"other_num_displaced": "11000",
25-
"other_sources": "The English-Quotient (EQ) test measures your proficiency in the English language, including vocabulary, grammar, and comprehension. Designed for learners and professionals, it provides a benchmark for assessing language skills. ",
26-
"gov_num_assisted": "8000",
27-
"num_assisted": "7000",
28-
"num_localstaff": "6000",
29-
"num_volunteers": "5000",
30-
"num_expats_delegates": "4000",
10+
"numInjured": "8000",
11+
"govNumInjured": "4000",
12+
"otherNumInjured": "5000",
13+
"numDead": "1200",
14+
"govNumDead": "800",
15+
"otherNumDead": "500",
16+
"numMissing": "6000",
17+
"govNumMissing": "3000",
18+
"otherNumMissing": "2500",
19+
"numAffected": "12000",
20+
"govNumAffected": "8000",
21+
"otherNumAffected": "4000",
22+
"numDisplaced": "18000",
23+
"govNumDisplaced": "14000",
24+
"otherNumDisplaced": "11000",
25+
"otherSources": "The English-Quotient (EQ) test measures your proficiency in the English language, including vocabulary, grammar, and comprehension. Designed for learners and professionals, it provides a benchmark for assessing language skills",
26+
"govNumAssisted": "8000",
27+
"numAssisted": "7000",
28+
"numLocalstaff": "6000",
29+
"numVolunteers": "5000",
30+
"numExpatsDelegates": "4000",
3131
"actionHuman": "Human remains management and identification",
3232
"actionEvacuation": "Evacuation",
3333
"actionHealth": "Health",

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

Lines changed: 159 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ test.describe('Field Report', () => {
1515
title,
1616
govRequest,
1717
nationalsocietyRequest,
18-
num_injured,
19-
gov_num_injured,
20-
other_num_injured,
21-
num_dead,
22-
gov_num_dead,
23-
other_num_dead,
24-
num_missing,
25-
gov_num_missing,
26-
other_num_missing,
27-
num_affected,
28-
gov_num_affected,
29-
other_num_affected,
30-
num_displaced,
31-
other_num_displaced,
32-
gov_num_displaced,
33-
other_sources,
34-
gov_num_assisted,
35-
num_assisted,
36-
num_localstaff,
37-
num_volunteers,
38-
num_expats_delegates,
18+
numInjured,
19+
govNumInjured,
20+
otherNumInjured,
21+
numDead,
22+
govNumDead,
23+
otherNumDead,
24+
numMissing,
25+
govNumMissing,
26+
otherNumMissing,
27+
numAffected,
28+
govNumAffected,
29+
otherNumAffected,
30+
numDisplaced,
31+
otherNumDisplaced,
32+
govNumDisplaced,
33+
otherSources,
34+
govNumAssisted,
35+
numAssisted,
36+
numLocalstaff,
37+
numVolunteers,
38+
numExpatsDelegates,
3939
actionHuman,
4040
actionEvacuation,
4141
actionHealth,
@@ -102,53 +102,53 @@ test.describe('Field Report', () => {
102102
.click();
103103
await page.getByRole('button', { name: 'Continue' }).click();
104104
// Situation Page
105-
await page.locator('input[name="num_injured"]').fill(num_injured);
105+
await page.locator('input[name="num_injured"]').fill(numInjured);
106106
await page
107107
.locator('input[name="gov_num_injured"]')
108-
.fill(gov_num_injured);
108+
.fill(govNumInjured);
109109
await page
110110
.locator('input[name="other_num_injured"]')
111-
.fill(other_num_injured);
112-
await page.locator('input[name="num_dead"]').fill(num_dead);
113-
await page.locator('input[name="gov_num_dead"]').fill(gov_num_dead);
114-
await page.locator('input[name="other_num_dead"]').fill(other_num_dead);
115-
await page.locator('input[name="num_missing"]').fill(num_missing);
111+
.fill(otherNumInjured);
112+
await page.locator('input[name="num_dead"]').fill(numDead);
113+
await page.locator('input[name="gov_num_dead"]').fill(govNumDead);
114+
await page.locator('input[name="other_num_dead"]').fill(otherNumDead);
115+
await page.locator('input[name="num_missing"]').fill(numMissing);
116116
await page
117117
.locator('input[name="gov_num_missing"]')
118-
.fill(gov_num_missing);
118+
.fill(govNumMissing);
119119
await page
120120
.locator('input[name="other_num_missing"]')
121-
.fill(other_num_missing);
122-
await page.locator('input[name="num_affected"]').fill(num_affected);
121+
.fill(otherNumMissing);
122+
await page.locator('input[name="num_affected"]').fill(numAffected);
123123
await page
124124
.locator('input[name="gov_num_affected"]')
125-
.fill(gov_num_affected);
125+
.fill(govNumAffected);
126126
await page
127127
.locator('input[name="other_num_affected"]')
128-
.fill(other_num_affected);
129-
await page.locator('input[name="num_displaced"]').fill(num_displaced);
128+
.fill(otherNumAffected);
129+
await page.locator('input[name="num_displaced"]').fill(numDisplaced);
130130
await page
131131
.locator('input[name="gov_num_displaced"]')
132-
.fill(gov_num_displaced);
132+
.fill(govNumDisplaced);
133133
await page
134134
.locator('input[name="other_num_displaced"]')
135-
.fill(other_num_displaced);
135+
.fill(otherNumDisplaced);
136136
await page
137137
.locator('textarea[name="other_sources"]')
138-
.fill(other_sources);
138+
.fill(otherSources);
139139
// await page.frameLocator('iframe[title="Rich Text Area"]').locator('html').fill("Just the random data");
140140
// issue in Situational overview textbox
141141
await page.getByRole('button', { name: 'Continue' }).click();
142142
// Action Page
143143
await page
144144
.locator('input[name="gov_num_assisted"]')
145-
.fill(gov_num_assisted);
146-
await page.locator('input[name="num_assisted"]').fill(num_assisted);
147-
await page.locator('input[name="num_localstaff"]').fill(num_localstaff);
148-
await page.locator('input[name="num_volunteers"]').fill(num_volunteers);
145+
.fill(govNumAssisted);
146+
await page.locator('input[name="num_assisted"]').fill(numAssisted);
147+
await page.locator('input[name="num_localstaff"]').fill(numLocalstaff);
148+
await page.locator('input[name="num_volunteers"]').fill(numVolunteers);
149149
await page
150150
.locator('input[name="num_expats_delegates"]')
151-
.fill(num_expats_delegates);
151+
.fill(numExpatsDelegates);
152152
// Action taken by National red cross society
153153
await page
154154
.locator('label')
@@ -292,54 +292,54 @@ test.describe('Field Report', () => {
292292
await expect(frDate).toHaveText(`Start Date${date}`);
293293
// Assertions to verify whether the data inserted on the form are displayed on the UI // Numeric Details
294294
const numericDetails = [
295-
{ label: 'Injured (RC)', value: formatNumber(num_injured) },
295+
{ label: 'Injured (RC)', value: formatNumber(numInjured) },
296296
{
297297
label: 'Injured (Government)',
298-
value: formatNumber(gov_num_injured),
298+
value: formatNumber(govNumInjured),
299299
},
300300
{
301301
label: 'Injured (Other)',
302-
value: formatNumber(other_num_injured),
302+
value: formatNumber(otherNumInjured),
303303
},
304-
{ label: 'Missing (RC)', value: formatNumber(num_missing) },
304+
{ label: 'Missing (RC)', value: formatNumber(numMissing) },
305305
{
306306
label: 'Missing (Government)',
307-
value: formatNumber(gov_num_missing),
307+
value: formatNumber(govNumMissing),
308308
},
309309
{
310310
label: 'Missing (Other)',
311-
value: formatNumber(other_num_missing),
311+
value: formatNumber(otherNumMissing),
312312
},
313-
{ label: 'Dead (RC)', value: formatNumber(num_dead) },
314-
{ label: 'Dead (Government)', value: formatNumber(gov_num_dead) },
315-
{ label: 'Dead (Other)', value: formatNumber(other_num_dead) },
316-
{ label: 'Displaced (RC)', value: formatNumber(num_displaced) },
313+
{ label: 'Dead (RC)', value: formatNumber(numDead) },
314+
{ label: 'Dead (Government)', value: formatNumber(govNumDead) },
315+
{ label: 'Dead (Other)', value: formatNumber(otherNumDead) },
316+
{ label: 'Displaced (RC)', value: formatNumber(numDisplaced) },
317317
{
318318
label: 'Displaced (Government)',
319-
value: formatNumber(gov_num_displaced),
319+
value: formatNumber(govNumDisplaced),
320320
},
321321
{
322322
label: 'Displaced (Other)',
323-
value: formatNumber(other_num_displaced),
323+
value: formatNumber(otherNumDisplaced),
324324
},
325-
{ label: 'Affected (RC)', value: formatNumber(num_affected) },
325+
{ label: 'Affected (RC)', value: formatNumber(numAffected) },
326326
{
327327
label: 'Affected (Government)',
328-
value: formatNumber(gov_num_affected),
328+
value: formatNumber(govNumAffected),
329329
},
330330
{
331331
label: 'Affected (Other)',
332-
value: formatNumber(other_num_affected),
332+
value: formatNumber(otherNumAffected),
333333
},
334-
{ label: 'Assisted (RC)', value: formatNumber(num_assisted) },
334+
{ label: 'Assisted (RC)', value: formatNumber(numAssisted) },
335335
{
336336
label: 'Assisted (Government)',
337-
value: formatNumber(gov_num_assisted),
337+
value: formatNumber(govNumAssisted),
338338
},
339-
{ label: 'Local Staff', value: formatNumber(num_localstaff) },
340-
{ label: 'Volunteers', value: formatNumber(num_volunteers) },
339+
{ label: 'Local Staff', value: formatNumber(numLocalstaff) },
340+
{ label: 'Volunteers', value: formatNumber(numVolunteers) },
341341
{ label: 'IFRC Staff', value: formatNumber(emergencyResponse) },
342-
{ label: 'Delegates', value: formatNumber(num_expats_delegates) },
342+
{ label: 'Delegates', value: formatNumber(numExpatsDelegates) },
343343
];
344344
for (const detail of numericDetails) {
345345
const parentElement = page.getByText(detail.label).locator('..');
@@ -355,7 +355,7 @@ test.describe('Field Report', () => {
355355
.locator('..')
356356
.locator('..')
357357
.locator('..');
358-
await expect(sourceParent).toContainText(other_sources);
358+
await expect(sourceParent).toContainText(otherSources);
359359
// Request for Assistance Assertions
360360
const govReq = page
361361
.getByText('Government Requests International Assistance', {
@@ -497,5 +497,100 @@ test.describe('Field Report', () => {
497497
await expect(detailLocator).toContainText(detail.email);
498498
await expect(detailLocator).toContainText(detail.phone);
499499
}
500-
});
500+
await page.getByRole('link', { name: 'Edit Report' }).click();
501+
// Input Value Assertions
502+
// Context Page
503+
// Status
504+
const statusValue = page.locator('label').filter({ hasText: 'EventFirst report for this disaster' })
505+
await expect(statusValue).toBeChecked();
506+
// Assertions for Country, Region, Disaster Type, Date and Title
507+
const countryValue = page.locator('input[name="country"]');
508+
await expect(countryValue).toHaveValue(country);
509+
const regionValue = page.locator('input[name="districts"]')
510+
await expect(regionValue).toHaveValue(district);
511+
const disasterValue = page.locator('input[name="dtype"]');
512+
await expect(disasterValue).toHaveValue(disasterType);
513+
const dateValue = page.locator('input[name="start_date"]');
514+
await expect(dateValue).toHaveValue(date);
515+
const titleValue = page.getByPlaceholder('Example: Cyclone Cody');
516+
await expect(titleValue).toHaveValue(`${newtitle} - ${title}`,);
517+
// Government request international assistance
518+
const govReqValue = page.locator('label').filter({ hasText: govRequest }).nth(1)
519+
await expect(govReqValue).toBeChecked();
520+
// National Society requests international assistance?
521+
const nsReqValue = page.locator('label').filter({ hasText: nationalsocietyRequest }).nth(2)
522+
await expect(nsReqValue).toBeChecked();
523+
await page.getByRole('button', { name: 'Continue' }).click();
524+
// Situation Page
525+
// Assertions for Numeric Details Value
526+
const numericDetailValues = [
527+
{ name: 'num_injured', value: numInjured },
528+
{ name: 'gov_num_injured', value: govNumInjured },
529+
{ name: 'other_num_injured', value: otherNumInjured },
530+
{ name: 'num_dead', value: numDead },
531+
{ name: 'gov_num_dead', value: govNumDead },
532+
{ name: 'other_num_dead', value: otherNumDead },
533+
{ name: 'num_missing', value: numMissing },
534+
{ name: 'gov_num_missing', value: govNumMissing },
535+
{ name: 'other_num_missing', value: otherNumMissing },
536+
{ name: 'num_affected', value: numAffected },
537+
{ name: 'gov_num_affected', value: govNumAffected },
538+
{ name: 'other_num_affected', value: otherNumAffected },
539+
{ name: 'num_displaced', value: numDisplaced },
540+
{ name: 'gov_num_displaced', value: govNumDisplaced },
541+
{ name: 'other_num_displaced', value: otherNumDisplaced }
542+
];
543+
for (const { name, value } of numericDetailValues) {
544+
const inputValue = page.locator(`input[name="${name}"]`);
545+
await expect(inputValue).toHaveValue(value);
546+
}
547+
// Assertions for Source Details value
548+
const sourceValue = page.locator('textarea[name="other_sources"]');
549+
await expect(sourceValue).toHaveValue(otherSources);
550+
await page.getByRole('button', { name: 'Continue' }).click();
551+
// Actions Page
552+
// Assertions for Actions taken Value
553+
const assistedValues = [
554+
{ name: 'gov_num_assisted', value: govNumAssisted },
555+
{ name: 'num_assisted', value: numAssisted },
556+
{ name: 'num_localstaff', value: numLocalstaff },
557+
{ name: 'num_volunteers', value: numVolunteers },
558+
{ name: 'num_expats_delegates', value: numExpatsDelegates }
559+
];
560+
for (const { name, value } of assistedValues) {
561+
const inputValue = page.locator(`input[name="${name}"]`);
562+
await expect(inputValue).toHaveValue(value);
563+
}
564+
// Assertions for Actions Taken by National Society Red Cross Value
565+
const nsActions = [actionHuman, actionShelter, actionEvacuation];
566+
for (const action of nsActions) {
567+
const label = page.locator('label').filter({ hasText: action }).first();
568+
await expect(label).toBeChecked();
569+
}
570+
const nsValue = page.getByPlaceholder('Brief description of the action').first();
571+
await expect(nsValue).toHaveText(nationalSocietySummary);
572+
// Assertions for Actions Taken by IFRC Value
573+
const ifrcActions = [actionHealth, actionShelter, actionCamp];
574+
for (const action of ifrcActions) {
575+
const label = page.locator('label').filter({ hasText: action }).nth(1);
576+
await expect(label).toBeChecked();
577+
}
578+
const ifrcValue = page.getByPlaceholder('Brief description of the action').nth(1);
579+
await expect(ifrcValue).toHaveText(federationSummary);
580+
// Assertions for Actions Taken by RCRC Movements Value
581+
const rcrcActions = [actionFirst, actionPsychosocial, actionFood];
582+
for (const action of rcrcActions) {
583+
const label = page.locator('label').filter({ hasText: action }).nth(2);
584+
await expect(label).toBeChecked();
585+
}
586+
const rcrcValue = page.getByPlaceholder('Brief description of the action').nth(2);
587+
await expect(rcrcValue).toHaveText(rcrcSummary);
588+
// Assertions for Information Bulletin
589+
const bulletinValue = page.locator('label').filter({ hasText: informationBulletin });
590+
await expect(bulletinValue).toBeChecked();
591+
// Assertions for Actions Taken by Others Value
592+
const actionsOtherValue = page.locator('textarea[name="actions_others"]');
593+
await expect(actionsOtherValue).toHaveText(actionOther)
594+
595+
});
501596
});

0 commit comments

Comments
 (0)