@@ -73,6 +73,49 @@ test.describe('Search Pages', () => {
7373 await expect ( page ) . toHaveURL ( / \/ ( p a c k a g e | o r g | u s e r ) \/ v u e / )
7474 } )
7575
76+ test ( '/search?q=vue → ArrowDown navigates only between results, not keyword buttons' , async ( {
77+ page,
78+ goto,
79+ } ) => {
80+ await goto ( '/search?q=vue' , { waitUntil : 'hydration' } )
81+
82+ await expect ( page . locator ( 'text=/found \\d+|showing \\d+/i' ) . first ( ) ) . toBeVisible ( {
83+ timeout : 15000 ,
84+ } )
85+
86+ const firstResult = page . locator ( '[data-result-index="0"]' ) . first ( )
87+ const secondResult = page . locator ( '[data-result-index="1"]' ) . first ( )
88+ await expect ( firstResult ) . toBeVisible ( )
89+ await expect ( secondResult ) . toBeVisible ( )
90+
91+ // ArrowDown from input focuses the first result
92+ await page . keyboard . press ( 'ArrowDown' )
93+ await expect ( firstResult ) . toBeFocused ( )
94+
95+ // Second ArrowDown focuses the second result (not a keyword button within the first)
96+ await page . keyboard . press ( 'ArrowDown' )
97+ await expect ( secondResult ) . toBeFocused ( )
98+ } )
99+
100+ test ( '/search?q=vue → ArrowUp from first result returns focus to search input' , async ( {
101+ page,
102+ goto,
103+ } ) => {
104+ await goto ( '/search?q=vue' , { waitUntil : 'hydration' } )
105+
106+ await expect ( page . locator ( 'text=/found \\d+|showing \\d+/i' ) . first ( ) ) . toBeVisible ( {
107+ timeout : 15000 ,
108+ } )
109+
110+ // Navigate to first result
111+ await page . keyboard . press ( 'ArrowDown' )
112+ await expect ( page . locator ( '[data-result-index="0"]' ) . first ( ) ) . toBeFocused ( )
113+
114+ // ArrowUp returns to the search input
115+ await page . keyboard . press ( 'ArrowUp' )
116+ await expect ( page . locator ( 'input[type="search"]' ) ) . toBeFocused ( )
117+ } )
118+
76119 test ( '/search?q=vue → "/" focuses the search input from results' , async ( { page, goto } ) => {
77120 await goto ( '/search?q=vue' , { waitUntil : 'hydration' } )
78121
0 commit comments