Skip to content

Commit

Permalink
Make tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
philippzagar committed Jan 24, 2025
1 parent 4f6f7b5 commit ef0827f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions Tests/UITests/TestAppUITests/SpeziOnboardingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ final class OnboardingTests: XCTestCase {
// Check if on custom test view 1
XCTAssert(app.staticTexts["Custom Test View 1: Hello Spezi!"].waitForExistence(timeout: 2))

XCTAssert(app.buttons["Next"].exists)
XCTAssert(app.buttons["Next"].waitForExistence(timeout: 2))
app.buttons["Next"].tap()

// Check if on custom test view 2
XCTAssert(app.staticTexts["Custom Test View 2"].waitForExistence(timeout: 2))

XCTAssert(app.buttons["Next"].exists)
XCTAssert(app.buttons["Next"].waitForExistence(timeout: 2))
app.buttons["Next"].tap()

// Check if on welcome onboarding view
Expand Down Expand Up @@ -279,12 +279,12 @@ final class OnboardingTests: XCTestCase {
XCTAssert(app.buttons["Show Conditional View"].waitForExistence(timeout: 2))
app.buttons["Show Conditional View"].tap()

XCTAssert(app.buttons["Next"].exists)
XCTAssert(app.buttons["Next"].waitForExistence(timeout: 2))
app.buttons["Next"].tap()

// Check if on conditional test view
XCTAssert(app.staticTexts["Conditional Test View"].waitForExistence(timeout: 2))
XCTAssert(app.buttons["Next"].exists)
XCTAssert(app.buttons["Next"].waitForExistence(timeout: 2))
app.buttons["Next"].tap()

// Check if on final page
Expand All @@ -301,9 +301,11 @@ final class OnboardingTests: XCTestCase {
app.buttons["Onboarding Identifiable View"].tap()

XCTAssert(app.staticTexts["ID: 1"].waitForExistence(timeout: 2))
XCTAssert(app.buttons["Next"].waitForExistence(timeout: 2))
app.buttons["Next"].tap()

XCTAssert(app.staticTexts["ID: 2"].waitForExistence(timeout: 2))
XCTAssert(app.buttons["Next"].waitForExistence(timeout: 2))
app.buttons["Next"].tap()

XCTAssert(app.staticTexts["Welcome"].waitForExistence(timeout: 2))
Expand Down
14 changes: 7 additions & 7 deletions Tests/UITests/TestAppUITests/XCUIApplication+Onboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension XCUIApplication {
// Check if on consent export page
XCTAssert(staticTexts["First Consent PDF rendering doesn't exist"].waitForExistence(timeout: 2))

XCTAssert(buttons["Next"].exists)
XCTAssert(buttons["Next"].waitForExistence(timeout: 2))
buttons["Next"].tap()

try consentViewOnboardingFlow(consentTitle: "Second Consent", markdownText: "This is the second markdown example")
Expand All @@ -52,7 +52,7 @@ extension XCUIApplication {
// Check if on conditional test view
XCTAssert(staticTexts["Conditional Test View"].waitForExistence(timeout: 2))

XCTAssert(buttons["Next"].exists)
XCTAssert(buttons["Next"].waitForExistence(timeout: 2))
buttons["Next"].tap()
}

Expand All @@ -62,16 +62,16 @@ extension XCUIApplication {

func consentViewOnboardingFlow(consentTitle: String, markdownText: String) throws {
XCTAssert(staticTexts[consentTitle].waitForExistence(timeout: 2))
XCTAssert(staticTexts[markdownText].exists)
XCTAssert(staticTexts[markdownText].waitForExistence(timeout: 2))

#if targetEnvironment(simulator) && (arch(i386) || arch(x86_64))
throw XCTSkip("PKCanvas view-related tests are currently skipped on Intel-based iOS simulators due to a metal bug on the simulator.")
#endif

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

XCTAssert(staticTexts["Last Name"].exists)
XCTAssert(staticTexts["Last Name"].waitForExistence(timeout: 2))
try textFields["Enter your last name ..."].enter(value: "Stanford")

hitConsentButton()
Expand All @@ -85,10 +85,10 @@ extension XCUIApplication {
XCTAssertTrue(buttons["Undo"].isEnabled)
buttons["Undo"].tap()

XCTAssert(scrollViews["Signature Field"].exists)
XCTAssert(scrollViews["Signature Field"].waitForExistence(timeout: 2))
scrollViews["Signature Field"].swipeRight()
#else
XCTAssert(textFields["Signature Field"].exists)
XCTAssert(textFields["Signature Field"].waitForExistence(timeout: 2))
try textFields["Signature Field"].enter(value: "Leland Stanford")
#endif

Expand Down

0 comments on commit ef0827f

Please # to comment.