@@ -47,14 +47,14 @@ class AddBabyTests: XCTestCase {
4747 app. buttons [ " Settings " ] . tap ( )
4848
4949 // Verify initial state: No baby should be selected
50- XCTAssertTrue ( app. staticTexts [ " Select Baby " ] . exists , " Select baby dropdown should be visible " )
51- XCTAssertTrue ( app. staticTexts [ " No baby selected " ] . exists , " No babies should exist " )
50+ XCTAssertTrue ( app. staticTexts [ " Select Baby " ] . waitForExistence ( timeout : 5 ) , " Select baby dropdown should be visible " )
51+ XCTAssertTrue ( app. staticTexts [ " No baby selected " ] . waitForExistence ( timeout : 5 ) , " No babies should exist " )
5252
5353 // Open the dropdown menu and select "Add New Baby"
5454 let dropdown = app. buttons [ " Baby icon, Select Baby, Menu dropdown " ]
5555 dropdown. tap ( )
5656 let addNew = app. buttons [ " Add New Baby " ]
57- XCTAssertTrue ( addNew. exists , " Should be an option to add a baby " )
57+ XCTAssertTrue ( addNew. waitForExistence ( timeout : 5 ) , " Should be an option to add a baby " )
5858 addNew. tap ( )
5959
6060 // Ensure that the Save button is initially disabled
@@ -67,7 +67,7 @@ class AddBabyTests: XCTestCase {
6767 nameField. typeText ( " Benjamin " )
6868
6969 // Verify that a duplicate name warning is not displayed
70- XCTAssertFalse ( app. staticTexts [ " This name is already taken " ] . exists , " Duplicate name warning should not appear " )
70+ XCTAssertFalse ( app. staticTexts [ " This name is already taken " ] . waitForExistence ( timeout : 5 ) , " Duplicate name warning should not appear " )
7171
7272 // Date Picker: Select March 2025 (valid past date)
7373 let datePickersQuery = app. datePickers. firstMatch
@@ -82,24 +82,14 @@ class AddBabyTests: XCTestCase {
8282 saveButton. tap ( )
8383
8484 // Verify that the new baby is correctly added and displayed in the UI
85- XCTAssertTrue ( app. staticTexts [ " Benjamin " ] . exists, " Baby's name should be displayed " )
86- XCTAssertTrue ( app. buttons [ " Baby icon, Benjamin, Menu dropdown " ] . exists, " Baby dropdown should show new baby " )
87- XCTAssertTrue ( app. buttons [ " Delete Baby, Delete Baby " ] . exists, " Delete button should be displayed for the new baby " )
88- XCTAssertTrue ( app. staticTexts [ " Use Kilograms " ] . exists, " The 'Use Kilograms' text should be displayed " )
89- }
90-
91- func testNavigateToHealthDetails( ) {
92- let app = XCUIApplication ( )
93- // app.buttons["Settings"].tap()
94-
95- // Ensure at least one baby
96- if app. staticTexts [ " No baby selected " ] . exists {
97- testAddBaby ( )
98- }
99-
85+ XCTAssertTrue ( app. staticTexts [ " Benjamin " ] . waitForExistence ( timeout: 5 ) , " Baby's name should be displayed " )
86+ XCTAssertTrue ( app. buttons [ " Baby icon, Benjamin, Menu dropdown " ] . waitForExistence ( timeout: 5 ) , " Baby dropdown should show new baby " )
87+ XCTAssertTrue ( app. buttons [ " Delete Baby, Delete Baby " ] . waitForExistence ( timeout: 5 ) , " Delete button should be displayed for the new baby " )
88+ XCTAssertTrue ( app. staticTexts [ " Use Kilograms " ] . waitForExistence ( timeout: 5 ) , " The 'Use Kilograms' text should be displayed " )
89+
10090 let healthDetailsCell = app. staticTexts [ " Health Details " ]
10191 XCTAssertTrue (
102- healthDetailsCell. exists ,
92+ healthDetailsCell. waitForExistence ( timeout : 5 ) ,
10393 " Health Details navigation link not found. "
10494 )
10595 healthDetailsCell. tap ( )
@@ -112,10 +102,10 @@ class AddBabyTests: XCTestCase {
112102
113103 print ( " DEBUG: Current UI for 'AddEntryView': \n \( app. debugDescription) " )
114104
115- XCTAssertTrue ( app. staticTexts [ " FEED ENTRIES " ] . exists , " Feed Entries exists " )
116- XCTAssertTrue ( app. staticTexts [ " WEIGHT ENTRIES " ] . exists , " Weight Entries exists " )
117- XCTAssertTrue ( app. staticTexts [ " STOOL ENTRIES " ] . exists , " Stool Entries exists " )
118- XCTAssertTrue ( app. staticTexts [ " VOID ENTRIES " ] . exists , " Void Entries exists " )
119- XCTAssertTrue ( app. staticTexts [ " DEHYDRATION CHECKS " ] . exists , " Dehydration Checks exists " )
105+ XCTAssertTrue ( app. staticTexts [ " FEED ENTRIES " ] . waitForExistence ( timeout : 5 ) , " Feed Entries exists " )
106+ XCTAssertTrue ( app. staticTexts [ " WEIGHT ENTRIES " ] . waitForExistence ( timeout : 5 ) , " Weight Entries exists " )
107+ XCTAssertTrue ( app. staticTexts [ " STOOL ENTRIES " ] . waitForExistence ( timeout : 5 ) , " Stool Entries exists " )
108+ XCTAssertTrue ( app. staticTexts [ " VOID ENTRIES " ] . waitForExistence ( timeout : 5 ) , " Void Entries exists " )
109+ XCTAssertTrue ( app. staticTexts [ " DEHYDRATION CHECKS " ] . waitForExistence ( timeout : 5 ) , " Dehydration Checks exists " )
120110 }
121111}
0 commit comments