From 3631120321154bc245648354b7cf2ff783a62605 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Fri, 23 Oct 2026 20:17:09 +0300 Subject: [PATCH] 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. --- .../RoomDetailsScreenViewModelTests.swift | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift index dbca317f4..68fe44235 100644 --- a/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift @@ -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) }