@@ -135,6 +135,19 @@ async function zoomInUntilMapPinsAreDetailed(page: Page) {
135135 await expectMapPinDetailScale ( page , 1 ) ;
136136}
137137
138+ async function focusMapControlByKeyboard ( page : Page , testId : string ) {
139+ for ( let i = 0 ; i < 20 ; i += 1 ) {
140+ await page . keyboard . press ( "Tab" ) ;
141+ const activeTestId = await page . evaluate ( ( ) =>
142+ document . activeElement ?. getAttribute ( "data-testid" )
143+ ) ;
144+
145+ if ( activeTestId === testId ) return ;
146+ }
147+
148+ throw new Error ( `Could not focus ${ testId } by keyboard` ) ;
149+ }
150+
138151test ( "map mounts when IP location is unavailable and restores the last view" , async ( {
139152 page,
140153} ) => {
@@ -155,6 +168,25 @@ test("map mounts when IP location is unavailable and restores the last view", as
155168 } ) ;
156169 expect ( await readStoredMapView ( page ) ) . toBeNull ( ) ;
157170
171+ await focusMapControlByKeyboard ( page , "map-control-search" ) ;
172+ await expect ( page . getByTestId ( "map-control-search" ) ) . toBeFocused ( ) ;
173+ await expect
174+ . poll ( ( ) =>
175+ page
176+ . getByTestId ( "map-control-search" )
177+ . evaluate ( ( element ) => getComputedStyle ( element ) . boxShadow )
178+ )
179+ . toContain ( "inset" ) ;
180+ await focusMapControlByKeyboard ( page , "map-control-zoom-in" ) ;
181+ await expect ( page . getByTestId ( "map-control-zoom-in" ) ) . toBeFocused ( ) ;
182+ await expect
183+ . poll ( ( ) =>
184+ page
185+ . getByTestId ( "map-control-zoom-in" )
186+ . evaluate ( ( element ) => getComputedStyle ( element ) . boxShadow )
187+ )
188+ . toContain ( "inset" ) ;
189+
158190 await page . getByTestId ( "map-control-zoom-in" ) . click ( ) ;
159191
160192 await expect
@@ -264,6 +296,12 @@ test("map search palette flies to a picked geocoding result", async ({
264296 await page . getByTestId ( "map-control-search" ) . click ( ) ;
265297 const searchInput = page . getByTestId ( "geocoding-search-input" ) ;
266298 await expect ( searchInput ) . toBeFocused ( ) ;
299+ await expect ( page . getByTestId ( "map-search-close" ) ) . toHaveCount ( 0 ) ;
300+ await page . keyboard . press ( "Escape" ) ;
301+ await expect ( page . getByTestId ( "map-search-dialog" ) ) . toBeHidden ( ) ;
302+
303+ await page . getByTestId ( "map-control-search" ) . click ( ) ;
304+ await expect ( searchInput ) . toBeFocused ( ) ;
267305 await searchInput . fill ( "Newtown" ) ;
268306 await expect
269307 . poll ( async ( ) =>
0 commit comments