mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-24 18:59:36 +00:00
Fix flaky ignore/unignore tests in RoomDetailsScreenViewModelTests
The ignore and unignore tests waited for isProcessingIgnoreRequest to transition through [true, false]. The mocked client call returns almost immediately, so under load the observation can coalesce and only ever see false, making the test time out after 10 seconds and triggering a CI retry. Wait on the durable outcome instead (the recipient's ignored state, or the alert on failure) and assert only that, dropping the processing state checks which no longer cover anything.
This commit is contained in:
@@ -169,15 +169,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member == RoomMemberDetails(withProxy: recipient))
|
||||
|
||||
#expect(!context.viewState.isProcessingIgnoreRequest)
|
||||
let deferredProcessing = deferFulfillment(viewModel.context.observe(\.viewState.isProcessingIgnoreRequest),
|
||||
transitionValues: [true, false])
|
||||
let deferredIgnored = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0?.member.isIgnored == true }
|
||||
|
||||
context.send(viewAction: .ignoreConfirmed)
|
||||
|
||||
try await deferredProcessing.fulfill()
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member.isIgnored == true)
|
||||
try await deferredIgnored.fulfill()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -200,13 +196,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member == RoomMemberDetails(withProxy: recipient))
|
||||
|
||||
#expect(!context.viewState.isProcessingIgnoreRequest)
|
||||
let deferredProcessing = deferFulfillment(viewModel.context.observe(\.viewState.isProcessingIgnoreRequest),
|
||||
transitionValues: [true, false])
|
||||
let deferredAlert = deferFulfillment(context.observe(\.alertInfo)) { $0 != nil }
|
||||
|
||||
context.send(viewAction: .ignoreConfirmed)
|
||||
|
||||
try await deferredProcessing.fulfill()
|
||||
try await deferredAlert.fulfill()
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member.isIgnored == false)
|
||||
#expect(context.alertInfo != nil)
|
||||
@@ -230,15 +224,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member == RoomMemberDetails(withProxy: recipient))
|
||||
|
||||
#expect(!context.viewState.isProcessingIgnoreRequest)
|
||||
let deferredProcessing = deferFulfillment(viewModel.context.observe(\.viewState.isProcessingIgnoreRequest),
|
||||
transitionValues: [true, false])
|
||||
let deferredUnignored = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0?.member.isIgnored == false }
|
||||
|
||||
context.send(viewAction: .unignoreConfirmed)
|
||||
|
||||
try await deferredProcessing.fulfill()
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member.isIgnored == false)
|
||||
try await deferredUnignored.fulfill()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -261,14 +251,12 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
#expect(context.viewState.dmRecipientInfo?.member == RoomMemberDetails(withProxy: recipient))
|
||||
|
||||
#expect(!context.viewState.isProcessingIgnoreRequest)
|
||||
let deferredAlert = deferFulfillment(context.observe(\.alertInfo)) { $0 != nil }
|
||||
|
||||
context.send(viewAction: .unignoreConfirmed)
|
||||
|
||||
try await deferredAlert.fulfill()
|
||||
|
||||
#expect(!context.viewState.isProcessingIgnoreRequest)
|
||||
#expect(context.viewState.dmRecipientInfo?.member.isIgnored == true)
|
||||
#expect(context.alertInfo != nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user