11import { test , expect } from "@playwright/test" ;
2- import { login } from "../../utils/auth.ts" ;
2+ import { login } from "../../utils/auth.ts"
33import { formatNumber } from '../../utils/common.ts' ;
44import fixtureData from "./fieldReport.json" ;
55
@@ -239,21 +239,15 @@ test.describe("test suite for Field report", async () => {
239239 const sections = [
240240 {
241241 childText : 'Actions taken by National Society' ,
242- actions : [ actionHuman , actionShelter , actionEvacuation ] ,
243- summaryIndex : 0 ,
244- summaryText : nationalSocietySummary
242+ actions : [ actionHuman , actionShelter , actionEvacuation , nationalSocietySummary ]
245243 } ,
246244 {
247245 childText : 'Actions Taken by Federation' ,
248- actions : [ actionHealth , actionShelter , actionCamp ] ,
249- summaryIndex : 1 ,
250- summaryText : federationSummary
246+ actions : [ actionHealth , actionShelter , actionCamp , federationSummary ]
251247 } ,
252248 {
253249 childText : 'Actions Taken by RCRC' ,
254- actions : [ actionFirst , actionPsychosocial , actionFood ] ,
255- summaryIndex : 2 ,
256- summaryText : rcrcSummary
250+ actions : [ actionFirst , actionPsychosocial , actionFood , rcrcSummary ]
257251 }
258252 ] ;
259253
@@ -264,9 +258,6 @@ test.describe("test suite for Field report", async () => {
264258 for ( const action of section . actions ) {
265259 await expect ( sectionParent ) . toContainText ( action ) ;
266260 }
267-
268- const summary = page . getByText ( 'Summary' ) . nth ( section . summaryIndex ) . locator ( '..' ) ;
269- await expect ( summary ) . toContainText ( section . summaryText ) ;
270261 }
271262 // Actions taken by others assertions
272263 const actionParent = page . getByText ( 'Actions taken by others' , { exact : true } ) ;
@@ -281,19 +272,24 @@ test.describe("test suite for Field report", async () => {
281272 await expect ( rapidPI ) . toHaveText ( "Rapid Response Personnel" + interventionOptionThree ) ;
282273 const emergencyResponsePI = page . getByText ( 'Emergency Response Units' , { exact : true } ) . locator ( '..' ) ;
283274 await expect ( emergencyResponsePI ) . toHaveText ( "Emergency Response Units" + interventionOptionTwo ) ;
275+
284276 // Assertions to verify the contacts
285- // Originator
286- const originatorDetail = page . getByText ( 'Uday, Project Manager, [email protected] , 9802556314' ) ; 287- expect ( originatorDetail ) . toContainText ( originatorName + ", " + originatorTitle + ", " + originatorEmail + ", " + originatorPhone ) ;
288- // National Society
289- const nationalSocietyDetail = page . getByText ( 'Navin, Network Engineer, [email protected] , 9804115777' ) ; 290- expect ( nationalSocietyDetail ) . toContainText ( nationalName + ", " + nationalTitle + ", " + nationalEmail + ", " + nationalPhone ) ;
291- // Federation
292- const federationDetail = page . getByText ( "Ankit, CEO, [email protected] , 9801447523" ) ; 293- expect ( federationDetail ) . toContainText ( ifrcName + ", " + ifrcTitle + ", " + ifrcEmail + ", " + ifrcPhone ) ;
294- // Media
295- const mediaDetail = page . getByText ( "Shreya, Shreya uffu, [email protected] , 9805441239" ) ; 296- expect ( mediaDetail ) . toContainText ( mediaName + ", " + mediaTitle + ", " + mediaEmail + ", " + mediaPhone ) ;
277+ const details = [
278+ { label : 'Originator' , name : originatorName , title : originatorTitle , email : originatorEmail , phone : originatorPhone } ,
279+ { label : 'NationalSociety' , name : nationalName , title : nationalTitle , email : nationalEmail , phone : nationalPhone } ,
280+ { label : 'Federation' , name : ifrcName , title : ifrcTitle , email : ifrcEmail , phone : ifrcPhone } ,
281+ { label : 'Media' , name : mediaName , title : mediaTitle , email : mediaEmail , phone : mediaPhone }
282+ ] ;
283+
284+ for ( const detail of details ) {
285+ const detailLocator = page . getByText ( detail . label , { exact : true } ) . locator ( '..' ) ;
286+ await expect ( detailLocator ) . toContainText ( detail . name ) ;
287+ await expect ( detailLocator ) . toContainText ( detail . title ) ;
288+ await expect ( detailLocator ) . toContainText ( detail . email ) ;
289+ await expect ( detailLocator ) . toContainText ( detail . phone ) ;
290+ }
291+
292+
297293 } ) ;
298294} ) ;
299295
0 commit comments