11import { expect , test } from '@playwright/test' ;
22import { formatNumber } from '#utils/common' ;
3- import fixtureData from './earlywarning.json' ;
3+ import earlyWarning from './fixtures/earlyWarning.json' ;
4+
45test . use ( { storageState : 'playwright/.auth/user.json' } ) ;
5- test . describe ( 'Field Report' , ( ) => {
6- test ( 'test' , async ( { page } ) => {
6+
7+ test . describe ( 'Field Report early warning flow' , ( ) => {
8+ test ( 'creates an early warning field report and assert the submitted values' , async ( {
9+ page,
10+ } ) => {
711 const {
8- country,
9- province,
10- disasterType,
11- date,
12- title,
13- govRequest,
14- nationalSocietyRequest,
15- potentiallyAffectedRc,
16- potentiallyAffectedGov,
17- potentiallyAffectedOther,
18- peopleAtRiskRc,
19- peopleAtRiskGov,
20- peopleAtRiskOther,
21- likelyToBeAffectedRc,
22- likelyToBeAffectedGov,
23- likelyToBeAffectedOther,
24- sourceDetails,
25- riskAnalysis,
26- govNumAssisted,
27- rcrcAssisted,
28- actionWash,
12+ actionCash,
2913 actionEvacuation,
3014 actionHealth,
31- actionShelter,
32- actionCash,
33- actionNfi,
34- actionMovement,
35- actionMonitor,
3615 actionInteragency,
37- generalSummary,
38- fedSummary,
39- rcrcSummary,
40- informationBulletin,
16+ actionMonitor,
17+ actionMovement,
18+ actionNfi,
4119 actionOther,
42- interventionOptionOne,
43- interventionOptionTwo,
44- interventionOptionThree,
20+ actionShelter,
21+ actionWash,
22+ country,
23+ date,
24+ disasterType,
4525 drefRequested,
4626 emergencyAppeal,
47- rapidResponse,
4827 emergencyResponse,
28+ fedSummary,
4929 forecastAction,
50- originatorName,
51- originatorTitle,
52- originatorEmail,
53- originatorPhone,
54- nationalName,
55- nationalTitle,
56- nationalEmail,
57- nationalPhone,
58- ifrcName,
59- ifrcTitle,
30+ generalSummary,
31+ govNumAssisted,
32+ govRequest,
6033 ifrcEmail,
34+ ifrcName,
6135 ifrcPhone,
62- mediaName,
63- mediaTitle,
36+ ifrcTitle,
37+ informationBulletin,
38+ interventionOptionOne,
39+ interventionOptionThree,
40+ interventionOptionTwo,
41+ likelyToBeAffectedGov,
42+ likelyToBeAffectedOther,
43+ likelyToBeAffectedRc,
6444 mediaEmail,
45+ mediaName,
6546 mediaPhone,
66- visibiltyOptOne,
67- visibiltyOptTwo,
68- } = fixtureData ;
47+ mediaTitle,
48+ nationalEmail,
49+ nationalName,
50+ nationalPhone,
51+ nationalSocietyRequest,
52+ nationalTitle,
53+ originatorEmail,
54+ originatorName,
55+ originatorPhone,
56+ originatorTitle,
57+ peopleAtRiskGov,
58+ peopleAtRiskOther,
59+ peopleAtRiskRc,
60+ potentiallyAffectedGov,
61+ potentiallyAffectedOther,
62+ potentiallyAffectedRc,
63+ province,
64+ rapidResponse,
65+ rcrcAssisted,
66+ rcrcSummary,
67+ riskAnalysis,
68+ sourceDetails,
69+ title,
70+ visibilityOptTwo,
71+ } = earlyWarning ;
6972 await page . goto ( '/' ) ;
7073 await page . getByRole ( 'button' , { name : 'Create a Report' } ) . click ( ) ;
7174 await page . getByRole ( 'link' , { name : 'New Field Report' } ) . click ( ) ;
@@ -85,7 +88,7 @@ test.describe('Field Report', () => {
8588 ) ;
8689 await page . locator ( 'input[name="start_date"]' ) . fill ( date ) ;
8790 await page . getByPlaceholder ( 'Example: Cyclone Cody' ) . fill ( title ) ;
88- const newtitle = await page . inputValue ( 'input[type="text"]' ) ;
91+ const newTitle = await page . inputValue ( 'input[type="text"]' ) ;
8992 await page
9093 . locator ( 'label' )
9194 . filter ( { hasText : govRequest } )
@@ -262,13 +265,13 @@ test.describe('Field Report', () => {
262265 }
263266 await page
264267 . locator ( 'label' )
265- . filter ( { hasText : visibiltyOptTwo } )
268+ . filter ( { hasText : visibilityOptTwo } )
266269 . click ( ) ;
267270 await page . getByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
268271 // Wait for redirection to field reports listing page
269272 await page . waitForURL ( / \/ f i e l d - r e p o r t s \/ \d + / ) ;
270273 await expect ( page . locator ( 'h1' ) ) . toContainText (
271- `${ newtitle } - ${ title } ` ,
274+ `${ newTitle } - ${ title } ` ,
272275 ) ;
273276 // Assertion for Early Warning Type of Field Report
274277 const parentElement = page
@@ -277,7 +280,7 @@ test.describe('Field Report', () => {
277280 . locator ( '..' )
278281 . locator ( '..' )
279282 . locator ( '..' ) ;
280- await expect ( parentElement ) . toContainText ( visibiltyOptTwo ) ;
283+ await expect ( parentElement ) . toContainText ( visibilityOptTwo ) ;
281284 const parent = page
282285 . getByText ( 'Forecasted Date of Impact' )
283286 . locator ( '..' )
@@ -333,11 +336,11 @@ test.describe('Field Report', () => {
333336 } ,
334337 ] ;
335338 for ( const element of elements ) {
336- const pElement = await page
339+ const pElement = page
337340 . getByText ( element . text , { exact : true } )
338341 . locator ( '..' ) ;
339342 const cElement = await pElement . nth ( 0 ) . innerText ( ) ;
340- await expect ( cElement ) . toContain ( element . expectedText ) ;
343+ expect ( cElement ) . toContain ( element . expectedText ) ;
341344 }
342345 // Assertions for Sources for data marked as other
343346 const sourceElement = page . getByText (
@@ -369,7 +372,7 @@ test.describe('Field Report', () => {
369372 . getByText ( 'NS Requests International Assistance' , { exact : true } )
370373 . locator ( '..' ) ;
371374 await expect ( nsRequestElement ) . toContainText ( nationalSocietyRequest ) ;
372- // Assertions for Information Bulletion Published
375+ // Assertions for Information Bulletin Published
373376 const infoElement = page . getByText ( 'Information Bulletin Published' , {
374377 exact : true ,
375378 } ) ;
@@ -496,7 +499,7 @@ test.describe('Field Report', () => {
496499 const dateValue = page . locator ( 'input[name="start_date"]' ) ;
497500 await expect ( dateValue ) . toHaveValue ( date ) ;
498501 const titleValue = page . getByPlaceholder ( 'Example: Cyclone Cody' ) ;
499- await expect ( titleValue ) . toHaveValue ( `${ newtitle } - ${ title } ` ) ;
502+ await expect ( titleValue ) . toHaveValue ( `${ newTitle } - ${ title } ` ) ;
500503 // Government request international assistance
501504 const govReqValue = page
502505 . locator ( 'label' )
@@ -533,9 +536,7 @@ test.describe('Field Report', () => {
533536 } ,
534537 ] ;
535538 for ( const field of fields ) {
536- const valueLocator = await page . locator (
537- `input[name="${ field . name } "]` ,
538- ) ;
539+ const valueLocator = page . locator ( `input[name="${ field . name } "]` ) ;
539540 await expect ( valueLocator ) . toHaveValue ( field . value ) ;
540541 }
541542 // Assertions for Source Details Value
@@ -589,11 +590,11 @@ test.describe('Field Report', () => {
589590 . locator ( 'textarea[name="summary"]' )
590591 . nth ( 2 ) ;
591592 await expect ( rcrcActionsValue ) . toHaveValue ( rcrcSummary ) ;
592- // Assertions for Information Bulletion Value
593- const informationBulletionValue = page
593+ // Assertions for Information Bulletin Value
594+ const informationBulletinValue = page
594595 . locator ( 'label' )
595596 . filter ( { hasText : informationBulletin } ) ;
596- await expect ( informationBulletionValue ) . toBeChecked ( ) ;
597+ await expect ( informationBulletinValue ) . toBeChecked ( ) ;
597598 // Assertions for Action Taken by Other Value
598599 const otherActionValue = page . locator (
599600 'textarea[name="actions_others"]' ,
@@ -610,7 +611,7 @@ test.describe('Field Report', () => {
610611 await expect ( drefValue ) . toBeChecked ( ) ;
611612 const drefSummaryValue = page . locator ( 'input[name="dref_amount"]' ) ;
612613 await expect ( drefSummaryValue ) . toHaveValue ( drefRequested ) ;
613- // Emmergency Appeal
614+ // Emergency Appeal
614615 const emergencyAppealValue = page
615616 . locator ( 'label' )
616617 . filter ( { hasText : interventionOptionTwo } )
@@ -700,7 +701,7 @@ test.describe('Field Report', () => {
700701 // Assertions for Field Report Visibility Value
701702 const frVisibilityValue = page
702703 . locator ( 'label' )
703- . filter ( { hasText : visibiltyOptTwo } ) ;
704+ . filter ( { hasText : visibilityOptTwo } ) ;
704705 await expect ( frVisibilityValue ) . toBeChecked ( ) ;
705706 } ) ;
706707} ) ;
0 commit comments