8000 Stabilize kebab handling in UI tests by ahus1 · Pull Request #52434 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Stabilize kebab handling in UI tests - #52434

Merged
ahus1 merged 2 commits into
keycloak:mainfrom
ahus1:is-52433-fix-table-toggle-click
Sep 4, 2026
Merged

ahus1 merged 2 commits into
keycloak:mainfrom
ahus1:is-52433-fix-table-toggle-click

Conversation

@ahus1
@ahus1 ahus1 commented Sep 4, 2026 •
Copy link
Copy Markdown
Member

Closes #52433

Summary

Hardens clickRowKebabItem in table.ts to retry the kebab toggle click when the dropdown menu fails to appear, matching the stabilization pattern used for other table helpers in PR #50995.

What changed

clickRowKebabItem now uses Playwright's expect().toPass() to retry the toggle-click + visibility-assertion sequence with a 10-second timeout. Once the menu item is confirmed visible, it clicks it.

Design decisions

  • expect().toPass() over manual try-catch loop: A try-catch retry loop is functionally an if-statement — it branches on transient state, which is the same anti-pattern Playwright's assertion-based API is designed to avoid. toPass() is the idiomatic Playwright retry primitive.

  • No aria-expanded guard before clicking: Checking toggle state then conditionally clicking is a TOCTOU race (state can change between check and click). Instead, the retry naturally handles toggle ambiguity — if one attempt closes an already-open menu, the next attempt re-opens it.

  • No Escape to dismiss menus between retries: Pressing Escape is a blunt instrument that could interfere with other page elements (modals, notifications). The retry loop resolves the toggle state without side effects.

  • All row-level kebab actions covered: clickRowKebabItem is the shared helper for all row kebab interactions across the test suite. The toolbar-level kebab (clickTableToolbarItem) was already hardened in PR try and make tests more stable #50995.

Closes keycloak#52433

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI 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.

🟡 Changes recommended

The final menu-item click remains outside the retry block, leaving the reported race partially unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Hardens row-level kebab actions against transient menu-rendering failures.

Changes:

  • Retries opening the kebab menu and checking item visibility.
  • Adds a 10-second retry timeout.
File summaries
File Description
js/apps/admin-ui/test/utils/table.ts Adds retry handling to row kebab interactions.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread js/apps/admin-ui/test/utils/table.ts Resolved
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI 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.

🟡 Changes recommended

The retry block can repeat a successfully dispatched, side-effecting menu action.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread js/apps/admin-ui/test/utils/table.ts Resolved
@ahus1
ahus1 marked this pull request as ready for review September 4, 2026 11:58
@ahus1
ahus1 requested review from a team as code owners September 4, 2026 11:58
@ahus1
ahus1 enabled auto-merge (squash) September 4, 2026 11:58
@edewit
edewit commented Sep 4, 2026
Copy link
Copy Markdown
Contributor

@ahus1 instead of adding more retry logic, how about this #52323 , it makes that the table doesn't unmount making the component easier to test

@ahus1
ahus1 commented Sep 4, 2026
Copy link
Copy Markdown
Member Author

@edewit - that's beyond my understanding of React, and possibly also difficult to backport to earlier branches.

What about merging this one first and backporting it to stabilize the tests, and then you proceed with your larger refactoring?

@ahus1
ahus1 merged commit 86608b6 into keycloak:main Sep 4, 2026
72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: registration-policies.spec.ts kebab menu "Delete" item not found after toggle click

3 participants

0