From 9f03fe3ca1a71df80667c49cda8da927964924b4 Mon Sep 17 00:00:00 2001 From: Maxim Dozhdev Date: Mon, 19 Oct 2026 18:04:39 +0200 Subject: [PATCH 1/2] test: wait for Trezor prompts to close and clear text fields reliably The lifecycle test opened each prompt right after cancelling the previous one, and SwiftUI drops a sheet presentation while another is dismissing, so the pairing sheet never appeared. The clear helper relied on a Select All menu that the simulator does not show, so it deleted one character and appended the new text to the prefilled message. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../TrezorBridgeDashboardUITests.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/BitkitUITests/TrezorBridgeDashboardUITests.swift b/BitkitUITests/TrezorBridgeDashboardUITests.swift index 062548bf0..c2c58b6f3 100644 --- a/BitkitUITests/TrezorBridgeDashboardUITests.swift +++ b/BitkitUITests/TrezorBridgeDashboardUITests.swift @@ -43,18 +43,22 @@ final class TrezorBridgeDashboardUITests: XCTestCase { app.buttons["TrezorTestHook-Pin"].tap() XCTAssertTrue(app.otherElements["TrezorPinSheet"].waitForExistence(timeout: 5)) app.buttons["TrezorPinCancel"].tap() + XCTAssertTrue(app.otherElements["TrezorPinSheet"].waitForNonExistence(timeout: 5)) app.buttons["TrezorTestHook-Passphrase"].tap() XCTAssertTrue(app.otherElements["TrezorPassphraseSheet"].waitForExistence(timeout: 5)) app.buttons["TrezorPassphraseCancel"].tap() + XCTAssertTrue(app.otherElements["TrezorPassphraseSheet"].waitForNonExistence(timeout: 5)) app.buttons["TrezorTestHook-Pairing"].tap() XCTAssertTrue(app.otherElements["TrezorPairingSheet"].waitForExistence(timeout: 5)) app.buttons["TrezorPairingCancel"].tap() + XCTAssertTrue(app.otherElements["TrezorPairingSheet"].waitForNonExistence(timeout: 5)) app.buttons["TrezorTestHook-Confirm"].tap() XCTAssertTrue(app.otherElements["TrezorConfirmOnDeviceOverlay"].waitForExistence(timeout: 5)) app.buttons["TrezorConfirmOnDeviceCancel"].tap() + XCTAssertTrue(app.otherElements["TrezorConfirmOnDeviceOverlay"].waitForNonExistence(timeout: 5)) app.buttons["TrezorDebugLogToggle"].tap() XCTAssertTrue(app.buttons["TrezorDebugLogClear"].waitForExistence(timeout: 5)) @@ -434,10 +438,9 @@ final class TrezorBridgeDashboardUITests: XCTestCase { XCTAssertTrue(element.waitForExistence(timeout: 10), "Missing text input \(element)") scrollTo(element) element.tap() - if let currentValue = element.value as? String, !currentValue.isEmpty { - element.press(forDuration: 1.0) - app.menuItems["Select All"].tapIfExists() - element.typeText(XCUIKeyboardKey.delete.rawValue) + if let currentValue = element.value as? String, !currentValue.isEmpty, currentValue != element.placeholderValue { + element.coordinate(withNormalizedOffset: CGVector(dx: 0.99, dy: 0.99)).tap() + element.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: currentValue.count)) } element.typeText(text) } @@ -587,11 +590,3 @@ private final class RegtestRpcClient { case rpc([String: Any]) } } - -private extension XCUIElement { - func tapIfExists() { - if waitForExistence(timeout: 2), isHittable { - tap() - } - } -} From afda99d51baf2a8b12635b66596ed45e63cf1b80 Mon Sep 17 00:00:00 2001 From: Maxim Dozhdev Date: Tue, 20 Oct 2026 11:15:04 +0200 Subject: [PATCH 2/2] test: dismiss the app-wide pairing sheet and keep focus when clearing Pairing prompts open the app-wide HwPairSheet, not the dashboard's own sheet, and it has no cancel button, so the test now swipes it away. The extra tap at the field's corner lost keyboard focus; the normal tap already leaves the cursor at the end of the text. Co-Authored-By: Claude Opus 5.5 (1M context) --- BitkitUITests/TrezorBridgeDashboardUITests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BitkitUITests/TrezorBridgeDashboardUITests.swift b/BitkitUITests/TrezorBridgeDashboardUITests.swift index c2c58b6f3..de12c9bd6 100644 --- a/BitkitUITests/TrezorBridgeDashboardUITests.swift +++ b/BitkitUITests/TrezorBridgeDashboardUITests.swift @@ -51,9 +51,10 @@ final class TrezorBridgeDashboardUITests: XCTestCase { XCTAssertTrue(app.otherElements["TrezorPassphraseSheet"].waitForNonExistence(timeout: 5)) app.buttons["TrezorTestHook-Pairing"].tap() - XCTAssertTrue(app.otherElements["TrezorPairingSheet"].waitForExistence(timeout: 5)) - app.buttons["TrezorPairingCancel"].tap() - XCTAssertTrue(app.otherElements["TrezorPairingSheet"].waitForNonExistence(timeout: 5)) + let pairingSheet = app.descendants(matching: .any)["HwPairSheet"] + XCTAssertTrue(pairingSheet.waitForExistence(timeout: 5)) + pairingSheet.swipeDown(velocity: .fast) + XCTAssertTrue(pairingSheet.waitForNonExistence(timeout: 5)) app.buttons["TrezorTestHook-Confirm"].tap() XCTAssertTrue(app.otherElements["TrezorConfirmOnDeviceOverlay"].waitForExistence(timeout: 5)) @@ -439,7 +440,6 @@ final class TrezorBridgeDashboardUITests: XCTestCase { scrollTo(element) element.tap() if let currentValue = element.value as? String, !currentValue.isEmpty, currentValue != element.placeholderValue { - element.coordinate(withNormalizedOffset: CGVector(dx: 0.99, dy: 0.99)).tap() element.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: currentValue.count)) } element.typeText(text)