Skip to content

test: wait for focus to reach Cancel in the add-torrent no-client test - #613

Merged
kikootwo merged 1 commit into
mainfrom
fix/610-addtorrent-focus-test
Nov 16, 2026
Merged

kikootwo merged 1 commit into
mainfrom
fix/610-addtorrent-focus-test

Conversation

@kikootwo

Copy link
Copy Markdown
Owner

What changed

  • tests/app/admin/components/AddTorrentDialog.test.tsx: the no-torrent-client test now waits (waitFor) for focus to land on Cancel instead of checking it the moment the message appears. The component is unchanged.

Why

The dialog shows the "No torrent client is set up" message on one render and moves focus to Cancel in an effect after that render. findByText can resolve between the two, so the old check sometimes still saw focus on the magnet field (it failed once in CI). The same kind of race was fixed in the header badge tests in #607.

The other checks in this file were read for the same pattern. They either run right after render or fireEvent (both flush effects), or check things that change in the same render as the text they wait for (disabled fields, the disabled Cancel while sending), so they cannot race.

Checks

  • With the focus effect removed from a local copy of the component, the new check fails; with it in place, it passes.
  • The test file passed 30 runs in a row.
  • npx vitest related --run on the test file, npx tsc --noEmit and eslint on the file are clean.

Risk and rollback

Test-only. Revert the commit to roll back.

Closes #610

🤖 Generated with Claude Code

The dialog shows the no-torrent-client message on one render and moves
focus to Cancel in an effect after it, so findByText could resolve before
focus moved. Wait for the focus instead of checking it at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kikootwo
kikootwo marked this pull request as ready for review November 16, 2026 00:29
@kikootwo
kikootwo merged commit ef1a282 into main Nov 16, 2026
1 check passed
@kikootwo
kikootwo deleted the fix/610-addtorrent-focus-test branch November 16, 2026 00:32
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.

AddTorrentDialog test: the no-client focus check can run before focus moves to Cancel

1 participant