Skip to content

test: fix flaky insurance request test in OfflineFirstChatRepositoryTest - #6927

Merged
AndyScherzinger merged 1 commit into
masterfrom
fix/noid/flaky-insurance-request-test
Oct 17, 2026
Merged

AndyScherzinger merged 1 commit into
masterfrom
fix/noid/flaky-insurance-request-test

Conversation

@AndyScherzinger

Copy link
Copy Markdown
Member

Fixes the flaky unit test OfflineFirstChatRepositoryTest > insurance requests resume with the next tick after the chat is resumed, which fails intermittently on CI with WantedButNotInvoked (e.g. run 39053012463 on #6500, and run 39041491912 on an earlier version of the same Renovate commit that also passed in another run).

Cause: the test advances virtual time with runTest, then verifies right after runCurrent() that pullChatMessages was called once. The insurance request goes through ChatMessageSyncer's pull flow, which runs .flowOn(Dispatchers.IO). runCurrent() only drains the test dispatcher, so on a busy runner the verify could run before the IO thread reached the network mock.

Fix: verify with timeout(AWAIT_TIMEOUT_MILLIS).times(1), the same pattern the long polling test in this class already uses. Test-only change, no production code touched.

Verified: with a temporary Thread.sleep(300) before the network call in ChatMessageSyncer, the old test fails reproducibly and the fixed one passes. Without it, the whole class passes repeatedly; ktlint and detekt are clean.

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🚧 TODO

  • ...

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The insurance request goes through ChatMessageSyncer's pull flow, which
runs on Dispatchers.IO. runCurrent() only drains the test dispatcher, so
the verify could run before the IO thread reached the network mock and
the test failed with WantedButNotInvoked on busy CI runners.

Verify with a timeout, as the long polling test in the same class does.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@github-actions

Copy link
Copy Markdown
Contributor

Codacy

Lint

TypemasterPR
Warnings138138
Errors1515

SpotBugs

CategoryBaseNew
Bad practice77
Correctness88
Dodgy code4040
Internationalization33
Malicious code vulnerability33
Performance88
Security1111
Total8080

@github-actions

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit 703d3a3
Version 6927
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@AndyScherzinger
AndyScherzinger merged commit a446a03 into master Oct 17, 2026
20 checks passed
@AndyScherzinger
AndyScherzinger deleted the fix/noid/flaky-insurance-request-test branch October 17, 2026 20:03
@AndyScherzinger AndyScherzinger added this to the 25.1.0 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant