@@ -12,19 +12,24 @@ test.describe('Search Pages', () => {
1212 const firstResult = page . locator ( '[data-result-index="0"]' ) . first ( )
1313 await expect ( firstResult ) . toBeVisible ( )
1414
15+ // First result is selected by default, Enter navigates to it
16+ // URL is /vue not /package/vue (cleaner URLs)
1517 await page . keyboard . press ( 'Enter' )
16- await expect ( page ) . toHaveURL ( / \/ p a c k a g e \/ / )
18+ await expect ( page ) . toHaveURL ( / \/ v u e / )
1719
1820 await page . goBack ( )
21+ // Search input is autofocused on mount
1922 await expect ( searchInput ) . toBeFocused ( )
2023 await expect ( page . locator ( 'text=/found \\d+/i' ) ) . toBeVisible ( )
2124
25+ // ArrowDown changes visual selection but keeps focus in input
2226 await page . keyboard . press ( 'ArrowDown' )
23- const secondResult = page . locator ( '[data-result-index="1"]' ) . first ( )
24- await expect ( secondResult ) . toBeFocused ( )
27+ await expect ( searchInput ) . toBeFocused ( )
2528
29+ // Enter navigates to the now-selected second result
2630 await page . keyboard . press ( 'Enter' )
27- await expect ( page ) . toHaveURL ( / \/ p a c k a g e \/ / )
31+ // Second result could be vue-router, vuex, etc - just check we navigated away
32+ await expect ( page ) . not . toHaveURL ( / \/ s e a r c h / )
2833 } )
2934
3035 test ( '/search?q=vue → "/" focuses the search input from results' , async ( { page, goto } ) => {
0 commit comments