Skip to content

Commit

Permalink
UITests
Browse files Browse the repository at this point in the history
  • Loading branch information
nriedman committed Apr 4, 2024
1 parent 3828048 commit a27e59d
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 15 deletions.
3 changes: 3 additions & 0 deletions ENGAGEHF/Dashboard/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ struct Greeting: View {
HStack {
Text("Hello, world!")
.font(.title2)
.accessibilityLabel(Text("DASHBOARD_GREETING"))
Spacer()
Text(dateString ?? "No date")
.font(.title2)
.accessibilityLabel(Text("DASHBOARD_DATE"))
}
.padding()
.task {
Expand Down Expand Up @@ -58,6 +60,7 @@ struct Dashboard: View {
ToolbarItem(placement: .topBarTrailing) {
AccountButton(isPresented: $presentingAccount)
.foregroundColor(.white)
.accessibilityLabel(Text("DASHBOARD_ACC_BTN"))
}
}
.toolbarBackground(.visible, for: .navigationBar)
Expand Down
1 change: 1 addition & 0 deletions ENGAGEHF/Education/EducationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ struct Education: View {

var body: some View {
Text("Education Test")
.accessibilityLabel(Text("EDU"))
}
}
1 change: 1 addition & 0 deletions ENGAGEHF/HeartHealth/HeartHealthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ struct HeartHealth: View {

var body: some View {
Text("Heart Health Test")
.accessibilityLabel(Text("HH"))
}
}
1 change: 1 addition & 0 deletions ENGAGEHF/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct HomeView: View {
}
}
}
.accessibilityLabel(Text("Tab Bar"))
.sheet(isPresented: $presentingAccount) {
AccountSheet()
}
Expand Down
1 change: 1 addition & 0 deletions ENGAGEHF/Medications/MedicationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ struct Medications: View {

var body: some View {
Text("Medications Test")
.accessibilityLabel(Text("MED"))
}
}
3 changes: 3 additions & 0 deletions ENGAGEHF/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@
}
}
}
},
"Tab Bar" : {

},
"TASK_CONTEXT_ACTION_QUESTIONNAIRE" : {
"localizations" : {
Expand Down
73 changes: 58 additions & 15 deletions ENGAGEHFUITests/HomeViewUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,68 @@ class HomeViewUITests: XCTestCase {
app.launch()
}

// Make sure the correct tabs show and that they go to the correct view
func testHomeTabs() throws {
// Make sure the Dashboard view UI functions correctly
func testDashboard() throws {
let app = XCUIApplication()
let tabBar = app.tabBars["Tab Bar"]

XCTAssertEqual(app.state, .runningForeground)
XCTAssertEqual(app.tabs["Home"].label, "Home")
app.tabs["Home"].tap()
app.tabs["Home"].tap()
// Test Home tab button
XCTAssert(tabBar.buttons["Home"].exists)
tabBar.buttons["Home"].tap()

XCTAssertEqual(app.tabs["Heart Health"].label, "Heart Health")
app.tabs["Heart Health"].tap()
app.tabs["Heart Health"].tap()
// Make sure greeting and title appear, indicating we're in the correct view
XCTAssert(app.staticTexts["DASHBOARD_GREETING"].exists)
XCTAssert(app.staticTexts["ENGAGE-HF: Home"].exists)

XCTAssertEqual(app.tabs["Medications"].label, "Medications")
app.tabs["Medications"].tap()
app.tabs["Medications"].tap()
// Make sure the date appears
XCTAssert(app.staticTexts["DASHBOARD_DATE"].exists)

XCTAssertEqual(app.tabs["Education"].label, "Education")
app.tabs["Education"].tap()
app.tabs["Education"].tap()
// Todo: Test to make sure the date is correct
// let currentDate = Date()
// let dateFormatter = DateFormatter()
// dateFormatter.dateStyle = .short
// XCTAssertEqual(app.staticTexts["DASHBOARD_DATE"].label, dateFormatter.string(from: currentDate))

// Make sure the account button appears and is hittable
XCTAssert(app.buttons["DASHBOARD_ACC_BTN"].exists && app.buttons["DASHBOARD_ACC_BTN"].isHittable)
}

// Test the Heart Health View
func testHeartHealth() throws {
let app = XCUIApplication()
let tabBar = app.tabBars["Tab Bar"]

// Make sure the Heart Health tab button appears and takes us to correct screen
XCTAssert(tabBar.buttons["Heart Health"].exists)
tabBar.buttons["Heart Health"].tap()

// Make sure filler text appears
XCTAssert(app.staticTexts["HH"].exists)
}

// Test the Medications view
func testMedications() throws {
let app = XCUIApplication()
let tabBar = app.tabBars["Tab Bar"]

// Make sure the Medications tab button appears and takes us to the correct screen
XCTAssert(tabBar.buttons["Medications"].exists)
tabBar.buttons["Medications"].tap()

// Make sure the filler text appears
XCTAssert(app.staticTexts["MED"].exists)
}

// Test the Education view
func testEducation() throws {
let app = XCUIApplication()
let tabBar = app.tabBars["Tab Bar"]

// Make sure the Education tab button appears and takes us to the correct screen
XCTAssert(tabBar.buttons["Education"].exists)
tabBar.buttons["Education"].tap()

// Make sure the filler text appears
XCTAssert(app.staticTexts["EDU"].exists)
}
}

0 comments on commit a27e59d

Please sign in to comment.