mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 03:48:27 +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:
@@ -71,18 +71,19 @@ class BugReportViewModelTests: XCTestCase {
|
||||
deviceID: nil,
|
||||
screenshot: nil, isModallyPresented: false)
|
||||
let context = viewModel.context
|
||||
let deferred = deferFulfillment(viewModel.actions.collect(2).first())
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||
switch action {
|
||||
case .submitFinished:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
context.send(viewAction: .submit)
|
||||
let actions = try await deferred.fulfill()
|
||||
|
||||
guard case .submitStarted = actions[0] else {
|
||||
return XCTFail("Action 1 was not .submitFailed")
|
||||
}
|
||||
|
||||
guard case .submitFinished = actions[1] else {
|
||||
return XCTFail("Action 2 was not .submitFinished")
|
||||
}
|
||||
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
|
||||
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, canContact: false, githubLabels: [], files: []))
|
||||
}
|
||||
@@ -97,18 +98,18 @@ class BugReportViewModelTests: XCTestCase {
|
||||
deviceID: nil,
|
||||
screenshot: nil, isModallyPresented: false)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actions.collect(2).first())
|
||||
let context = viewModel.context
|
||||
context.send(viewAction: .submit)
|
||||
let actions = try await deferred.fulfill()
|
||||
|
||||
guard case .submitStarted = actions[0] else {
|
||||
return XCTFail("Action 1 was not .submitFailed")
|
||||
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||
switch action {
|
||||
case .submitFailed:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
guard case .submitFailed = actions[1] else {
|
||||
return XCTFail("Action 2 was not .submitFailed")
|
||||
}
|
||||
let context = viewModel.context
|
||||
context.send(viewAction: .submit)
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
|
||||
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, canContact: false, githubLabels: [], files: []))
|
||||
|
||||
Reference in New Issue
Block a user