@@ -21,6 +21,8 @@ test.describe("Notifications Page", () => {
2121
2222 test . describe ( "Authenticated - No Notifications" , ( ) => {
2323 test . beforeEach ( async ( { page } ) => {
24+ // Clear notifications for user two before testing empty state
25+ await clearNotifications ( E2E_USER_TWO_ID ) ;
2426 await loggedInAsUserTwo ( page ) ;
2527 } ) ;
2628
@@ -30,12 +32,14 @@ test.describe("Notifications Page", () => {
3032 page . getByRole ( "heading" , { name : "Notifications" } ) ,
3133 ) . toBeVisible ( ) ;
3234 // Should show empty state message
33- await expect ( page . getByText ( " No new notifications" ) ) . toBeVisible ( ) ;
35+ await expect ( page . getByText ( / N o n e w n o t i f i c a t i o n s / ) ) . toBeVisible ( ) ;
3436 } ) ;
3537 } ) ;
3638
3739 test . describe ( "Authenticated - With Notifications" , ( ) => {
3840 test . beforeEach ( async ( { page } ) => {
41+ // Clear notifications before each test to ensure clean state
42+ await clearNotifications ( E2E_USER_ONE_ID ) ;
3943 await loggedInAsUserOne ( page ) ;
4044 } ) ;
4145
@@ -75,9 +79,11 @@ test.describe("Notifications Page", () => {
7579 } ) ;
7680
7781 await page . goto ( "http://localhost:3000/notifications" ) ;
82+ // Wait for notifications to load
83+ await page . waitForLoadState ( "domcontentloaded" ) ;
7884 await expect (
7985 page . getByRole ( "button" , { name : "Mark all as read" } ) ,
80- ) . toBeVisible ( ) ;
86+ ) . toBeVisible ( { timeout : 15000 } ) ;
8187 } ) ;
8288
8389 test ( "Should be able to mark individual notification as read" , async ( {
@@ -91,10 +97,12 @@ test.describe("Notifications Page", () => {
9197 } ) ;
9298
9399 await page . goto ( "http://localhost:3000/notifications" ) ;
100+ // Wait for notifications to load
101+ await page . waitForLoadState ( "domcontentloaded" ) ;
94102
95103 // Wait for notification to appear
96104 await page . waitForSelector ( 'button[title="Mark as read"]' , {
97- timeout : 10000 ,
105+ timeout : 15000 ,
98106 } ) ;
99107
100108 // Click mark as read button
@@ -216,13 +224,14 @@ test.describe("Notifications Page", () => {
216224 // Log back in as user one and check for notification
217225 await loggedInAsUserOne ( page ) ;
218226 await page . goto ( "http://localhost:3000/notifications" ) ;
227+ await page . waitForLoadState ( "domcontentloaded" ) ;
219228
220229 await expect ( page . getByText ( "E2E Test User Two" ) . first ( ) ) . toBeVisible ( {
221230 timeout : 15000 ,
222231 } ) ;
223232 await expect (
224- page . getByText ( " replied to your comment" ) . first ( ) ,
225- ) . toBeVisible ( ) ;
233+ page . getByText ( / r e p l i e d t o y o u r c o m m e n t / ) . first ( ) ,
234+ ) . toBeVisible ( { timeout : 10000 } ) ;
226235 } ) ;
227236 } ) ;
228237} ) ;
0 commit comments