test(next-js): fix flaky deleteIndex test race

Closed
JU
9d ago
+9-4

Summary

  • next-js-test failed on #549 (an unrelated workflow-only change). The failing test was deleteIndex > shows an error message when deleting the index fails. At failure time, the button's accessible name was Deleting Index.
  • Cause: deleteIndex runs in an async useTransition. The state updates after the await commit before isPending clears. That leaves one render where the error or idle UI is visible while the button still reads "Deleting Index" and Build is still disabled. The two delete tests asserted right after the first waitFor passed, so they could land on that render.
  • Fix: both tests now wait for the delete button label to settle before asserting. This is a test-only change. The component is unchanged.

Test plan

  • Reproduced on the unchanged branch: 3 of 12 full-file runs failed when 12 ran in parallel. Both delete tests hit the race.
  • With the fix: 36 of 36 full-file runs passed when run in batches of 12 in parallel.
  • eslint app/page.test.tsx: no new warnings.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated deletion tests to wait for the expected post-deletion state and verify that deletion errors appear alongside an enabled Delete Index button.