Fix UI tests (#950)

* Fixed unstored weak reference warning

* Prevent the timeline from jumping whenever we access XCUIApplication properties

* Prevent UI tests from causing side effects on the timeline

* Update userSession reference screenshots

* Fix create room UI tests

* Update inviteUsers UI test reference screenshots

* Allow certain tests to enable timeline accessibility

* Fix roomLayout tests and update reference screenshots

* Disable the testTimelineLayoutInMiddle test because of flakiness

* Update screenshots following timestamp addition

* Another attempt

* Yet another attempt, replace XCUIScreen screenshots with XCUIApplication ones, decrease delay to 1 second

* Allow tests to retry up to 3 times before failing the run
This commit is contained in:
Stefan Ceriu
2023-05-26 17:43:38 +03:00
committed by GitHub
parent 142a8d6275
commit a1fdfd068a
79 changed files with 241 additions and 245 deletions
+12 -7
View File
@@ -18,12 +18,18 @@ import SnapshotTesting
import XCTest
struct Application {
static func launch(_ identifier: UITestsScreenIdentifier) -> XCUIApplication {
static func launch(_ identifier: UITestsScreenIdentifier, disableTimelineAccessibility: Bool = true) -> XCUIApplication {
let app = XCUIApplication()
app.launchEnvironment = [
var launchEnvironment = [
"UI_TESTS_SCREEN": identifier.rawValue
]
if disableTimelineAccessibility {
launchEnvironment["UI_TESTS_DISABLE_TIMELINE_ACCESSIBILITY"] = "1"
}
app.launchEnvironment = launchEnvironment
app.launch()
return app
}
@@ -35,17 +41,16 @@ extension XCUIApplication {
/// - Parameter identifier: Identifier of the UI test screen
/// - Parameter step: An optional integer that can be used to take multiple snapshots per test identifier.
/// - Parameter insets: Optional insets with which to crop the image by.
func assertScreenshot(_ identifier: UITestsScreenIdentifier, step: Int? = nil, insets: UIEdgeInsets? = nil, delayInMilliseconds: UInt = 2000, precision: Float = 0.99) async throws {
func assertScreenshot(_ identifier: UITestsScreenIdentifier, step: Int? = nil, insets: UIEdgeInsets? = nil, delay: Duration = .seconds(1), precision: Float = 0.99) async throws {
var snapshotName = identifier.rawValue
if let step {
snapshotName += "-\(step)"
}
// Sometimes the CI might be too slow to load the content so let's wait the delay time
if delayInMilliseconds > 0 {
try await Task.sleep(for: .milliseconds(delayInMilliseconds))
}
var snapshot = XCUIScreen.main.screenshot().image
try await Task.sleep(for: delay)
var snapshot = screenshot().image
if let insets {
snapshot = snapshot.inset(by: insets)