Skip to content

Issue 3211 fix flaky tests part 5 - #3373

Draft
DenBond7 wants to merge 3 commits into
masterfrom
issue_3211_fix_flaky_tests_part_5
Draft

DenBond7 wants to merge 3 commits into
masterfrom
issue_3211_fix_flaky_tests_part_5

Conversation

@DenBond7

@DenBond7 DenBond7 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

This PR fixes more flaky androidTests from #3211 (part 5, follows #3340, #3347, #3355 and #3358). One of them was caused by a bug in the app.

Draft upload: the thread didn't show the updated draft

DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest failed 9 times on CI (7 branches, including master), mostly with PerformException when scrolling to the edited draft. It was an app bug. UploadDraftsWorker reported progress with setProgress(), and ThreadDetailsFragment reloaded the thread on the final "upload completed" progress. WorkManager doesn't deliver every progress update. On a slow emulator the fragment got RUNNING {STATE: UPLOADING} and then SUCCEEDED with empty progress, so the thread kept the old version of the draft. A user would see the old version too.

  • ThreadDetailsFragment remembers the UploadDraftsWorker runs it saw in the RUNNING state and silently reloads the thread when such a run finishes. The STATE_COMMON_UPLOAD_COMPLETED progress, which this replaces, is removed from the worker. The old code reloaded only for drafts of this thread. Now any draft upload reloads the open thread, which costs one extra silent request, and only while the thread screen is open.
  • The test retries scrollTo until the message appears (up to 30 s). The old waitForObjectWithText waited silently and never failed, so the next step failed instead.

Other tests

  • MessageDetailsFlowTest#testStandardMsgPlaintextWithOneAttachment failed on master with NoMatchingViewException for layoutAtt. BaseMessageDetailsFlowTest waited a fixed Thread.sleep(1000), but attachments are shown only after the message is parsed, which took 0.9–1.3 s on a slow emulator. baseCheckWithAtt() and matchReplyButtons() now wait until the views are displayed.
  • WkdClientTest was the only class without RetryRule. Its CI failures came from ClearAppSettingsRule failing to delete the Glide cache, and a retry handles that.
  • docs/testing-like-ci.md: lost WorkManager progress updates.

Testing (slow CI-like emulator, docs/testing-like-ci.md)

  • DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest without retries: failed 6 of 8 runs before the fix, passed 8 of 8 after it. The other 2 DraftsGmailAPITestCorrect*FlowTest classes pass too.
  • MessageDetailsFlowTest and 6 other classes based on BaseMessageDetailsFlowTest: 58 tests passed, no retries.
  • WkdClientTest: 5 tests passed.
  • lintConsumerUiTests and all unit tests (852) pass.

CI for this branch fails in ci-install-android-sdk.sh before any tests run. It's fixed in #3375 (#3374). This PR's pipeline needs a rerun after that is merged.

issue #3211


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

…lost

WorkManager doesn't deliver every setProgress() update. When a draft is
uploaded quickly, the thread screen sees the UPLOADING progress and then
the finished WorkInfo without progress, so the "upload completed" updates
that trigger the reload are lost and the thread keeps the old version of
the edited draft. This made DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest
fail on CI.

Reload the thread when an upload run seen running finishes, and drop the
STATE_COMMON_UPLOAD_COMPLETED progress that this replaces. In the test,
wait for the messages instead of a UiAutomator wait that never fails.
@DenBond7 DenBond7 changed the title fix: reload thread after a draft upload even if progress updates are … Issue 3211 fix flaky tests part 5 Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant