Skip to content

Commit

Permalink
Fix UI Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer committed Dec 4, 2024
1 parent 7154a78 commit 2912056
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions ENGAGEHF/Account/InvitationCodeModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class InvitationCodeModule: Module, EnvironmentAccessible {
details.password = password
details.name = PersonNameComponents(givenName: "Leland", familyName: "Stanford")
try await accountService.signUp(with: details)
try await Task.sleep(for: .seconds(0.5))
try await verifyOnboardingCode(invitationCode)
} catch {
logger.error("Failed setting up test account : \(error)")
Expand Down
16 changes: 13 additions & 3 deletions ENGAGEHFUITests/Dashboard/RecentVitalsUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
import XCTest

final class RecentVitalsUITests: XCTestCase {
private var expectedFormattedMeasurementDate: String {
let expectedDateComponents = DateComponents(year: 2024, month: 6, day: 5, hour: 12, minute: 33, second: 11)
let expectedDate = Calendar.current.date(from: expectedDateComponents) ?? .now
let daylightSavingTimeOffset = TimeZone.current.daylightSavingTimeOffset(for: expectedDate)
let formatter = DateFormatter()
formatter.dateFormat = "M/d/yyyy, h:mm a"
return formatter.string(from: expectedDate.addingTimeInterval(daylightSavingTimeOffset))
}


override func setUpWithError() throws {
try super.setUpWithError()

Expand Down Expand Up @@ -58,7 +68,7 @@ final class RecentVitalsUITests: XCTestCase {
XCTAssert(app.staticTexts["Recent Vitals"].waitForExistence(timeout: 0.5))
XCTAssert(app.staticTexts["Weight Quantity: \(expectedWeight)"].exists)
XCTAssert(app.staticTexts["Weight Unit: \(weightUnit)"].exists)
XCTAssert(app.staticTexts["Weight Date: 6/5/2024, 12:33 PM"].exists)
XCTAssert(app.staticTexts["Weight Date: \(expectedFormattedMeasurementDate)"].exists)

app.staticTexts["Weight Quantity: \(expectedWeight)"].tap()
XCTAssert(app.staticTexts["Body Weight"].waitForExistence(timeout: 2.0))
Expand Down Expand Up @@ -103,7 +113,7 @@ final class RecentVitalsUITests: XCTestCase {
let heartRateQuantityText = "Heart Rate Quantity: 62"
XCTAssert(app.staticTexts[heartRateQuantityText].exists)
XCTAssert(app.staticTexts["Heart Rate Unit: BPM"].exists)
XCTAssert(app.staticTexts["Heart Rate Date: 6/5/2024, 12:33 PM"].exists)
XCTAssert(app.staticTexts["Heart Rate Date: \(expectedFormattedMeasurementDate)"].exists)

app.staticTexts[heartRateQuantityText].tap()
XCTAssert(app.staticTexts["Heart Rate"].waitForExistence(timeout: 2.0))
Expand All @@ -114,7 +124,7 @@ final class RecentVitalsUITests: XCTestCase {
let bloodPressureQuantityText = "Blood Pressure Quantity: 103/64"
XCTAssert(app.staticTexts[bloodPressureQuantityText].exists)
XCTAssert(app.staticTexts["Blood Pressure Unit: mmHg"].exists)
XCTAssert(app.staticTexts["Blood Pressure Date: 6/5/2024, 12:33 PM"].exists)
XCTAssert(app.staticTexts["Blood Pressure Date: \(expectedFormattedMeasurementDate)"].exists)

app.staticTexts[bloodPressureQuantityText].tap()
XCTAssert(app.staticTexts["Blood Pressure"].waitForExistence(timeout: 2.0))
Expand Down

0 comments on commit 2912056

Please sign in to comment.