Skip to content

Commit

Permalink
Ask the iPad to reveal the keyboard when it's hidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Oct 9, 2024
1 parent 5c2b107 commit 6e6be5b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
7 changes: 6 additions & 1 deletion ElementX/Sources/Other/Extensions/XCUIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import XCTest

extension XCUIElement {
func clearAndTypeText(_ text: String) {
func clearAndTypeText(_ text: String, app: XCUIApplication) {
if UIDevice.current.userInterfaceIdiom == .pad, app.keyboards.count == 0 {
app.buttons["Keyboard"].tap()
app.buttons["Show Keyboard"].tap()
}

tapCenter()

guard let currentValue = value as? String else {
Expand Down
4 changes: 2 additions & 2 deletions UITests/Sources/AppLockSetupUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ class AppLockSetupUITests: XCTestCase {
let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField]
XCTAssert(textField.waitForExistence(timeout: 10))

textField.clearAndTypeText("2023")
textField.clearAndTypeText("2023", app: app)
}

private func enterDifferentPIN() {
let textField = app.secureTextFields[A11yIdentifiers.appLockSetupPINScreen.textField]
XCTAssert(textField.waitForExistence(timeout: 10))

textField.clearAndTypeText("2233")
textField.clearAndTypeText("2233", app: app)
}
}
12 changes: 6 additions & 6 deletions UITests/Sources/AuthenticationFlowCoordinatorUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
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")
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("alice\n", app: app)
app.secureTextFields[A11yIdentifiers.loginScreen.password].clearAndTypeText("12345678", app: app)

try await app.assertScreenshot(.authenticationFlow)

Expand All @@ -48,8 +48,8 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
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")
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("alice", app: app)
app.secureTextFields[A11yIdentifiers.loginScreen.password].clearAndTypeText("87654321", app: app)

// Login Screen: Tap continue
XCTAssertTrue(continueButton.isEnabled)
Expand All @@ -74,7 +74,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
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")
app.textFields[A11yIdentifiers.loginScreen.emailUsername].clearAndTypeText("@test:server.net\n", app: app)

// Then the screen should not allow login to continue.
try await app.assertScreenshot(.authenticationFlow, step: 1)
Expand All @@ -91,7 +91,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
app.buttons[A11yIdentifiers.serverConfirmationScreen.changeServer].tap()

// Server Selection: Clear the default, enter OIDC server and continue.
app.textFields[A11yIdentifiers.changeServerScreen.server].clearAndTypeText("company.com\n")
app.textFields[A11yIdentifiers.changeServerScreen.server].clearAndTypeText("company.com\n", app: app)

// Server Confirmation: Tap continue button
app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap()
Expand Down
4 changes: 2 additions & 2 deletions UITests/Sources/BugReportUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class BugReportUITests: XCTestCase {
let app = Application.launch(.bugReport)

// Type 4 characters and the send button should be disabled.
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Text")
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Text", app: app)
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
XCTAssert(!app.switches[A11yIdentifiers.bugReportScreen.canContact].isOn)
try await app.assertScreenshot(.bugReport, step: 2)

// Type more than 4 characters and send the button should become enabled.
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Longer text")
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Longer text", app: app)
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
XCTAssert(!app.switches[A11yIdentifiers.bugReportScreen.canContact].isOn)
try await app.assertScreenshot(.bugReport, step: 3)
Expand Down
4 changes: 2 additions & 2 deletions UITests/Sources/RoomMembersListScreenUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RoomMembersListScreenUITests: XCTestCase {
let app = Application.launch(.roomMembersListScreenPendingInvites)

let searchBar = app.searchFields.firstMatch
searchBar.clearAndTypeText("alice\n")
searchBar.clearAndTypeText("alice\n", app: app)

try await app.assertScreenshot(.roomMembersListScreenPendingInvites, step: 1)
}
Expand All @@ -28,7 +28,7 @@ class RoomMembersListScreenUITests: XCTestCase {
let app = Application.launch(.roomMembersListScreenPendingInvites)

let searchBar = app.searchFields.firstMatch
searchBar.clearAndTypeText("bob\n")
searchBar.clearAndTypeText("bob\n", app: app)

try await app.assertScreenshot(.roomMembersListScreenPendingInvites, step: 2)
}
Expand Down
2 changes: 1 addition & 1 deletion UITests/Sources/ServerSelectionUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ServerSelectionUITests: XCTestCase {
let app = Application.launch(.serverSelection)

// When typing in an invalid homeserver
app.textFields[A11yIdentifiers.changeServerScreen.server].clearAndTypeText("thisisbad\n") // The tests only accept an address from LoginHomeserver.mockXYZ
app.textFields[A11yIdentifiers.changeServerScreen.server].clearAndTypeText("thisisbad\n", app: app) // The tests only accept an address from LoginHomeserver.mockXYZ

// Then an error should be shown and the confirmation button disabled.
try await app.assertScreenshot(.serverSelection, step: 2)
Expand Down
4 changes: 2 additions & 2 deletions UITests/Sources/StartChatScreenUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class StartChatScreenUITests: XCTestCase {
func testSearchWithNoResults() async throws {
let app = Application.launch(.startChat)
let searchField = app.searchFields.firstMatch
searchField.clearAndTypeText("None\n")
searchField.clearAndTypeText("None\n", app: app)
XCTAssert(app.staticTexts[A11yIdentifiers.startChatScreen.searchNoResults].waitForExistence(timeout: 1.0))
try await app.assertScreenshot(.startChat, step: 1)
}

func testSearchWithResults() async throws {
let app = Application.launch(.startChatWithSearchResults)
let searchField = app.searchFields.firstMatch
searchField.clearAndTypeText("Bob\n")
searchField.clearAndTypeText("Bob\n", app: app)
XCTAssertFalse(app.staticTexts[A11yIdentifiers.startChatScreen.searchNoResults].waitForExistence(timeout: 1.0))
XCTAssertEqual(app.collectionViews.firstMatch.cells.count, 2)
try await app.assertScreenshot(.startChat, step: 2)
Expand Down

0 comments on commit 6e6be5b

Please sign in to comment.