Skip to content

Commit

Permalink
Update UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Mar 30, 2024
1 parent 0cafd0a commit d1880e1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# This source file is part of the StrokeCog based on the Stanford Spezi Template Application project
# This source file is part of the StrokeCog proejct based on the Stanford Spezi Template Application project
#
# SPDX-FileCopyrightText: 2023 Stanford University
#
# SPDX-License-Identifier: LicenseRef-Proprietary
# SPDX-License-Identifier: MIT
#

cff-version: 1.2.0
Expand Down
2 changes: 1 addition & 1 deletion StrokeCog/Onboarding/StudyIDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct StudyIDView: View {
},
actionView: {
OnboardingActionsView(
"Continue",
"Next",
action: {
guard validation.validateSubviews() else {
return

Check warning on line 36 in StrokeCog/Onboarding/StudyIDView.swift

View check run for this annotation

Codecov / codecov/patch

StrokeCog/Onboarding/StudyIDView.swift#L36

Added line #L36 was not covered by tests
Expand Down
12 changes: 6 additions & 6 deletions StrokeCog/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@
}
}
}
},
"Continue" : {

},
"CONTRIBUTIONS_LIST_DESCRIPTION" : {
"localizations" : {
Expand Down Expand Up @@ -179,7 +176,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "HealthKit Data Access"
"value" : "HealthKit Access"
}
}
}
Expand Down Expand Up @@ -329,6 +326,9 @@
}
}
}
},
"Next" : {

},
"NOTIFICATION_PERMISSIONS_BUTTON" : {
"localizations" : {
Expand Down Expand Up @@ -539,7 +539,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Continue"
"value" : "Next"
}
}
}
Expand All @@ -560,7 +560,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "\nStrokeCog Study"
"value" : "StrokeCog Study"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion StrokeCogUITests/ContactsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ContactsTests: XCTestCase {
XCTAssertTrue(app.tabBars["Tab Bar"].buttons["Contacts"].waitForExistence(timeout: 2))
app.tabBars["Tab Bar"].buttons["Contacts"].tap()

XCTAssertTrue(app.staticTexts["Contact: Leland Stanford"].waitForExistence(timeout: 2))
XCTAssertTrue(app.staticTexts["Contact: Dr. Michelle Odden"].waitForExistence(timeout: 2))

XCTAssertTrue(app.buttons["Call"].waitForExistence(timeout: 2))
XCTAssertTrue(app.buttons["Text"].waitForExistence(timeout: 2))
Expand Down
32 changes: 21 additions & 11 deletions StrokeCogUITests/OnboardingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension XCUIApplication {
func conductOnboardingIfNeeded(email: String = "[email protected]") throws {
let app = XCUIApplication()

if app.staticTexts["Spezi\nStrokeCog"].waitForExistence(timeout: 5) {
if app.staticTexts["StrokeCog Study"].waitForExistence(timeout: 5) {
try app.navigateOnboardingFlow(email: email)
}
}
Expand All @@ -69,6 +69,9 @@ extension XCUIApplication {
) throws {
try navigateOnboardingFlowWelcome()
try navigateOnboardingFlowInterestingModules()
if staticTexts["Study ID"].waitForExistence(timeout: 5) {
try navigateStudyID()
}
if staticTexts["Your Account"].waitForExistence(timeout: 5) {
try navigateOnboardingAccount(email: email)
}
Expand All @@ -82,16 +85,16 @@ extension XCUIApplication {
}

private func navigateOnboardingFlowWelcome() throws {
XCTAssertTrue(staticTexts["Spezi\nStrokeCog"].waitForExistence(timeout: 5))
XCTAssertTrue(staticTexts["StrokeCog Study"].waitForExistence(timeout: 5))

XCTAssertTrue(buttons["Learn More"].waitForExistence(timeout: 2))
buttons["Learn More"].tap()
XCTAssertTrue(buttons["Next"].waitForExistence(timeout: 2))
buttons["Next"].tap()
}

private func navigateOnboardingFlowInterestingModules() throws {
XCTAssertTrue(staticTexts["Interesting Modules"].waitForExistence(timeout: 5))
XCTAssertTrue(staticTexts["Information"].waitForExistence(timeout: 5))

for _ in 1..<4 {
for _ in 1..<2 {
XCTAssertTrue(buttons["Next"].waitForExistence(timeout: 2))
buttons["Next"].tap()
}
Expand All @@ -100,6 +103,14 @@ extension XCUIApplication {
buttons["Next"].tap()
}

private func navigateStudyID() throws {
XCTAssertTrue(staticTexts["Study ID"].waitForExistence(timeout: 5))

try textFields["Tap here and enter your Study ID"].enter(value: "1234")

buttons["Next"].tap()
}

private func navigateOnboardingAccount(email: String) throws {
if buttons["Logout"].waitForExistence(timeout: 2.0) {
buttons["Logout"].tap()
Expand All @@ -112,8 +123,6 @@ extension XCUIApplication {

try collectionViews.textFields["E-Mail Address"].enter(value: email)
try collectionViews.secureTextFields["Password"].enter(value: "StanfordRocks")
try textFields["enter first name"].enter(value: "Leland")
try textFields["enter last name"].enter(value: "Stanford")

XCTAssertTrue(collectionViews.buttons["Signup"].waitForExistence(timeout: 2))
collectionViews.buttons["Signup"].tap()
Expand All @@ -123,7 +132,6 @@ extension XCUIApplication {
if staticTexts["HealthKit Access"].waitForExistence(timeout: 5) && navigationBars.buttons["Back"].waitForExistence(timeout: 5) {
navigationBars.buttons["Back"].tap()

XCTAssertTrue(staticTexts["Leland Stanford"].waitForExistence(timeout: 2))
XCTAssertTrue(staticTexts[email].waitForExistence(timeout: 2))

XCTAssertTrue(buttons["Next"].waitForExistence(timeout: 2))
Expand All @@ -134,6 +142,10 @@ extension XCUIApplication {
private func navigateOnboardingFlowConsent() throws {
XCTAssertTrue(staticTexts["Consent"].waitForExistence(timeout: 5))

for _ in 1...7 {
swipeUp()
}

XCTAssertTrue(staticTexts["First Name"].waitForExistence(timeout: 2))
try textFields["Enter your first name ..."].enter(value: "Leland")

Expand Down Expand Up @@ -180,9 +192,7 @@ extension XCUIApplication {
navigationBars.buttons["Your Account"].tap()

XCTAssertTrue(staticTexts["Account Overview"].waitForExistence(timeout: 5.0))
XCTAssertTrue(staticTexts["Leland Stanford"].exists)
XCTAssertTrue(staticTexts[email].exists)
XCTAssertTrue(staticTexts["Gender Identity, Choose not to answer"].exists)


XCTAssertTrue(navigationBars.buttons["Close"].waitForExistence(timeout: 0.5))
Expand Down

0 comments on commit d1880e1

Please sign in to comment.