Updated Screenshot Tests and fixed an issue with the MockMediaProvider (#554)

* updated the tests

* updated ui tests

* removed unused files

* fixed a bug that prevented the image to be added in the avatar of the rooms from the mock, and improved some UI tests

* swiftformat

* fixed an issue where the room Id was not matching the real room id coming from the timelineController, also updated some tests, and added a test for the case where the RoomAvatar is available.

* added some waitForExistence checks to allow the CI to find the UI elements

* this should make the loading bar always match at the HStack size

* code improvement for the tests

* fix for the max frame of the loading screen

* updated tests

* regenerated and improved some tests

* sonarcloud improvements

* changelog
This commit is contained in:
Mauro 2023-02-09 14:57:55 +01:00 committed by GitHub
parent a02b461c37
commit 910a8e2067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
137 changed files with 293 additions and 260 deletions

View File

@ -40,7 +40,8 @@ struct UserNotificationModalView: View {
}
}
.padding()
.frame(minWidth: 150.0, maxWidth: 250.0)
.frame(minWidth: 150.0)
.fixedSize(horizontal: true, vertical: false)
.background(Color.element.quinaryContent)
.clipShape(RoundedCornerShape(radius: 12.0, corners: .allCorners))
.shadow(color: .black.opacity(0.1), radius: 10.0, y: 4.0)

View File

@ -103,13 +103,13 @@ struct RoomDetailsScreen: View {
.background(Color.element.system)
.clipShape(RoundedCornerShape(radius: 8, corners: .allCorners))
.frame(width: menuIconSize, height: menuIconSize)
Text(ElementL10n.bottomActionPeople)
.foregroundColor(.element.primaryContent)
.font(.body)
Spacer()
if context.viewState.isLoadingMembers {
ProgressView()
} else {
@ -138,19 +138,19 @@ struct RoomDetailsScreen: View {
.background(Color.element.system)
.clipShape(RoundedCornerShape(radius: 8, corners: .allCorners))
.frame(width: menuIconSize, height: menuIconSize)
VStack(alignment: .leading, spacing: 2) {
Text(ElementL10n.encryptionEnabled)
.foregroundColor(.element.primaryContent)
.font(.element.body)
Text(ElementL10n.encryptionEnabledTileDescription)
.foregroundColor(.element.secondaryContent)
.font(.element.footnote)
}
Spacer()
Image(systemName: "checkmark")
.foregroundColor(.element.quaternaryContent)
}

View File

@ -119,7 +119,7 @@ class BugReportService: NSObject, BugReportServiceProtocol {
if let progressListener {
progressSubject
.receive(on: DispatchQueue.main)
.assign(to: \.value, on: progressListener.progressSubject)
.weakAssign(to: \.value, on: progressListener.progressSubject)
.store(in: &cancellables)
(data, _) = try await session.data(for: request, delegate: self)
} else {

View File

@ -19,7 +19,7 @@ import UIKit
struct MockMediaProvider: MediaProviderProtocol {
func imageFromSource(_ source: MediaSourceProxy?, size: CGSize?) -> UIImage? {
nil
imageFromURL(source?.url, size: size)
}
func loadImageFromSource(_ source: MediaSourceProxy, size: CGSize?) async -> Result<UIImage, MediaProviderError> {

View File

@ -19,7 +19,7 @@ import Foundation
import MatrixRustSDK
struct MockRoomProxy: RoomProxyProtocol {
let id = UUID().uuidString
var id = UUID().uuidString
let name: String? = nil
let displayName: String?
var topic: String?

View File

@ -41,6 +41,7 @@ enum UITestScreenIdentifier: String {
case sessionVerification
case userSessionScreen
case roomDetailsScreen
case roomDetailsScreenWithRoomAvatar
case roomMemberDetailsScreen
}

View File

@ -274,11 +274,24 @@ class MockScreen: Identifiable {
return navigationSplitCoordinator
case .roomDetailsScreen:
let navigationStackCoordinator = NavigationStackCoordinator()
let userNotificationController = UserNotificationController(rootCoordinator: navigationStackCoordinator)
let roomProxy = MockRoomProxy(id: "MockRoomIdentifier",
displayName: "Room",
isEncrypted: true,
members: [.mockAlice, .mockBob, .mockCharlie])
let coordinator = RoomDetailsCoordinator(parameters: .init(navigationStackCoordinator: navigationStackCoordinator,
roomProxy: MockRoomProxy(displayName: "Room",
isEncrypted: true,
members: [.mockAlice, .mockBob, .mockCharlie]),
roomProxy: roomProxy,
mediaProvider: MockMediaProvider()))
navigationStackCoordinator.setRootCoordinator(coordinator)
return navigationStackCoordinator
case .roomDetailsScreenWithRoomAvatar:
let navigationStackCoordinator = NavigationStackCoordinator()
let roomProxy = MockRoomProxy(id: "MockRoomIdentifier",
displayName: "Room",
avatarURL: URL.picturesDirectory,
isEncrypted: true,
members: [.mockAlice, .mockBob, .mockCharlie])
let coordinator = RoomDetailsCoordinator(parameters: .init(navigationStackCoordinator: navigationStackCoordinator,
roomProxy: roomProxy,
mediaProvider: MockMediaProvider()))
navigationStackCoordinator.setRootCoordinator(coordinator)
return navigationStackCoordinator

View File

@ -51,7 +51,9 @@ class LoginScreenUITests: XCTestCase {
app.goToScreenWithIdentifier(.login)
// When entering a username on a homeserver with an unsupported flow.
app.textFields["usernameTextField"].clearAndTypeText("@test:server.net\n")
let usernameTextField = app.textFields["usernameTextField"]
XCTAssertTrue(usernameTextField.waitForExistence(timeout: 5.0))
usernameTextField.clearAndTypeText("@test:server.net\n")
// Then the screen should not allow login to continue.
app.assertScreenshot(.login, step: 2)

View File

@ -22,6 +22,15 @@ class RoomDetailsScreenUITests: XCTestCase {
let app = Application.launch()
app.goToScreenWithIdentifier(.roomDetailsScreen)
XCTAssert(app.staticTexts["roomAvatarImage"].exists)
app.assertScreenshot(.roomDetailsScreen)
}
func testInitialStateComponentsWithRoomAvatar() {
let app = Application.launch()
app.goToScreenWithIdentifier(.roomDetailsScreenWithRoomAvatar)
XCTAssert(app.images["roomAvatarImage"].waitForExistence(timeout: 1))
app.assertScreenshot(.roomDetailsScreenWithRoomAvatar)
}
}

View File

@ -147,7 +147,7 @@ class RoomScreenUITests: XCTestCase {
app.goToScreenWithIdentifier(.roomLayoutBottom)
let connection = try await listener.connection()
try await Task.sleep(for: .seconds(1)) // Allow the connection to settle on CI/Intel...
try await Task.sleep(for: .seconds(2)) // Allow the connection to settle on CI/Intel...
defer { connection.disconnect() }
// When an incoming message arrives.

View File

@ -29,7 +29,7 @@ class UserSessionScreenTests: XCTestCase {
app.buttons["roomName:\(roomName)"].tap()
XCTAssert(app.staticTexts[roomName].exists)
XCTAssert(app.staticTexts[roomName].waitForExistence(timeout: 5.0))
try await Task.sleep(for: .seconds(1))

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More