1- import { Page , Locator , expect } from '@playwright/test' ;
1+ import { Page , Locator , expect } from '@playwright/test' ;
22
33export class HomePage {
44 readonly page : Page ;
55 readonly expectedTitle : "Home" ;
66 readonly loggedInUser : Locator ;
77
8- constructor ( page : Page ) {
8+ // Header elements
9+ readonly accountLink : Locator ;
10+ readonly locationBadge : Locator ;
11+ readonly homeIcon : Locator ;
12+ readonly welcomeHeading : Locator ;
13+ readonly logoutButton : Locator ;
14+
15+ // Dashboard Apps
16+ readonly findPatientRecordApp : Locator ;
17+ readonly activeVisitsApp : Locator ;
18+ readonly captureVitalsApp : Locator ;
19+ readonly registerPatientApp : Locator ;
20+ readonly appointmentSchedulingApp : Locator ;
21+ readonly reportsApp : Locator ;
22+ readonly dataManagementApp : Locator ;
23+ readonly configureMetadataApp : Locator ;
24+ readonly systemAdministrationApp : Locator ;
25+
26+ constructor ( page : Page ) {
927 this . page = page ;
1028 this . expectedTitle = "Home" ;
1129 this . loggedInUser = page . locator ( 'li.nav-item.identifier' ) ;
30+
31+ // Initialize Header elements
32+ this . accountLink = page . getByText ( 'admin My Account' ) ;
33+ // Note: The location badge might change based on selection, but using the one from codegen for now
34+ // A more robust way would be to look for the ID or class, but sticking to codegen text as requested
35+ this . locationBadge = page . getByRole ( 'link' , { name : / I n p a t i e n t W a r d | I s o l a t i o n W a r d / } ) . first ( ) ;
36+ this . homeIcon = page . getByRole ( 'link' ) . first ( ) ;
37+ this . welcomeHeading = page . getByRole ( 'heading' , { name : 'Logged in as Super User (' } ) ;
38+ this . logoutButton = page . getByRole ( 'link' , { name : 'Logout ' } ) ;
39+
40+ // Initialize Dashboard Apps
41+ this . findPatientRecordApp = page . getByRole ( 'link' , { name : ' Find Patient Record' } ) ;
42+ this . activeVisitsApp = page . getByRole ( 'link' , { name : ' Active Visits' } ) ;
43+ this . captureVitalsApp = page . getByRole ( 'link' , { name : ' Capture Vitals' } ) ;
44+ this . registerPatientApp = page . getByRole ( 'link' , { name : ' Register a patient' } ) ;
45+ this . appointmentSchedulingApp = page . getByRole ( 'link' , { name : ' Appointment Scheduling' } ) ;
46+ this . reportsApp = page . getByRole ( 'link' , { name : ' Reports' } ) ;
47+ this . dataManagementApp = page . getByRole ( 'link' , { name : ' Data Management' } ) ;
48+ this . configureMetadataApp = page . getByRole ( 'link' , { name : ' Configure Metadata' } ) ;
49+ this . systemAdministrationApp = page . getByRole ( 'link' , { name : ' System Administration' } ) ;
1250 }
1351
1452 async verifyHomePage ( ) {
1553 await expect ( this . page ) . toHaveTitle ( this . expectedTitle ) ;
1654 await expect ( this . loggedInUser ) . toBeVisible ( ) ;
1755 }
56+
57+ async verifyDashboardElements ( ) {
58+ // Verify Header
59+ await Promise . all ( [
60+ expect ( this . accountLink ) . toBeVisible ( ) ,
61+ // Location badge might vary, checking if at least one is visible if we want to be strict,
62+ // but for now let's check the one we defined.
63+ // await expect(this.locationBadge).toBeVisible(); // Commenting out as it might be flaky if location changes
64+ expect ( this . homeIcon ) . toBeVisible ( ) ,
65+ expect ( this . welcomeHeading ) . toBeVisible ( ) ,
66+ expect ( this . logoutButton ) . toBeVisible ( ) ,
67+ ] ) ;
68+
69+ // Verify Apps
70+ await Promise . all ( [
71+ expect ( this . findPatientRecordApp ) . toBeVisible ( ) ,
72+ expect ( this . activeVisitsApp ) . toBeVisible ( ) ,
73+ expect ( this . captureVitalsApp ) . toBeVisible ( ) ,
74+ expect ( this . registerPatientApp ) . toBeVisible ( ) ,
75+ expect ( this . appointmentSchedulingApp ) . toBeVisible ( ) ,
76+ expect ( this . reportsApp ) . toBeVisible ( ) ,
77+ expect ( this . dataManagementApp ) . toBeVisible ( ) ,
78+ expect ( this . configureMetadataApp ) . toBeVisible ( ) ,
79+ expect ( this . systemAdministrationApp ) . toBeVisible ( ) ,
80+ ] ) ;
81+ }
1882}
0 commit comments