#40: Add the login screen from EI.

- Remove SSO and replace fallback with OIDC.
This commit is contained in:
Doug
2022-06-28 12:23:35 +01:00
committed by GitHub
parent cc14f1f567
commit d74158ced1
35 changed files with 1316 additions and 394 deletions
+119 -5
View File
@@ -15,14 +15,128 @@
//
import XCTest
import ElementX
@MainActor
class LoginScreenUITests: XCTestCase {
func testInitialStateComponents() {
let app = Application.launch()
var app: XCUIApplication!
@MainActor
override func setUp() async throws {
app = nil
}
func testMatrixDotOrg() {
app = Application.launch()
app.goToScreenWithIdentifier(.login)
XCTAssert(app.buttons["Login"].exists)
XCTAssert(app.textFields["Username"].exists)
XCTAssert(app.secureTextFields["Password"].exists)
let state = "matrix.org"
validateServerDescriptionIsVisible(for: state)
validateLoginFormIsVisible(for: state)
validateOIDCButtonIsHidden(for: state)
validateNextButtonIsDisabled(for: state)
validateUnsupportedServerTextIsHidden(for: state)
app.textFields.element.tap()
app.typeText("@test:server.com")
app.secureTextFields.element.tap()
app.typeText("12345678")
validateNextButtonIsEnabled(for: "matrix.org with credentials entered")
}
func testOIDC() {
app = Application.launch()
app.goToScreenWithIdentifier(.loginOIDC)
let state = "an OIDC only server"
validateServerDescriptionIsHidden(for: state)
validateLoginFormIsHidden(for: state)
validateOIDCButtonIsShown(for: state)
validateUnsupportedServerTextIsHidden(for: state)
}
func testUnsupported() {
app = Application.launch()
app.goToScreenWithIdentifier(.loginUnsupported)
let state = "an unsupported server"
validateServerDescriptionIsHidden(for: state)
validateLoginFormIsHidden(for: state)
validateOIDCButtonIsHidden(for: state)
validateUnsupportedServerTextIsShown(for: state)
}
/// Checks that the server description label is shown.
func validateServerDescriptionIsVisible(for state: String) {
let descriptionLabel = app.staticTexts["serverDescriptionText"]
XCTAssertTrue(descriptionLabel.exists, "The server description should be shown for \(state).")
}
/// Checks that the server description label is hidden.
func validateServerDescriptionIsHidden(for state: String) {
let descriptionLabel = app.staticTexts["serverDescriptionText"]
XCTAssertFalse(descriptionLabel.exists, "The server description should be shown for \(state).")
}
/// Checks that the username and password text fields are shown along with the next button.
func validateLoginFormIsVisible(for state: String) {
let usernameTextField = app.textFields.element
let passwordTextField = app.secureTextFields.element
let nextButton = app.buttons["nextButton"]
XCTAssertTrue(usernameTextField.exists, "Username input should be shown for \(state).")
XCTAssertTrue(passwordTextField.exists, "Password input should be shown for \(state).")
XCTAssertTrue(nextButton.exists, "The next button should be shown for \(state).")
}
/// Checks that the username and password text fields are hidden along with the next button.
func validateLoginFormIsHidden(for state: String) {
let usernameTextField = app.textFields.element
let passwordTextField = app.secureTextFields.element
let nextButton = app.buttons["nextButton"]
XCTAssertFalse(usernameTextField.exists, "Username input should not be shown for \(state).")
XCTAssertFalse(passwordTextField.exists, "Password input should not be shown for \(state).")
XCTAssertFalse(nextButton.exists, "The next button should not be shown for \(state).")
}
/// Checks that the next button is shown but is disabled.
func validateNextButtonIsDisabled(for state: String) {
let nextButton = app.buttons["nextButton"]
XCTAssertTrue(nextButton.exists, "The next button should be shown.")
XCTAssertFalse(nextButton.isEnabled, "The next button should be disabled for \(state).")
}
/// Checks that the next button is shown and is enabled.
func validateNextButtonIsEnabled(for state: String) {
let nextButton = app.buttons["nextButton"]
XCTAssertTrue(nextButton.exists, "The next button should be shown.")
XCTAssertTrue(nextButton.isEnabled, "The next button should be enabled for \(state).")
}
/// Checks that the OIDC button is shown on the screen.
func validateOIDCButtonIsShown(for state: String) {
let oidcButton = app.buttons["oidcButton"]
XCTAssertTrue(oidcButton.exists, "The OIDC button should be shown for \(state).")
}
/// Checks that the OIDC button is not shown on the screen.
func validateOIDCButtonIsHidden(for state: String) {
let oidcButton = app.buttons["oidcButton"]
XCTAssertFalse(oidcButton.exists, "The OIDC button should be hidden for \(state).")
}
/// Checks that the unsupported homeserver text is shown on the screen.
func validateUnsupportedServerTextIsShown(for state: String) {
let unsupportedText = app.staticTexts["unsupportedServerText"]
XCTAssertTrue(unsupportedText.exists, "The unsupported homeserver text should be shown for \(state).")
}
/// Checks that the unsupported homeserver text is not shown on the screen.
func validateUnsupportedServerTextIsHidden(for state: String) {
let unsupportedText = app.staticTexts["unsupportedServerText"]
XCTAssertFalse(unsupportedText.exists, "The unsupported homeserver text should be hidden for \(state).")
}
}