You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2025-09-02] [$125] Fix flaky test UnreadIndicatorsTest #66037
This tests is flaky on main, please, identify the RCA and try to identify the pattern that we could try to avoid in other places. Lets fix this same issue in other tests if present and propose if there is some guard we could put in place to avoid this.
● Unread Indicators › Do not display the new line indicator when tracking an expense on self DM while offline
expect(received).toHaveLength(expected)
Expected length: 0
Received length: 1
Received array: [{"_fiber": [FiberNode]}]
672 | const newMessageLineIndicatorHintText = translateLocal('accessibilityHints.newMessageLineIndicator');
673 | const unreadIndicator = screen.queryAllByLabelText(newMessageLineIndicatorHintText);
> 674 | expect(unreadIndicator).toHaveLength(0);
| ^
675 | });
676 | it('Mark the chat as unread on clicking "Mark as unread" on an item in LHN when the last message of the chat was deleted by another user', async () => {
677 | await signInAndGetAppWithUnreadChat();
at Object.toHaveLength (tests/ui/UnreadIndicatorsTest.tsx:674:33)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:17)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:17:9)
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
None
What alternative solutions did you explore? (Optional)
NA
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Please re-state the problem that we are trying to solve in this issue.
Fix flaky test UnreadIndicatorsTest
What is the root cause of that problem?
Race Condition Between State Updates and Assertion
The app heavily relies on async state updates, which may not be flushed by the time the test reaches the assertion.
Test Uses Static Queries Instead of waitFor
The test uses screen.queryAllByLabelText without waiting for the DOM to settle.
This is risky, especially with asynchronous render cycles or delayed state propagation.
Using synchronous assertions without awaiting side effects can easily lead to flakiness.
What changes do you think we should make in order to solve the problem?
Use waitFor when querying elements affected by state or side effects:
@getusha The test will fail sometimes. It's based on Onyx.clear is done before the next test or not. Because we don't return a promise in beforeEach, the next test can be executed before Onyx.clear is complete.
@getusha The test will fail sometimes. It's based on Onyx.clear is done before the next test or not. Because we don't return a promise in beforeEach, the next test can be executed before Onyx.clear is complete.
Is there a way to make sure we don't forget to return the promise when there's an Onyx operation in a test case?
@getusha@abekkala The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
We don’t need a new test. This is not a bug, but a unit test inconsistency.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Jul 14, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (
External)melvin-bot commentedon Jul 14, 2025
Triggered auto assignment to @maddylewis (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.[-]Fix flaky test UnreadIndicatorsTest[/-][+][$125] Fix flaky test UnreadIndicatorsTest[/+]melvin-bot commentedon Jul 14, 2025
nkdengineer commentedon Jul 14, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Fix flaky test UnreadIndicatorsTest
What is the root cause of that problem?
App/tests/ui/UnreadIndicatorsTest.tsx
Line 190 in 8540a98
signInWithTestUserand rendering the sidebarWhat changes do you think we should make in order to solve the problem?
We should return a promise here and also set the fetch to our mock fetch
App/tests/ui/UnreadIndicatorsTest.tsx
Line 190 in 8540a98
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
None
What alternative solutions did you explore? (Optional)
NA
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
nabi-ebrahimi commentedon Jul 14, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Fix flaky test UnreadIndicatorsTest
What is the root cause of that problem?
Race Condition Between State Updates and Assertion
The app heavily relies on async state updates, which may not be flushed by the time the test reaches the assertion.
Test Uses Static Queries Instead of
waitForThe test uses
screen.queryAllByLabelTextwithout waiting for the DOM to settle.This is risky, especially with asynchronous render cycles or delayed state propagation.
Using synchronous assertions without awaiting side effects can easily lead to flakiness.
What changes do you think we should make in order to solve the problem?
Use
waitForwhen querying elements affected by state or side effects:This ensures that React Native's async rendering and
Onyx-based updates complete before assertion.Audit similar tests for risky direct assertions:
screen.queryBy...orscreen.queryAllBy...with immediateexpect(...).toHaveLength(0).waitForwhere state can be async.We can consider introducing a shared test utility:
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional)
getusha commentedon Jul 14, 2025
@nkdengineer @nabi-ebrahimi it's not a new test case your RCA fails to explain why it suddenly started to fail
nkdengineer commentedon Jul 14, 2025
@getusha The test will fail sometimes. It's based on
Onyx.clearis done before the next test or not. Because we don't return a promise inbeforeEach, the next test can be executed beforeOnyx.clearis complete.getusha commentedon Jul 14, 2025
Is there a way to make sure we don't forget to return the promise when there's an Onyx operation in a test case?
31 remaining items
melvin-bot commentedon Aug 26, 2025
@getusha @abekkala The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
abekkala commentedon Aug 26, 2025
PAYMENT SUMMARY FOR SEPT 02
please complete checklist
abekkala commentedon Sep 2, 2025
@nkdengineer please accept the Upwork offer and I can get that sent today - thanks!
nkdengineer commentedon Sep 2, 2025
@abekkala Offer was accepted, thanks!
abekkala commentedon Sep 2, 2025
@nkdengineer payment sent and contract ended - thank you! 🎉
@getusha please complete the checklist and we can close this one out! Thanks!
melvin-bot commentedon Sep 2, 2025
Payment Summary
Upwork Job
BugZero Checklist (@abekkala)
abekkala commentedon Sep 3, 2025
@getusha bumping for the checklist - thanks!
abekkala commentedon Sep 4, 2025
@getusha can you complete the checklist so we can close this one out - thanks!
getusha commentedon Sep 4, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: Fix optimistic message created while offline is marked as unread #56628 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1756996408119649
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
We don’t need a new test. This is not a bug, but a unit test inconsistency.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
getusha commentedon Sep 4, 2025
Done, thanks!
abekkala commentedon Sep 5, 2025
posting payment summary once more for better visibility:
PAYMENT SUMMARY FOR SEPT 02
flaviadefaria commentedon Oct 2, 2025
$125 approved for @getusha