Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 15 additions & 25 deletions FeedbridgeUITests/AddBabyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class AddBabyTests: XCTestCase {
app.buttons["Settings"].tap()

// Verify initial state: No baby should be selected
XCTAssertTrue(app.staticTexts["Select Baby"].exists, "Select baby dropdown should be visible")
XCTAssertTrue(app.staticTexts["No baby selected"].exists, "No babies should exist")
XCTAssertTrue(app.staticTexts["Select Baby"].waitForExistence(timeout: 5), "Select baby dropdown should be visible")
XCTAssertTrue(app.staticTexts["No baby selected"].waitForExistence(timeout: 5), "No babies should exist")

// Open the dropdown menu and select "Add New Baby"
let dropdown = app.buttons["Baby icon, Select Baby, Menu dropdown"]
dropdown.tap()
let addNew = app.buttons["Add New Baby"]
XCTAssertTrue(addNew.exists, "Should be an option to add a baby")
XCTAssertTrue(addNew.waitForExistence(timeout: 5), "Should be an option to add a baby")
addNew.tap()

// Ensure that the Save button is initially disabled
Expand All @@ -67,7 +67,7 @@ class AddBabyTests: XCTestCase {
nameField.typeText("Benjamin")

// Verify that a duplicate name warning is not displayed
XCTAssertFalse(app.staticTexts["This name is already taken"].exists, "Duplicate name warning should not appear")
XCTAssertFalse(app.staticTexts["This name is already taken"].waitForExistence(timeout: 5), "Duplicate name warning should not appear")

// Date Picker: Select March 2025 (valid past date)
let datePickersQuery = app.datePickers.firstMatch
Expand All @@ -82,24 +82,14 @@ class AddBabyTests: XCTestCase {
saveButton.tap()

// Verify that the new baby is correctly added and displayed in the UI
XCTAssertTrue(app.staticTexts["Benjamin"].exists, "Baby's name should be displayed")
XCTAssertTrue(app.buttons["Baby icon, Benjamin, Menu dropdown"].exists, "Baby dropdown should show new baby")
XCTAssertTrue(app.buttons["Delete Baby, Delete Baby"].exists, "Delete button should be displayed for the new baby")
XCTAssertTrue(app.staticTexts["Use Kilograms"].exists, "The 'Use Kilograms' text should be displayed")
}

func testNavigateToHealthDetails() {
let app = XCUIApplication()
// app.buttons["Settings"].tap()

// Ensure at least one baby
if app.staticTexts["No baby selected"].exists {
testAddBaby()
}

XCTAssertTrue(app.staticTexts["Benjamin"].waitForExistence(timeout: 5), "Baby's name should be displayed")
XCTAssertTrue(app.buttons["Baby icon, Benjamin, Menu dropdown"].waitForExistence(timeout: 5), "Baby dropdown should show new baby")
XCTAssertTrue(app.buttons["Delete Baby, Delete Baby"].waitForExistence(timeout: 5), "Delete button should be displayed for the new baby")
XCTAssertTrue(app.staticTexts["Use Kilograms"].waitForExistence(timeout: 5), "The 'Use Kilograms' text should be displayed")

let healthDetailsCell = app.staticTexts["Health Details"]
XCTAssertTrue(
healthDetailsCell.exists,
healthDetailsCell.waitForExistence(timeout: 5),
"Health Details navigation link not found."
)
healthDetailsCell.tap()
Expand All @@ -112,10 +102,10 @@ class AddBabyTests: XCTestCase {

print("DEBUG: Current UI for 'AddEntryView':\n\(app.debugDescription)")

XCTAssertTrue(app.staticTexts["FEED ENTRIES"].exists, "Feed Entries exists")
XCTAssertTrue(app.staticTexts["WEIGHT ENTRIES"].exists, "Weight Entries exists")
XCTAssertTrue(app.staticTexts["STOOL ENTRIES"].exists, "Stool Entries exists")
XCTAssertTrue(app.staticTexts["VOID ENTRIES"].exists, "Void Entries exists")
XCTAssertTrue(app.staticTexts["DEHYDRATION CHECKS"].exists, "Dehydration Checks exists")
XCTAssertTrue(app.staticTexts["FEED ENTRIES"].waitForExistence(timeout: 5), "Feed Entries exists")
XCTAssertTrue(app.staticTexts["WEIGHT ENTRIES"].waitForExistence(timeout: 5), "Weight Entries exists")
XCTAssertTrue(app.staticTexts["STOOL ENTRIES"].waitForExistence(timeout: 5), "Stool Entries exists")
XCTAssertTrue(app.staticTexts["VOID ENTRIES"].waitForExistence(timeout: 5), "Void Entries exists")
XCTAssertTrue(app.staticTexts["DEHYDRATION CHECKS"].waitForExistence(timeout: 5), "Dehydration Checks exists")
}
}
14 changes: 7 additions & 7 deletions FeedbridgeUITests/AddEntryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ final class AddEntryTests: XCTestCase {

// Check that "No babies found" is displayed
XCTAssertTrue(
app.staticTexts["No babies found"].exists,
app.staticTexts["No babies found"].waitForExistence(timeout: 5),
"Should show 'No babies found' message if there are no babies."
)
XCTAssertTrue(app.staticTexts["Please add a baby in Settings before adding entries."].exists)
XCTAssertTrue(app.staticTexts["Please add a baby in Settings before adding entries."].waitForExistence(timeout: 5))
}

/// Tests adding a weight entry in kilograms.
Expand Down Expand Up @@ -219,7 +219,7 @@ final class AddEntryTests: XCTestCase {
// Enter a feed time
let feedTimeField = app.textFields["Feed time (minutes)"]
XCTAssertTrue(
feedTimeField.exists, "Feed time text field should be present for direct breastfeeding."
feedTimeField.waitForExistence(timeout: 5), "Feed time text field should be present for direct breastfeeding."
)
feedTimeField.tap()
feedTimeField.typeText("15")
Expand Down Expand Up @@ -362,12 +362,12 @@ final class AddEntryTests: XCTestCase {

// Toggle poor skin elasticity
let poorSkinSwitch = app.switches["Poor Skin Elasticity"]
XCTAssertTrue(poorSkinSwitch.exists, "Poor Skin Elasticity toggle not found.")
XCTAssertTrue(poorSkinSwitch.waitForExistence(timeout: 5), "Poor Skin Elasticity toggle not found.")
poorSkinSwitch.tap()

// Toggle dry mucous membranes
let dryMucousSwitch = app.switches["Dry Mucous Membranes"]
XCTAssertTrue(dryMucousSwitch.exists, "Dry Mucous Membranes toggle not found.")
XCTAssertTrue(dryMucousSwitch.waitForExistence(timeout: 5), "Dry Mucous Membranes toggle not found.")
dryMucousSwitch.tap()

print("DEBUG: Dehydration toggles set on")
Expand Down Expand Up @@ -422,7 +422,7 @@ final class AddEntryTests: XCTestCase {

// At this point, the entry won't be saved, so "Entry saved successfully!" should NOT appear
let successBanner = app.staticTexts["Entry saved successfully!"]
XCTAssertFalse(successBanner.exists, "Success banner should not appear with invalid input.")
XCTAssertFalse(successBanner.waitForExistence(timeout: 5), "Success banner should not appear with invalid input.")
}

/// Tests that invalid feeding input (zero or negative time or volume) is handled properly.
Expand Down Expand Up @@ -460,7 +460,7 @@ final class AddEntryTests: XCTestCase {

let successBanner = app.staticTexts["Entry saved successfully!"]
XCTAssertFalse(
successBanner.exists, "Success banner should not appear with invalid feeding data."
successBanner.waitForExistence(timeout: 5), "Success banner should not appear with invalid feeding data."
)
}
}
Loading