mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
69d430f51b
## Problem The `UsageUserDrillIn` play function in `AgentSettingsPageView.stories.tsx` flakes in Chromatic (noticed in #23282). After clicking a user row to drill into the detail view, sync assertions fire before React finishes the state transition — element not found. <img width="1110" height="649" alt="image" src="https://github.com/user-attachments/assets/8b5c36c2-09c4-4dd6-a280-ab6379c1464e" /> ### Root cause The play function clicks "Alice Liddell" and then waits with `findByText("Alice Liddell")` before asserting on detail-view content. But "Alice Liddell" appears in **both** the list row and the detail header, so `findByText` resolves immediately against the stale list-row text that is still in the DOM. The same is true for `"@alice"` — `UserRow` renders `@${user.username}` as a subtitle in the list, and `AvatarData` renders it again in the detail view. ### Fix Gate on `"User ID: ..."` instead — text that **only** renders in the detail panel. Once it is in the DOM, the detail view is fully mounted and all sync assertions are safe. Applied to both `UsageUserDrillIn` and `UsageUserDrillInAndBack`, which had the same issue.