Skip to content

[No QA] Fix flaky SignInBackButtonTest - #98579

Closed
situchan wants to merge 1 commit into
Expensify:mainfrom
situchan:situchan/fix-signin-back-button-test-flake
Closed

[No QA] Fix flaky SignInBackButtonTest#98579
situchan wants to merge 1 commit into
Expensify:mainfrom
situchan:situchan/fix-signin-back-button-test-flake

Conversation

@situchan

Copy link
Copy Markdown
Contributor

Explanation of Change

tests/unit/SignInBackButtonTest.tsx (added in #98401) is flaky and is currently failing on most open PRs, e.g. https://github.com/Expensify/App/actions/runs/31686180988/job/94402673478:

FAIL tests/unit/SignInBackButtonTest.tsx
  ● sign-in Android hardware back handling › SignInModal › registers no back listener that consumes the press without navigating
    TypeError: _Navigation.default.dismissModal is not a function
      at src/pages/signin/SignInModal.tsx:60:19

Root cause:

  1. The test mocks @libs/Navigation/Navigation with only goBack and navigationRef.
  2. Rendering SignInModal runs an effect that ends in openApp(true) (the mocked useSession returns undefined, so the user is treated as non-anonymous and hasSignedInRef is set).
  3. openApp issues a real OpenApp request. jest/setup.ts installs a global fetch mock that resolves {jsonCode: 200}, so the request succeeds and finallyData merges IS_LOADING_APP: false.
  4. That Onyx write re-renders the modal, the second effect's isLoadingApp !== false guard now passes, and it calls Navigation.dismissModal() — which the mock doesn't define → TypeError.

Whether that round trip lands before the test file finishes is a race, which is why the same shard (test (job 1), 2799 tests) passes in some runs and fails in others with no change on main in between:

Run Time (UTC) Result
31682152902 / 31682289042 / 31682575899 08:27–08:33 PASS
31682721109 / 31683280022 / 31684038938 / 31685112441 08:35–09:06 FAIL
31686180988 / 31686714790 / 31686932462 / 31688812358 / 31689714043 / 31690207448 / 31690340714 / 31691728068 09:21–10:34 FAIL

Fix:

  • Stub openApp so the unit test doesn't fire a real API request whose response lands mid-test (this also removes leaked async work — the failing job logs "A worker process has failed to exit gracefully").
  • Complete the Navigation mock with the members SignInModal/SignInPage actually use (dismissModal, navigate, isNavigationReady), so the test can't break again on timing alone.

The assertions themselves are unchanged, so the regression coverage added by #98401 for #96869 is preserved.

Fixed Issues

$ N/A — CI-only fix for the flaky test added in #98401

Tests

N/A

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

N/A

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@situchan
situchan marked this pull request as ready for review August 13, 2026 12:42
@situchan
situchan requested a review from a team as a code owner August 13, 2026 12:42
@melvin-bot
melvin-bot Bot requested review from blimpich and removed request for a team August 13, 2026 12:43
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

@blimpich Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@situchan

Copy link
Copy Markdown
Contributor Author

@MelvinBot investigate all workflow failures

@MelvinBot

Copy link
Copy Markdown
Contributor

Workflow failures — all infrastructure, none from this PR

All three failing checks died from the same CI runner failure, not your code:

The self-hosted runner lost communication with the server. Verify the machine is running and has a healthy network connection.

Check Cause
ESLint check Runner lost communication with server
test (job 2) Runner lost communication with server
test (job 7) Runner lost communication with server

The job logs are all BlobNotFound — the runner died before it could upload them, which is the signature of the runner dropping mid-job rather than a code error surfacing.

Your fix is fine. The flaky SignInBackButtonTest lives in the test (job 1) shard, and job 1 passed (5m51s), along with jobs 3, 4, 5, 6, and 8. Only the shards whose runners happened to drop (2 and 7) and the ESLint runner failed, and they failed before running to a real conclusion.

Check independent approval is also failing, but that's expected — it just means the PR still needs independent Expensify approvals; it's not a code check.

Recommendation: Re-run the failed jobs — I don't have permission to trigger re-runs here, so please kick them off:

gh run rerun 31700363252 --repo Expensify/App --failed   # ESLint
gh run rerun 31700363292 --repo Expensify/App --failed   # test (jobs 2 & 7)

They should go green on a healthy runner with no changes needed.

@situchan

Copy link
Copy Markdown
Contributor Author

Fixed in #98586

@situchan situchan closed this Aug 13, 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.

2 participants