@@ -177,7 +177,8 @@ test.describe('Error Handling - 401 Unauthorized', () => {
177177 await page . goto ( '/article/test-article' ) ;
178178 // App should handle gracefully - not crash
179179 await expect ( page . locator ( 'nav.navbar' ) ) . toBeVisible ( ) ;
180- // TODO add another check to ensure expected content is there?
180+ // Article content should still be visible
181+ await expect ( page . locator ( '.article-content' ) ) . toBeVisible ( ) ;
181182 } ) ;
182183} ) ;
183184
@@ -297,12 +298,14 @@ test.describe('Error Handling - 403 Forbidden', () => {
297298 await page . goto ( '/article/test-article' ) ;
298299 // Wait for comment to be visible
299300 await expect ( page . locator ( '.card-block:has-text("This is a comment")' ) ) . toBeVisible ( ) ;
300- // Click delete button on the comment
301- await page . locator ( '.card-block:has-text("This is a comment")' ) . locator ( 'i.ion-trash-a' ) . click ( ) ;
302- // Comment should still be visible (delete failed), app should not crash
303- // TODO verify a local failure indicator is present?
301+ // Click delete button on the comment (delete button is in card-footer, sibling of card-block)
302+ await page . locator ( '.card:has-text("This is a comment")' ) . locator ( 'i.ion-trash-a' ) . click ( ) ;
303+ // Comment should still be visible (delete failed)
304304 await expect ( page . locator ( '.card-block:has-text("This is a comment")' ) ) . toBeVisible ( ) ;
305- await expect ( page . locator ( 'nav.navbar' ) ) . toBeVisible ( ) ;
305+ // Error message should be displayed
306+ await expect ( page . locator ( '.error-messages' ) . last ( ) ) . toBeVisible ( ) ;
307+ // Article content should still be visible
308+ await expect ( page . locator ( '.article-content' ) ) . toBeVisible ( ) ;
306309 } ) ;
307310
308311 test ( 'should handle 403 when following user you are blocked by' , async ( { page } ) => {
@@ -729,8 +732,8 @@ test.describe('Error Handling - Network Errors', () => {
729732 await page . goto ( '/article/test-article' ) ;
730733 await page . fill ( 'textarea[placeholder="Write a comment..."]' , 'Test comment' ) ;
731734 await page . click ( 'button:has-text("Post Comment")' ) ;
732- await expect ( page . locator ( '.error-messages' ) ) . toBeVisible ( ) ;
733- await expect ( page . locator ( '.error-messages' ) ) . toContainText ( 'Unable to connect' ) ;
735+ await expect ( page . locator ( '.error-messages' ) . first ( ) ) . toBeVisible ( ) ;
736+ await expect ( page . locator ( '.error-messages' ) . first ( ) ) . toContainText ( 'Unable to connect' ) ;
734737 // Article content should still be visible
735738 await expect ( page . locator ( '.article-content' ) ) . toBeVisible ( ) ;
736739 } ) ;
0 commit comments