Repository navigation
test: fix flaky insurance request test in OfflineFirstChatRepositoryTest - #6927
Merged
Merged
Conversation
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>
Contributor
Contributor
📱 QA build
The QA build installs alongside a released Nextcloud app, so you can keep Downloading the file requires a GitHub account, so open this link on the |
4 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the flaky unit test
OfflineFirstChatRepositoryTest > insurance requests resume with the next tick after the chat is resumed, which fails intermittently on CI withWantedButNotInvoked(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 afterrunCurrent()thatpullChatMessageswas called once. The insurance request goes throughChatMessageSyncer'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 inChatMessageSyncer, the old test fails reproducibly and the fixed one passes. Without it, the whole class passes repeatedly; ktlint and detekt are clean.🖼️ Screenshots
🚧 TODO
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)