Fix UI tests

This commit is contained in:
Stefan Ceriu 2022-09-26 14:18:36 +03:00 committed by Stefan Ceriu
parent 730ada69a0
commit 98de77679b
97 changed files with 189 additions and 196 deletions

View File

@ -39,7 +39,7 @@ struct HomeScreen: View {
} }
} }
} }
.animation(.default, value: context.viewState.visibleRooms) .animation(.elementDefault, value: context.viewState.visibleRooms)
.padding(.horizontal) .padding(.horizontal)
.searchable(text: $context.searchQuery) .searchable(text: $context.searchQuery)
} }

View File

@ -46,7 +46,6 @@ struct RoomScreenViewState: BindableState {
var roomId: String var roomId: String
var roomTitle = "" var roomTitle = ""
var roomAvatar: UIImage? var roomAvatar: UIImage?
var roomEncryptionBadge: UIImage?
var items: [RoomTimelineViewProvider] = [] var items: [RoomTimelineViewProvider] = []
var isBackPaginating = false var isBackPaginating = false
var bindings: RoomScreenViewStateBindings var bindings: RoomScreenViewStateBindings

View File

@ -33,8 +33,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
timelineViewFactory: RoomTimelineViewFactoryProtocol, timelineViewFactory: RoomTimelineViewFactoryProtocol,
mediaProvider: MediaProviderProtocol, mediaProvider: MediaProviderProtocol,
roomName: String?, roomName: String?,
roomAvatarUrl: String? = nil, roomAvatarUrl: String? = nil) {
roomEncryptionBadge: UIImage? = nil) {
self.timelineController = timelineController self.timelineController = timelineController
self.timelineViewFactory = timelineViewFactory self.timelineViewFactory = timelineViewFactory
self.mediaProvider = mediaProvider self.mediaProvider = mediaProvider
@ -42,7 +41,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
super.init(initialViewState: RoomScreenViewState(roomId: timelineController.roomId, super.init(initialViewState: RoomScreenViewState(roomId: timelineController.roomId,
roomTitle: roomName ?? "Unknown room 💥", roomTitle: roomName ?? "Unknown room 💥",
roomAvatar: nil, roomAvatar: nil,
roomEncryptionBadge: roomEncryptionBadge,
bindings: .init(composerText: "", composerFocused: false))) bindings: .init(composerText: "", composerFocused: false)))
timelineController.callbacks timelineController.callbacks

View File

@ -37,11 +37,6 @@ struct RoomHeaderView: View {
ZStack(alignment: .bottomTrailing) { ZStack(alignment: .bottomTrailing) {
roomAvatarImage roomAvatarImage
.clipShape(Circle()) .clipShape(Circle())
if let encryptionBadge = context.viewState.roomEncryptionBadge {
Image(uiImage: encryptionBadge)
.accessibilityIdentifier("encryptionBadgeIcon")
}
} }
.frame(width: AvatarSize.room(on: .timeline).value, height: AvatarSize.room(on: .timeline).value) .frame(width: AvatarSize.room(on: .timeline).value, height: AvatarSize.room(on: .timeline).value)
} }
@ -87,8 +82,7 @@ struct RoomHeaderView_Previews: PreviewProvider {
timelineViewFactory: RoomTimelineViewFactory(), timelineViewFactory: RoomTimelineViewFactory(),
mediaProvider: MockMediaProvider(), mediaProvider: MockMediaProvider(),
roomName: "Some Room name", roomName: "Some Room name",
roomAvatarUrl: nil, roomAvatarUrl: nil)
roomEncryptionBadge: Asset.Images.encryptionTrusted.image)
RoomHeaderView(context: viewModel.context) RoomHeaderView(context: viewModel.context)
.previewLayout(.sizeThatFits) .previewLayout(.sizeThatFits)

View File

@ -43,6 +43,10 @@ struct MockMediaProvider: MediaProviderProtocol {
} }
func loadImageFromURLString(_ urlString: String, avatarSize: AvatarSize?) async -> Result<UIImage, MediaProviderError> { func loadImageFromURLString(_ urlString: String, avatarSize: AvatarSize?) async -> Result<UIImage, MediaProviderError> {
.failure(.failedRetrievingImage) guard let image = UIImage(systemName: "photo") else {
fatalError()
}
return .success(image)
} }
} }

View File

@ -25,7 +25,6 @@ class RoomScreenUITests: XCTestCase {
XCTAssert(app.staticTexts["roomNameLabel"].exists) XCTAssert(app.staticTexts["roomNameLabel"].exists)
XCTAssert(app.staticTexts["roomAvatarPlaceholderImage"].exists) XCTAssert(app.staticTexts["roomAvatarPlaceholderImage"].exists)
XCTAssertFalse(app.images["encryptionBadgeIcon"].exists)
app.assertScreenshot(.roomPlainNoAvatar) app.assertScreenshot(.roomPlainNoAvatar)
} }
@ -36,7 +35,6 @@ class RoomScreenUITests: XCTestCase {
XCTAssert(app.staticTexts["roomNameLabel"].exists) XCTAssert(app.staticTexts["roomNameLabel"].exists)
XCTAssert(app.images["roomAvatarImage"].exists) XCTAssert(app.images["roomAvatarImage"].exists)
XCTAssert(app.images["encryptionBadgeIcon"].exists)
app.assertScreenshot(.roomEncryptedWithAvatar) app.assertScreenshot(.roomEncryptedWithAvatar)
} }

View File

@ -56,7 +56,7 @@ class ServerSelectionUITests: XCTestCase {
// Then the screen should not allow the user to continue. // Then the screen should not allow the user to continue.
let serverTextField = app.textFields.element let serverTextField = app.textFields.element
XCTAssertEqual(serverTextField.value as? String, ElementL10n.serverSelectionServerUrl, "The text field should show placeholder text in this state.") XCTAssertEqual(serverTextField.value as? String, ElementL10n.ftueAuthChooseServerEntryHint, "The text field should show placeholder text in this state.")
let confirmButton = app.buttons["confirmButton"] let confirmButton = app.buttons["confirmButton"]
XCTAssertTrue(confirmButton.exists, "The confirm button should always be shown.") XCTAssertTrue(confirmButton.exists, "The confirm button should always be shown.")