Wait on durable state in three flaky test suites

These three suites assert against state that is still being loaded or has
already moved on, so they fail whenever a busy runner stretches the window.
All three passed on CI only because `-retry-tests-on-failure` re-ran them.

- MediaUploadPreviewScreenViewModelTests: the processing failure tests treated
  a one second `deferFailure` window as if it also meant the send had finished.
  Preprocessing the valid files outlasts it, so wait for the interaction to be
  re-enabled instead.
- SecurityAndPrivacyScreenViewModelTests: the screen loads its parent spaces and
  its room directory visibility in two independent tasks, and `isSaveDisabled`
  needs both. Every wait now gates on the visibility having landed too.
- RoomNotificationSettingsScreenViewModelTests: the delete tests waited on a
  transient `deletingCustomSetting` flag that the observation coalesces away
  under load. They now wait on the dismiss action and the alert.
This commit is contained in:
Mauro Romito
2026-07-28 18:52:10 +02:00
committed by Mauro
parent c296eb0e43
commit 58fb7c4fcb
3 changed files with 39 additions and 28 deletions
@@ -117,8 +117,11 @@ final class MediaUploadPreviewScreenViewModelTests {
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 1) // Loading indicator
// Then the failure should occur preventing the screen from being dismissed.
// The interaction being re-enabled is what marks the end of the send, the timeout above only proves
// that no dismissal happened within it — processing may still be in flight when it elapses.
let deferredInteraction = deferFulfillment(context.observe(\.viewState.shouldDisableInteraction)) { !$0 }
try await deferredFailure.fulfill()
#expect(!context.viewState.shouldDisableInteraction)
try await deferredInteraction.fulfill()
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 2, "An error indicator should be shown.")
}
@@ -213,8 +216,11 @@ final class MediaUploadPreviewScreenViewModelTests {
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 1) // Loading indicator
// Then the failure should occur preventing the screen from being dismissed.
// Preprocessing the valid files can outlast the timeout above, so wait for the interaction to be
// re-enabled rather than assuming the send has finished by the time it elapses.
let deferredInteraction = deferFulfillment(context.observe(\.viewState.shouldDisableInteraction)) { !$0 }
try await deferredFailure.fulfill()
#expect(!context.viewState.shouldDisableInteraction)
try await deferredInteraction.fulfill()
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 2, "An error indicator should be shown.")
}