mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix various flakey unit tests (#1783)
* Fix flakey emoji provider tests * Fix flakey RoomScreenViewModel tests * Fix flakey HomeScreenViewModel tests * Fix flakey RoomMemberListScreen tests, problem with bindings getting overriden and deferFulfillment cancellable not getting stored * Fix flakey RoomNotificationSettingsScreen tests and crashes * Fix flakey RoomMemberDetailsScreen tests * Deprecate old `deferFulfillment` and `nextViewState` methods * Convert more files to the new `deferFulfillment` * Converted the rest of the tests to the new deferFulfillment * Removed now unused `nextViewState` and `deferFulfillment` * Remove automatic retries from unit tests * Reset analytics flag after running unit tests * Address PR comments * Introduce a new `deferFulfillment(publisher, keyPath, transitionValues)` method and use it where appropiate
This commit is contained in:
@@ -81,7 +81,16 @@ class StaticLocationScreenViewModelTests: XCTestCase {
|
||||
func testSendUserLocation() async throws {
|
||||
context.mapCenterLocation = .init(latitude: 0, longitude: 0)
|
||||
context.geolocationUncertainty = 10
|
||||
let deferred = deferFulfillment(viewModel.actions.first())
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||
switch action {
|
||||
case .sendLocation:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
context.send(viewAction: .selectLocation)
|
||||
guard case .sendLocation(let geoUri, let isUserLocation) = try await deferred.fulfill() else {
|
||||
XCTFail("Sent action should be 'sendLocation'")
|
||||
@@ -95,7 +104,16 @@ class StaticLocationScreenViewModelTests: XCTestCase {
|
||||
context.mapCenterLocation = .init(latitude: 0, longitude: 0)
|
||||
context.isLocationAuthorized = nil
|
||||
context.geolocationUncertainty = 10
|
||||
let deferred = deferFulfillment(viewModel.actions.first())
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||
switch action {
|
||||
case .sendLocation:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
context.send(viewAction: .selectLocation)
|
||||
guard case .sendLocation(let geoUri, let isUserLocation) = try await deferred.fulfill() else {
|
||||
XCTFail("Sent action should be 'sendLocation'")
|
||||
|
||||
Reference in New Issue
Block a user