2022-07-04 10:00:27 +01:00
|
|
|
//
|
2024-09-06 16:34:30 +03:00
|
|
|
// Copyright 2022-2024 New Vector Ltd.
|
2022-07-04 10:00:27 +01:00
|
|
|
//
|
2025-01-06 11:27:37 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
// Please see LICENSE files in the repository root for full details.
|
2022-07-04 10:00:27 +01:00
|
|
|
//
|
|
|
|
|
2022-07-06 14:49:05 +01:00
|
|
|
import XCTest
|
2022-07-04 10:00:27 +01:00
|
|
|
|
|
|
|
@MainActor
|
|
|
|
class ServerSelectionUITests: XCTestCase {
|
2023-05-15 15:42:40 +02:00
|
|
|
func testNormalState() async throws {
|
2022-07-04 10:00:27 +01:00
|
|
|
// Given the initial server selection screen as a modal.
|
2023-02-14 16:25:24 +00:00
|
|
|
let app = Application.launch(.serverSelection)
|
2022-07-04 10:00:27 +01:00
|
|
|
|
2023-02-08 14:11:09 +00:00
|
|
|
// Then it should be configured for matrix.org
|
2025-03-04 17:17:52 +02:00
|
|
|
try await app.assertScreenshot()
|
2022-07-04 10:00:27 +01:00
|
|
|
}
|
|
|
|
|
2023-05-15 15:42:40 +02:00
|
|
|
func testEmptyAddress() async throws {
|
2022-07-04 10:00:27 +01:00
|
|
|
// Given the initial server selection screen as a modal.
|
2023-02-14 16:25:24 +00:00
|
|
|
let app = Application.launch(.serverSelection)
|
2022-07-04 10:00:27 +01:00
|
|
|
|
|
|
|
// When clearing the server address text field.
|
2023-02-15 05:53:04 +00:00
|
|
|
app.textFields[A11yIdentifiers.changeServerScreen.server].tap()
|
|
|
|
app.textFields[A11yIdentifiers.changeServerScreen.server].buttons.element.tap()
|
2022-07-04 10:00:27 +01:00
|
|
|
|
|
|
|
// Then the screen should not allow the user to continue.
|
2025-03-04 17:17:52 +02:00
|
|
|
try await app.assertScreenshot()
|
2022-07-04 10:00:27 +01:00
|
|
|
}
|
|
|
|
|
2023-05-15 15:42:40 +02:00
|
|
|
func testInvalidAddress() async throws {
|
2022-07-04 10:00:27 +01:00
|
|
|
// Given the initial server selection screen as a modal.
|
2023-02-14 16:25:24 +00:00
|
|
|
let app = Application.launch(.serverSelection)
|
2022-07-04 10:00:27 +01:00
|
|
|
|
|
|
|
// When typing in an invalid homeserver
|
2024-10-10 08:38:40 +01:00
|
|
|
app.textFields[A11yIdentifiers.changeServerScreen.server].clearAndTypeText("thisisbad\n", app: app) // The tests only accept an address from LoginHomeserver.mockXYZ
|
2022-07-04 10:00:27 +01:00
|
|
|
|
|
|
|
// Then an error should be shown and the confirmation button disabled.
|
2025-03-04 17:17:52 +02:00
|
|
|
try await app.assertScreenshot()
|
2023-05-30 16:51:00 +01:00
|
|
|
XCTAssertFalse(app.buttons[A11yIdentifiers.changeServerScreen.continue].isEnabled, "The continue button should be disabled when there is an error.")
|
2022-07-04 10:00:27 +01:00
|
|
|
}
|
|
|
|
}
|