mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Configure the AuthenticationService later now that we have 2 flows on the start screen. (#3316)
* Don't query the homeserver until confirming it (or selecting a different one). * Setup the infrastructure to test AuthenticationService. Implement basic tests for configuration & password login. * Use the real AuthenticationService with a mock Client in all of the tests. * Add tests for the ServerConfirmationScreenViewModel. * Remove redundant view state and test for it.
This commit is contained in:
@@ -19,6 +19,10 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
|
||||
// Server Confirmation: Tap continue button
|
||||
app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap()
|
||||
|
||||
// Login Screen: Wait for continue button to appear
|
||||
let continueButton = app.buttons[A11yIdentifiers.loginScreen.continue]
|
||||
XCTAssertTrue(continueButton.waitForExistence(timeout: 2.0))
|
||||
|
||||
// Login Screen: Enter valid credentials
|
||||
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("alice\n")
|
||||
app.secureTextFields[A11yIdentifiers.loginScreen.password].clearAndTypeText("12345678")
|
||||
@@ -39,20 +43,43 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
|
||||
// Server Confirmation: Tap continue button
|
||||
app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap()
|
||||
|
||||
// Login Screen: Wait for continue button to appear
|
||||
let continueButton = app.buttons[A11yIdentifiers.loginScreen.continue]
|
||||
XCTAssertTrue(continueButton.waitForExistence(timeout: 2.0))
|
||||
|
||||
// Login Screen: Enter invalid credentials
|
||||
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("alice")
|
||||
app.secureTextFields[A11yIdentifiers.loginScreen.password].clearAndTypeText("87654321")
|
||||
|
||||
// Login Screen: Tap next
|
||||
let nextButton = app.buttons[A11yIdentifiers.loginScreen.continue]
|
||||
XCTAssertTrue(nextButton.waitForExistence(timeout: 2.0))
|
||||
XCTAssertTrue(nextButton.isEnabled)
|
||||
nextButton.tap()
|
||||
// Login Screen: Tap continue
|
||||
XCTAssertTrue(continueButton.isEnabled)
|
||||
continueButton.tap()
|
||||
|
||||
// Then login should fail.
|
||||
XCTAssertTrue(app.alerts.element.waitForExistence(timeout: 2.0), "An error alert should be shown when attempting login with invalid credentials.")
|
||||
}
|
||||
|
||||
func testLoginWithUnsupportedUserID() async throws {
|
||||
// Given the authentication flow.
|
||||
let app = Application.launch(.authenticationFlow)
|
||||
|
||||
// Splash Screen: Tap get started button
|
||||
app.buttons[A11yIdentifiers.authenticationStartScreen.signIn].tap()
|
||||
|
||||
// Server Confirmation: Tap continue button
|
||||
app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap()
|
||||
|
||||
// Login Screen: Wait for continue button to appear
|
||||
let continueButton = app.buttons[A11yIdentifiers.loginScreen.continue]
|
||||
XCTAssertTrue(continueButton.waitForExistence(timeout: 2.0))
|
||||
|
||||
// When entering a username on a homeserver with an unsupported flow.
|
||||
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("@test:server.net\n")
|
||||
|
||||
// Then the screen should not allow login to continue.
|
||||
try await app.assertScreenshot(.authenticationFlow, step: 1)
|
||||
}
|
||||
|
||||
func testSelectingOIDCServer() {
|
||||
// Given the authentication flow.
|
||||
let app = Application.launch(.authenticationFlow)
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// Copyright 2022-2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Please see LICENSE in the repository root for full details.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class LoginScreenUITests: XCTestCase {
|
||||
func testMatrixDotOrg() async throws {
|
||||
// Given the initial login screen which defaults to matrix.org.
|
||||
let app = Application.launch(.login)
|
||||
try await app.assertScreenshot(.login)
|
||||
|
||||
// When typing in a username and password.
|
||||
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("@test:matrix.org")
|
||||
app.secureTextFields[A11yIdentifiers.loginScreen.password].clearAndTypeText("12345678")
|
||||
|
||||
// Then the form should be ready to submit.
|
||||
try await app.assertScreenshot(.login, step: 0)
|
||||
}
|
||||
|
||||
func testUnsupported() async throws {
|
||||
// Given the initial login screen.
|
||||
let app = Application.launch(.login)
|
||||
|
||||
// When entering a username on a homeserver with an unsupported flow.
|
||||
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("@test:server.net\n")
|
||||
|
||||
// Then the screen should not allow login to continue.
|
||||
try await app.assertScreenshot(.login, step: 1)
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9b059e871878224c54b4b69d59f95394cf73c5d86e0f83ea030808efb9b48767
|
||||
size 88666
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:58bcbecf677ba5b1ce9fc86a541e1df0389464677b882d34903be09512c65f46
|
||||
size 94767
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bbe00c86de31bcf15f2c80631a11ea4ff89a4b6d220209f18c11499750472e44
|
||||
size 86311
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ac640dca1b9e754b7ecdb958568473270838728f7dcf2d6a638b3495541f4420
|
||||
size 89495
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4f14c2216af345d3f620642f344f60fc79e877e78e651b33e20c3ebc0e8ef752
|
||||
size 85957
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b22d205a8a1f5d5889271a7fa93678112bebc8c8e73e21eaa8722d1e98bd427e
|
||||
size 89727
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:58e3224bd82abb9548d042e02a081ca5a73fd4685c2769d46f39d14da5769ace
|
||||
size 84034
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c626719a64e6f68e087f616f43ab6890a2c0be081c66b0bc51f6b308e1849197
|
||||
size 86066
|
||||
Reference in New Issue
Block a user