Repository navigation
test(web): wait for the Watch Party fallback call before checking it - #3708
Conversation
The "retains the refusal" test waited for the refusal text and then expected one fallback call. The player's first commit shows the refusal before the fallback effect runs, so on a slow runner the text matched before the call and the test failed with 0 calls. Wait for the call first, then for the refusal to come back after the rejected fallback. Rerender with a fresh room object so the effect runs again and the loop guard is what keeps the count at one.
Code Review Could Not Complete
|
| Options | Enabled |
|---|---|
| Bug | ✅ |
| Performance | ✅ |
| Security | ✅ |
| Business Logic | ❌ |
|
🤖 Claude Code (claude-opus-5-5) Review of What I checked
Other feedback: CodeRabbit left no comments. The failed Kody check was a provider outage on Kody's side and isn't related to this branch. Validated features: none affected. The change only touches tests. Fit: 9/10 · Readiness: 9/10 — ready
|
Problem
Related issue: N/A
Validation tasks: none
The Watch Party test "retains the refusal without looping when no shared fallback exists" fails now and then on CI with
expected "vi.fn()" to be called 1 times, but got 0 times. It failed in "ci / Web test (1/4)" on #3704, which doesn't touch the player. This change makes the test deterministic. It doesn't change the player.The test waited for the refusal text and then expected exactly one fallback call. The text isn't a sign that the fallback has run, though. When the Watch Party gate mounts the player, the player's first commit already shows the refusal. The fallback effect runs after that commit and then waits on a capability check before it calls
fallbackSource. If that first commit lands,waitFormatches the text and the test checks the count before the effect has got that far. That's 0 calls.Approach
The test now waits for the fallback call first. It then waits for the refusal to come back, which only happens once the rejected fallback clears the pending state, and checks that the "Finding a compatible version" message is gone. That makes the "retains the refusal" part of the name a real check rather than a match on the first frame.
For the no-loop part, the rerender now passes a fresh room object. Before, the room object was the same one, so the effect never ran again and the guard against a second request was never exercised. With a new object the effect runs again. If it got past the guard, it would set the pending state synchronously inside
rerender'sact(). So straight after the rerender the test checks that the refusal is still shown, the pending message isn't, and there's still one call. There are no timers or sleeps.I checked the sibling tests in the same block. The per-role test waits for the call before it checks the pending message, and the other two only assert that something wasn't called. None of them have this race, so I left them alone.
Validation
pnpm exec vitest run src/player/components/WatchPage.test.ts: 19 passed, six runs.fallbackHandledRefguard inWatchPage.tsxmakes the new test fail, so the no-loop check catches a second request. The old test passed with the guard removed.Evidence
Evidence: none, no user-visible change
Risks
None identified. Only the test changes.
Checklist
AI Disclosure
Note
Make Watch Party fallback refusal test wait for the fallback call
Reworks the fallback refusal test in WatchPage.test.ts. The test now waits for the fallback request before asserting the refusal state, stores the refusal text for reuse, and verifies that no pending fallback message appears. It also rerenders with a fresh room object and confirms no second fallback request occurs.
Macroscope summarized cc8d6cd.