diff --git a/ENGAGEHF/Dashboard/DashboardView.swift b/ENGAGEHF/Dashboard/DashboardView.swift index c8bd4d89..344b24e4 100644 --- a/ENGAGEHF/Dashboard/DashboardView.swift +++ b/ENGAGEHF/Dashboard/DashboardView.swift @@ -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 { @@ -58,6 +60,7 @@ struct Dashboard: View { ToolbarItem(placement: .topBarTrailing) { AccountButton(isPresented: $presentingAccount) .foregroundColor(.white) + .accessibilityLabel(Text("DASHBOARD_ACC_BTN")) } } .toolbarBackground(.visible, for: .navigationBar) diff --git a/ENGAGEHF/Education/EducationView.swift b/ENGAGEHF/Education/EducationView.swift index 79a1b524..978e6764 100644 --- a/ENGAGEHF/Education/EducationView.swift +++ b/ENGAGEHF/Education/EducationView.swift @@ -20,5 +20,6 @@ struct Education: View { var body: some View { Text("Education Test") + .accessibilityLabel(Text("EDU")) } } diff --git a/ENGAGEHF/HeartHealth/HeartHealthView.swift b/ENGAGEHF/HeartHealth/HeartHealthView.swift index b3b59177..e7e771ec 100644 --- a/ENGAGEHF/HeartHealth/HeartHealthView.swift +++ b/ENGAGEHF/HeartHealth/HeartHealthView.swift @@ -20,5 +20,6 @@ struct HeartHealth: View { var body: some View { Text("Heart Health Test") + .accessibilityLabel(Text("HH")) } } diff --git a/ENGAGEHF/Home.swift b/ENGAGEHF/Home.swift index 3386a891..ef8aeb24 100644 --- a/ENGAGEHF/Home.swift +++ b/ENGAGEHF/Home.swift @@ -59,6 +59,7 @@ struct HomeView: View { } } } + .accessibilityLabel(Text("Tab Bar")) .sheet(isPresented: $presentingAccount) { AccountSheet() } diff --git a/ENGAGEHF/Medications/MedicationsView.swift b/ENGAGEHF/Medications/MedicationsView.swift index 53d21270..9fab4c98 100644 --- a/ENGAGEHF/Medications/MedicationsView.swift +++ b/ENGAGEHF/Medications/MedicationsView.swift @@ -20,5 +20,6 @@ struct Medications: View { var body: some View { Text("Medications Test") + .accessibilityLabel(Text("MED")) } } diff --git a/ENGAGEHF/Resources/Localizable.xcstrings b/ENGAGEHF/Resources/Localizable.xcstrings index 4fa77ed1..9715e153 100644 --- a/ENGAGEHF/Resources/Localizable.xcstrings +++ b/ENGAGEHF/Resources/Localizable.xcstrings @@ -377,6 +377,9 @@ } } } + }, + "Tab Bar" : { + }, "TASK_CONTEXT_ACTION_QUESTIONNAIRE" : { "localizations" : { diff --git a/ENGAGEHFUITests/HomeViewUITests.swift b/ENGAGEHFUITests/HomeViewUITests.swift index c6d407d5..8c88590c 100644 --- a/ENGAGEHFUITests/HomeViewUITests.swift +++ b/ENGAGEHFUITests/HomeViewUITests.swift @@ -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) } }