Skip to content

Fix flaky test on AutocompletePrompt.test.tsx#6936

Open
gonzaloriestra wants to merge 1 commit intomainfrom
fix-flaky
Open

Fix flaky test on AutocompletePrompt.test.tsx#6936
gonzaloriestra wants to merge 1 commit intomainfrom
fix-flaky

Conversation

@gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Mar 4, 2026

WHY are these changes introduced?

After upgrading to React 19, some flaky tests raised that #6922 tried to fix.

But CI keeps failing https://github.com/Shopify/cli/actions/runs/22668051243/job/65704701620

WHAT is this pull request doing?

Apparently it's a race condition. The flaky test sends ENTER right after detecting "No results found" in the frame, but React 19 hasn't yet re-registered the useInput handler with updated closures, so the stale handler still sees the old items and submits "first".

The fix adds a yield in sendInputAndWaitForContent (matching the existing pattern in sendInputAndWaitForChange) to let React 19 flush effects before subsequent input is sent.

How to test your changes?

CI. I've re-run the tests here several times and that test didn't fail.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.85% 14523/18419
🟡 Branches 73.16% 7225/9876
🟡 Functions 79.06% 3697/4676
🟡 Lines 79.18% 13720/17327

Test suite run success

3797 tests passing in 1449 suites.

Report generated by 🧪jest coverage report action from afea463

@gonzaloriestra gonzaloriestra marked this pull request as ready for review March 4, 2026 12:30
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner March 4, 2026 12:30
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

@gonzaloriestra gonzaloriestra requested a review from tewson March 4, 2026 12:30
@binks-code-reviewer
Copy link

🤖 Code Review · #projects-dev-ai for questions
React with 👍/👎 or reply — all feedback helps improve the agent.

Complete - No issues

📋 History

✅ No issues

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