Skip to content

Commit

Permalink
Fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple committed Oct 17, 2023
1 parent 05da584 commit ee5bf93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 0 additions & 1 deletion SwiftUIDemoAppUITests/Tests/DeeplinkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ final class DeeplinkTests: StreamTestCase {
WHEN("user navigates to the app through deeplink") {
Safari()
.open(MockDeeplink.production)
.alertHandler()
.tapOnOpenButton()
}
THEN("user joins the the specified call") {
Expand Down
30 changes: 19 additions & 11 deletions TestTools/UITests/Safari.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ struct Safari {
func open(_ url: URL) -> Self {
safari.launch()
_ = safari.wait(for: .runningForeground, timeout: 5)

// Type the deeplink and execute it
let firstLaunchContinueButton = safari.buttons["Continue"]
if firstLaunchContinueButton.exists {
firstLaunchContinueButton.tap()
}
if #available(iOS 16.4, *) {
safari.open(url)
return self
} else {
// Type the deeplink and execute it
let firstLaunchContinueButton = safari.buttons["Continue"]
if firstLaunchContinueButton.exists {
firstLaunchContinueButton.tap()
}

return go(to: url)
return go(to: url)
}
}

@discardableResult
Expand All @@ -49,14 +53,18 @@ struct Safari {
}

@discardableResult
func tapOnOpenButton(_ timeout: TimeInterval = 5) -> Self {
func tapOnOpenButton() -> Self {
let openButton = safari.buttons.matching(NSPredicate(format: "label LIKE 'OPEN' OR label LIKE 'Open'")).firstMatch

let reloadButton = safari.buttons["ReloadButton"]
var counter = 0
while !openButton.wait(timeout: timeout).exists || counter < 5 {
safari.buttons["ReloadButton"].tap()

while !openButton.exists && counter < 5 {
reloadButton.wait().tap()
reloadButton.wait()
alertHandler()
counter += 1
}
XCTAssertTrue(openButton.exists, "Open button does not exist")

openButton.tap()
return self
Expand Down

0 comments on commit ee5bf93

Please sign in to comment.