Files
letro-ios/UITests/Sources/LinkNewDeviceTests.swift
Doug 15eae621b2 Add tests for linking a new device. (#4934)
* Replace GrantLoginWithQrCodeHandlerSDKMock with LinkNewDeviceServiceMock.

Add tests for all initial states on the QRCodeLoginScreen.

* Add tests for linking both mobile and desktop devices.

* Add UI tests for linking a new device.

* Don't show the Link Desktop Computer button when running on macOS.

This mirrors the decision to hide the Sign In With QR Code button on the start screen.
2026-01-09 13:10:14 +00:00

49 lines
1.6 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import XCTest
@MainActor
class LinkNewDeviceTests: XCTestCase {
enum Step {
static let selectDevice = 1
static let linkMobileDevice = 2
static let linkDesktopComputer = 3
static let dismissed = 99
}
func testFlow() async throws {
// Root screen
let app = Application.launch(.linkNewDevice)
try await app.assertScreenshot(step: Step.selectDevice)
// Link showing a QR code
let mobileDeviceButton = app.buttons[A11yIdentifiers.linkNewDeviceScreen.mobileDevice]
mobileDeviceButton.tap()
try await app.assertScreenshot(step: Step.linkMobileDevice)
// Pop back to the root screen
let backButton = app.buttons["Link new device"]
backButton.tap()
try await app.assertScreenshot(step: Step.selectDevice)
// Link scanning a QR code
let desktopComputerButton = app.buttons[A11yIdentifiers.linkNewDeviceScreen.desktopComputer]
desktopComputerButton.tap()
try await app.assertScreenshot(step: Step.linkDesktopComputer)
// Pop back to the root screen
backButton.tap()
try await app.assertScreenshot(step: Step.selectDevice)
// Dismiss the flow
let cancelButton = app.buttons[A11yIdentifiers.linkNewDeviceScreen.cancel]
cancelButton.tap()
try await app.assertScreenshot(step: Step.dismissed)
}
}