test(frontend): wait for the picker's open focus before pressing Enter on the scope tab

The dialog moves focus to the search input on the next animation frame after opening. The test focused the sessions tab before that frame, so Enter sometimes landed on the search input and the scope never toggled. It now waits for the open focus, asserts the tab has focus, and checks the persisted scope.
This commit is contained in:
Chris Scott committed 2026-10-24 19:15:00 -04:00
1 parent adb251081f
commit 80e7f78a9b
1 file changed
+8 -2
@@ -357,12 +357,18 @@ describe('SessionPickerDialog', () => {
const user = userEvent.setup()
renderPicker()
await waitFor(() => expect(combobox()).toHaveFocus())
const sessionsTab = screen.getByRole('tab', { name: 'This project' })
act(() => {
screen.getByRole('tab', { name: 'This project' }).focus()
sessionsTab.focus()
})
expect(sessionsTab).toHaveFocus()
await user.keyboard('{Enter}')
expect(screen.getByRole('tab', { name: 'All sessions', selected: true })).toBeInTheDocument()
expect(await screen.findByRole('tab', { name: 'All sessions', selected: true })).toBeInTheDocument()
expect(localStorage.getItem('oc:session-picker:all-projects')).toBe('true')
})
it('labels the sessions tab Sessions and lists every project without a current repo', () => {