diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2025-05-26 13:17:35 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-05-26 13:17:35 +0200 |
| commit | f409af9bec0eca58cabf6785c73068db2ea398b8 (patch) | |
| tree | d8013ab098e563566e14a42a7c426454eb966986 | |
| parent | d04feaaa714ca7430c2d783f1160ae328f6405e7 (diff) | |
| parent | e6a012ff740ffa2632d593025ed7d9443db89a48 (diff) | |
| download | mullvadvpn-f409af9bec0eca58cabf6785c73068db2ea398b8.tar.xz mullvadvpn-f409af9bec0eca58cabf6785c73068db2ea398b8.zip | |
Merge branch 'ios-e2e-login-timeout-fix'
| -rw-r--r-- | ios/MullvadVPNUITests/Pages/LoginPage.swift | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/ios/MullvadVPNUITests/Pages/LoginPage.swift b/ios/MullvadVPNUITests/Pages/LoginPage.swift index 9551eef3ee..24d1adcf2c 100644 --- a/ios/MullvadVPNUITests/Pages/LoginPage.swift +++ b/ios/MullvadVPNUITests/Pages/LoginPage.swift @@ -40,22 +40,9 @@ class LoginPage: Page { } @discardableResult public func verifySuccessIconShown() -> Self { - // Success icon is only shown very briefly, since another view is presented after success icon is shown. - // Therefore we need to poll faster than waitForElement function. - let successIconDisplayedExpectation = XCTestExpectation(description: "Success icon shown") - let timer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true) { [self] _ in - let statusImageView = self.app.images[.statusImageView] + let isShown = getSuccessIconShown() - if statusImageView.exists { - if statusImageView.value as? String == "success" { - successIconDisplayedExpectation.fulfill() - } - } - } - - let waitResult = XCTWaiter.wait(for: [successIconDisplayedExpectation], timeout: BaseUITestCase.longTimeout) - XCTAssertEqual(waitResult, .completed, "Success icon shown") - timer.invalidate() + XCTAssertTrue(isShown, "Success icon shown") return self } @@ -70,9 +57,24 @@ class LoginPage: Page { /// Checks whether success icon is being shown func getSuccessIconShown() -> Bool { - let predicate = NSPredicate(format: "identifier == 'statusImageView' AND value == 'success'") - let elementQuery = app.images.containing(predicate) - let elementExists = elementQuery.firstMatch.waitForExistence(timeout: BaseUITestCase.defaultTimeout) - return elementExists + // Success icon is only shown very briefly, since another view is presented after success icon is shown. + // Therefore we need to poll faster than waitForElement function. + let successIconDisplayedExpectation = XCTestExpectation(description: "Success icon shown") + var isShown = false + let timer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true) { [self] _ in + let statusImageView = self.app.images[.statusImageView] + + if statusImageView.exists { + if statusImageView.value as? String == "success" { + isShown = true + successIconDisplayedExpectation.fulfill() + } + } + } + + _ = XCTWaiter.wait(for: [successIconDisplayedExpectation], timeout: BaseUITestCase.longTimeout) + timer.invalidate() + + return isShown } } |
