Fix for flaky tests (#5869)

* possible logging tests fix

* fix for flaky tests

* use timelimit for max test time

* pr suggestions

* remove comment
This commit is contained in:
Mauro
2026-07-14 18:01:36 +02:00
committed by GitHub
parent 85f28d017d
commit 39bd882a27
14 changed files with 231 additions and 132 deletions
@@ -56,19 +56,21 @@ final class MediaUploadPreviewScreenViewModelTests {
try await send()
}
@Test
@Test(.timeLimit(.minutes(2))) // Transcoding videos can be slow on a busy CI runner.
func videoUploadWithoutCaption() async throws {
setUpViewModel(urls: [videoURL], expectedCaption: nil)
context.caption = .init("")
try await send()
// The preprocessor transcodes the video for real which can take a while on a busy CI runner.
try await send(timeout: .seconds(60))
}
@Test
@Test(.timeLimit(.minutes(2))) // Transcoding videos can be slow on a busy CI runner.
func videoUploadWithCaption() async throws {
let caption = "Check out this video!"
setUpViewModel(urls: [videoURL], expectedCaption: caption)
context.caption = .init(string: caption)
try await send()
// The preprocessor transcodes the video for real which can take a while on a busy CI runner.
try await send(timeout: .seconds(60))
}
@Test
@@ -306,10 +308,10 @@ final class MediaUploadPreviewScreenViewModelTests {
return .success(())
}
private func send() async throws {
private func send(timeout: Duration = .seconds(10)) async throws {
#expect(!context.viewState.shouldDisableInteraction, "Attempting to send when interaction is disabled.")
let deferred = deferFulfillment(viewModel.actions) { $0 == .dismiss }
let deferred = deferFulfillment(viewModel.actions, timeout: timeout) { $0 == .dismiss }
context.send(viewAction: .send)
#expect(context.viewState.shouldDisableInteraction, "The interaction should be disabled while sending.")