Skip to content

tests(ui): wait for the token panel before filling the search box - #449

Merged
aojea merged 1 commit into
google:mainfrom
aojea:ui-test-focus-race
Sep 19, 2026
Merged

aojea merged 1 commit into
google:mainfrom
aojea:ui-test-focus-race

Conversation

@aojea

@aojea aojea commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes the flake in the search box filters rendered rows seen in this run:

Locator: locator('#table-bootstrap tr[data-filter-empty]')
Expected substring: "No rows match"
Error: element(s) not found

Why

The test clicks Generate, then asserts the table contains root-admin. Earlier tests already minted root-admin tokens on the shared control plane, so that assertion passes at once from the rows rendered at login and the test does not actually wait for the POST.

It then fill()s the search box. Playwright's fill focuses the element and inserts the text in a separate CDP round-trip. If the token response lands in that gap, showGeneratedToken() runs input.focus(); input.select() on #token-result-value, so the text goes into the token field. The search box never receives an input event, no data-filter-empty row is created, and the expectation times out.

Fix

Wait for #token-result to be visible before typing anywhere else. The panel is unhidden in the same synchronous step as the focus change, so once it is visible nothing else in the page steals focus. Test-only change.

The search-box test clicks Generate and then asserts the table contains
"root-admin", which passes immediately from rows rendered at login when
earlier tests already minted tokens, so it never waits for the POST. When
the response lands while a later fill() is between focusing the search
box and inserting text, showGeneratedToken() moves focus to the token
field and the text goes there instead. The search box never sees an
input event, no data-filter-empty row appears, and the test times out.

Wait for the result panel, which is set visible in the same synchronous
step as the focus change, before typing into the search box.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the UI test in tests/ui/console.spec.js to wait for the #token-result panel to be visible after submitting the token generation form. This prevents a race condition where focus shifts to the token field and interferes with subsequent typing into the search box. There are no review comments, and I have no feedback to provide.

@aojea
aojea merged commit 37d1070 into google:main Sep 19, 2026
18 checks passed
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