mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Various UI test fixes (#370)
* Increase integration tests time limits again as they're still ocasionally failing * Fixed NavigationRootCoordinator name in logs * Refactor UI tests hierarchy and introduce new userFlowScreen * Introduce a RoomTimelineControllerFactory so that it can be mocked in the UserFlow UI tests * Start using a mock timeline controller for the UserSession flows * Remove the WeakDictionary dependency and replce it with a plain NSMapTable in the BackgroundTaskService * Allow multiple UITests screenshots per screen * Prevent the view hierarchy changing when taking screenshots * Add UserSessionScreen UI tests * Fix label triaging workflow project identifier as per vector-im/element-ios/pull/7150 * Fix settings screen tests * Fix roomPlainNoAvatar and roomEncryptedWithAvatar UI tests * Fix modal server selection screen UI tests * Fix bug report and login screen UI tests * Fix text typing missing characters on UI tests * Fix sliding sync configuration on integration tests * Stop crashing if not finding a particular room through the MockClientProxy
This commit is contained in:
@@ -41,10 +41,15 @@ extension XCUIApplication {
|
||||
|
||||
/// Assert screenshot for a screen with the given identifier. Does not fail if a screenshot is newly created.
|
||||
/// - Parameter identifier: Identifier of the UI test screen
|
||||
func assertScreenshot(_ identifier: UITestScreenIdentifier) {
|
||||
let failure = verifySnapshot(matching: screenshot().image,
|
||||
func assertScreenshot(_ identifier: UITestScreenIdentifier, step: Int? = nil) {
|
||||
var snapshotName = identifier.rawValue
|
||||
if let step {
|
||||
snapshotName += "-\(step)"
|
||||
}
|
||||
|
||||
let failure = verifySnapshot(matching: XCUIScreen.main.screenshot().image,
|
||||
as: .image(precision: 0.99, perceptualPrecision: 0.98, scale: nil),
|
||||
named: identifier.rawValue,
|
||||
named: snapshotName,
|
||||
testName: testName)
|
||||
|
||||
if let failure,
|
||||
|
||||
@@ -29,10 +29,9 @@ class AuthenticationCoordinatorUITests: XCTestCase {
|
||||
app.buttons["getStartedButton"].tap()
|
||||
|
||||
// Login Screen: Enter valid credentials
|
||||
app.textFields["usernameTextField"].tap()
|
||||
app.typeText("alice\n")
|
||||
app.secureTextFields["passwordTextField"].tap()
|
||||
app.typeText("12345678")
|
||||
|
||||
app.textFields["usernameTextField"].clearAndTypeText("alice\n")
|
||||
app.secureTextFields["passwordTextField"].clearAndTypeText("12345678")
|
||||
|
||||
app.assertScreenshot(.authenticationFlow)
|
||||
|
||||
@@ -52,10 +51,8 @@ class AuthenticationCoordinatorUITests: XCTestCase {
|
||||
app.buttons["getStartedButton"].tap()
|
||||
|
||||
// Login Screen: Enter invalid credentials
|
||||
app.textFields["usernameTextField"].tap()
|
||||
app.typeText("alice")
|
||||
app.secureTextFields["passwordTextField"].tap()
|
||||
app.typeText("87654321")
|
||||
app.textFields["usernameTextField"].clearAndTypeText("alice")
|
||||
app.secureTextFields["passwordTextField"].clearAndTypeText("87654321")
|
||||
|
||||
// Login Screen: Tap next
|
||||
let nextButton = app.buttons["nextButton"]
|
||||
@@ -80,9 +77,7 @@ class AuthenticationCoordinatorUITests: XCTestCase {
|
||||
app.buttons["editServerButton"].tap()
|
||||
|
||||
// Server Selection: Clear the default and enter OIDC server.
|
||||
app.textFields["addressTextField"].tap()
|
||||
app.textFields["addressTextField"].buttons.element.tap()
|
||||
app.typeText("company.com")
|
||||
app.textFields["addressTextField"].clearAndTypeText("company.com")
|
||||
|
||||
// Dismiss server screen.
|
||||
app.buttons["confirmButton"].tap()
|
||||
|
||||
@@ -46,13 +46,11 @@ class BugReportUITests: XCTestCase {
|
||||
app.goToScreenWithIdentifier(.bugReport)
|
||||
|
||||
// type 4 chars
|
||||
app.textViews["reportTextView"].tap()
|
||||
app.textViews["reportTextView"].typeText("Test")
|
||||
app.textViews["reportTextView"].clearAndTypeText("Text")
|
||||
XCTAssertFalse(app.buttons["sendButton"].isEnabled)
|
||||
|
||||
// type one more char and see the button enabled
|
||||
app.textViews["reportTextView"].tap()
|
||||
app.textViews["reportTextView"].typeText("-")
|
||||
app.textViews["reportTextView"].clearAndTypeText("Longer text")
|
||||
XCTAssert(app.buttons["sendButton"].isEnabled)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,9 @@ class LoginScreenUITests: XCTestCase {
|
||||
app.assertScreenshot(.login)
|
||||
|
||||
// When typing in a username and password.
|
||||
app.textFields.element.tap()
|
||||
app.typeText("@test:matrix.org")
|
||||
app.textFields.element.clearAndTypeText("@test:matrix.org")
|
||||
|
||||
app.secureTextFields.element.tap()
|
||||
app.typeText("12345678")
|
||||
app.secureTextFields.element.clearAndTypeText("12345678")
|
||||
|
||||
// Then the form should be ready to submit.
|
||||
validateNextButtonIsEnabled(for: "matrix.org with credentials entered")
|
||||
@@ -56,8 +54,7 @@ class LoginScreenUITests: XCTestCase {
|
||||
app.goToScreenWithIdentifier(.login)
|
||||
|
||||
// When entering a username on a homeserver that only supports OIDC.
|
||||
app.textFields.element.tap()
|
||||
app.typeText("@test:company.com\n")
|
||||
app.textFields.element.clearAndTypeText("@test:company.com\n")
|
||||
|
||||
// Then the screen should be configured for OIDC.
|
||||
let state = "an OIDC only server"
|
||||
@@ -72,8 +69,7 @@ class LoginScreenUITests: XCTestCase {
|
||||
app.goToScreenWithIdentifier(.login)
|
||||
|
||||
// When entering a username on a homeserver with an unsupported flow.
|
||||
app.textFields.element.tap()
|
||||
app.typeText("@test:server.net\n")
|
||||
app.textFields.element.clearAndTypeText("@test:server.net\n")
|
||||
|
||||
// Then the screen should not allow login to continue.
|
||||
let state = "an unsupported server"
|
||||
|
||||
@@ -66,9 +66,7 @@ class ServerSelectionUITests: XCTestCase {
|
||||
app.goToScreenWithIdentifier(.serverSelection)
|
||||
|
||||
// When typing in an invalid homeserver
|
||||
app.textFields[textFieldIdentifier].tap()
|
||||
app.textFields.element.buttons.element.tap()
|
||||
app.typeText("thisisbad\n") // The tests only accept an address from LoginHomeserver.mockXYZ
|
||||
app.textFields[textFieldIdentifier].clearAndTypeText("thisisbad\n") // The tests only accept an address from LoginHomeserver.mockXYZ
|
||||
|
||||
// Then an error should be shown and the confirmation button disabled.
|
||||
XCTAssertEqual(app.textFields[textFieldIdentifier].value as? String, "thisisbad", "The text field should show the entered server.")
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import ElementX
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class UserSessionScreenTests: XCTestCase {
|
||||
func testUserSessionFlows() async throws {
|
||||
let roomName = "First room"
|
||||
|
||||
let app = Application.launch()
|
||||
app.goToScreenWithIdentifier(.userSessionScreen)
|
||||
|
||||
app.assertScreenshot(.userSessionScreen, step: 1)
|
||||
|
||||
app.buttons["roomName:\(roomName)"].tap()
|
||||
|
||||
XCTAssert(app.staticTexts[roomName].exists)
|
||||
|
||||
try await Task.sleep(for: .seconds(1))
|
||||
|
||||
app.assertScreenshot(.userSessionScreen, step: 2)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6b5fb88d76d9d6b0c2ab6f9f96d80cac1cb41cfa7e938b2cf9746553c7ef55fc
|
||||
size 208681
|
||||
oid sha256:9902bf55f027c729fd31b790d875699bf4a2e0f2852b9ceb2178c84bc8aca226
|
||||
size 211684
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ce6df94c886ae302976ab1748fc000fdaf535a8178b5415f9e44f87f2c5677a7
|
||||
size 208028
|
||||
oid sha256:1fbf57e59072a7e06026a69a0858ed9f65a72e0bfa4fabdf4de6a28e1bc4b364
|
||||
size 211052
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9c957491840909920efbb8b445cecb039e0cfe50127918bace68d34bcf1b0501
|
||||
size 101235
|
||||
oid sha256:27d058762e6eafc940c71b8e4edeef26f6ccad34e086ad6a0f0a30252848485f
|
||||
size 93290
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d90a2dd77853c9707a2805b480983dc46d92d1606e22a61ff18ad12a0cb70228
|
||||
size 123022
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:89c5cd9ca5283ec107581a2e45b3f904fad92119848eb9bd7d8c3c7295802a75
|
||||
size 334531
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0305582dd212396d3443d10e675a5e2dcb9e964e6543acb0033d4f58e3c66be6
|
||||
size 296035
|
||||
oid sha256:dd603c2e38d5281190788cfa06425a512587fbb49a32d5d895361533ab48419a
|
||||
size 373824
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5beeaa7dea7a8d7cc8e6acb8928dd2b72fda9caa8a03e79d230e8a31392be58c
|
||||
size 295025
|
||||
oid sha256:066c66947a2d47092dde8db56d885cd62127f24a817a06198e2ab0d29fa61857
|
||||
size 371508
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ed05c76fb48fb1440ae419caed6833c3d25858513b85417d19921cac444cc781
|
||||
size 125722
|
||||
oid sha256:97980472cdf36a0d07109fc066bd8184013b0a99cbbd164e82dbfb0a20cbc09f
|
||||
size 115670
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3de2e5153d1b685c253df7f20d91a5355015fae183f4882315c56fe4eede0889
|
||||
size 112151
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6aaa8bf274c693ca1fd3dffd4fbeab41df2698e401bb1c16f9bd6190d694a0df
|
||||
size 334188
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ba9218275999d949200c620d5019bb03e99935081a70c6e7151217b1787e9ccb
|
||||
size 207960
|
||||
oid sha256:0a34acc9936b4fbff9aad17617ee77dd8c89356d652b2a7132f5bb7d20c4f715
|
||||
size 210981
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:82b057602fc6b76294eed9232a9fa9f5b9f8348bff50ba5cdd05a9299674b1dc
|
||||
size 207307
|
||||
oid sha256:ec8c0bdbf78d2bd1019cd8319aed419fd729be3d8be566b729d171cc21adec8b
|
||||
size 210340
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a5bafccc43ded94082a5182afe1af60e3a17f0d943ac981c704f313914eaa640
|
||||
size 101898
|
||||
oid sha256:cbbb771047c24948ad5b38308273fc1262667bdaafcf0bac61704b3186f66f1d
|
||||
size 93992
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:25ba24b61f830ca4a975957059dd912f587a06436e9bc1899a01bec845e4125c
|
||||
size 123049
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:df9c30fd83057e62b3ac28d820bae1ad17e520270e21ef1a4c1429a181877ee4
|
||||
size 334367
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:74b59a7a3f639eefa579333d77e301c4fb417889846b82c828242bcb87822ecc
|
||||
size 295099
|
||||
oid sha256:f7322585bdb968fa0ad5244e5ca05401e7b32e3c27a0e3b1abb4f74f2cc736f9
|
||||
size 372873
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ade4638eba012fdae7d0b60dd92b634a2dce225f4e24d52e53abf7617838a9ef
|
||||
size 294155
|
||||
oid sha256:bf8edaf502cb0a8ea89699280a31ef2a8505b2107fb67d81975b9a63813bdd2e
|
||||
size 370584
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4fdad77450c1fdf345f2c8f94fd36148f984819bb5e99f0079e72d9efaa03e34
|
||||
size 125447
|
||||
oid sha256:063feeb819831472533b47c11eb8a69924843fea616ef3f56651274fd8f970c9
|
||||
size 115397
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7b31c6c701af4e18f3bee3e28ce2d43044934f9a16dfb8726dadc233a616a27e
|
||||
size 112187
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d340ed581bb489d166f6d358cde52fd1a5c735faba60fb921bc71fc68489ef3d
|
||||
size 334229
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:df627a68a56f879f53298d8af24e6c66cf8cbf77745c94a50e365fce7f1f8922
|
||||
size 208173
|
||||
oid sha256:aa4dc34fbb2b7412232fb048d1ddde465f949784bc4e9af0374d7cae490a5dd3
|
||||
size 211181
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:58ac026654258e9713f5f5877f35de33e117c54405ec40aa90c4328414eeac79
|
||||
size 207519
|
||||
oid sha256:ca335bfdc0d02a56eb7584e9f18004361abcb0365c30733861bbd20b7a385b3b
|
||||
size 210546
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c20831ac18ee32022faf98abe3866d67581a3b466ed9eb7ceaa20bff6dfc9ec5
|
||||
size 102302
|
||||
oid sha256:df1a88376fa6e083729329fcf221093c4704d900de8acc40600a61b7fd812a2c
|
||||
size 94430
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a1713e05e0292fcd03384f297d171fe9f7494c4ca7d82c65bff68c490a5cf398
|
||||
size 124142
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:48524ce3e3adfbb8cf6db5d24af0ab50a188daf015cbab033fcecc6eeafd8439
|
||||
size 335408
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6170f6628637496185cd3d89509735bd91ecc9a00e6e9e449e79d4f09f19fc96
|
||||
size 295475
|
||||
oid sha256:794a4b78bd5e5cda370bfac8168d19951ef5005c5d9267d372b9b55c9accfa4b
|
||||
size 373232
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e4da4a01c13823486548c8e24926e7cae5f3e779597c39aaaddd57393c743c7a
|
||||
size 294447
|
||||
oid sha256:39a5f3d31a13112058a4b4c3d0b83066ff1e3a546b65e82234970b76748812ed
|
||||
size 370940
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b643263191776badaf326c825ed53af855836443b9ec9dbede5e9ee6063bafac
|
||||
size 127431
|
||||
oid sha256:d4b3f25e56c50b01e3ce87c4bd0537e752664e23b7b761a5bdb1e2b88ed4dc35
|
||||
size 117371
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dfbeb2402f34533a88a49185d5642188fe38821a090e6e34ad550b413b5fa912
|
||||
size 116841
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:04ab9dbb2bb167bbe6d4b8a6c9c392477b8b387f79313f0a9ecdc099ef7c0f97
|
||||
size 339899
|
||||
@@ -68,3 +68,4 @@ targets:
|
||||
- path: ../../ElementX/Sources/Other/Extensions/FileManager.swift
|
||||
- path: ../../ElementX/Sources/Other/InfoPlistReader.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/URL.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/XCUIElement.swift
|
||||
|
||||
Reference in New Issue
Block a user