Repository navigation
test: migrate batch 1 component tests to browser locators - #8615
tay1orjones wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0e8e36b7-9bf7-441f-b8fb-844f81f27d32
|
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
What changed in this PR
Migrates a first batch of component tests from React Testing Library (RTL) queries/interactions to Vitest browser locators, aiming to exercise more realistic browser behavior while keeping RTL rendering/lifecycle where appropriate.
Changes:
- Swapped many
screen/within/container queries topage.getBy*locators across ActionBar, ActionMenu, ActionList, and AnchoredOverlay tests. - Replaced most
@testing-library/user-eventusage withuserEventfromvitest/browser. - Updated focus and keyboard interaction patterns to use locators and
expect.element(...)assertions.
| File | Description |
|---|---|
| packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsx | Migrates overlay interaction tests to browser locators; updates click/keyboard flows. |
| packages/react/src/ActionMenu/ActionMenu.test.tsx | Converts ActionMenu tests to page locators + vitest/browser events/assertions. |
| packages/react/src/ActionList/LinkItem.test.tsx | Updates LinkItem tests to locator-based queries and interactions. |
| packages/react/src/ActionList/Item.test.tsx | Migrates Item interaction/focus tests to locators; adjusts keyboard/click handling. |
| packages/react/src/ActionList/Heading.test.tsx | Replaces RTL queries with page.getByRole(...) assertions. |
| packages/react/src/ActionList/Group.test.tsx | Moves Group heading tests to browser locators and locator-based assertions. |
| packages/react/src/ActionList/Description.test.tsx | Converts Description tests to locators and expect.element(...) assertions. |
| packages/react/src/ActionList/ActionList.test.tsx | Updates ActionList navigation/tree role tests to use page locators and browser events. |
| packages/react/src/ActionBar/ActionBar.test.tsx | Migrates ActionBar tests to vitest/browser locators/events; updates overflow/menu assertions. |
Review effort: Lite
| expect(option).toBeInTheDocument() | ||
| const option = page.getByRole('option') | ||
| await expect.element(option).toBeInTheDocument() | ||
| await userEvent.click(option) |

Related to github/primer#6369.
Move test interactions and queries to Vitest browser locators so these tests exercise browser behavior while keeping RTL rendering and lifecycle handling where needed.
Changelog
New
Changed
Removed
Rollout strategy
Testing & Reviewing
Check ActionBar's More items overflow menu and submenu icons, ActionMenu opening and closing with click and keyboard (including focus return), and AnchoredOverlay outside-click dismissal. Confirm ActionList item interactions and accessible queries still behave as expected.
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com