@@ -271,19 +271,35 @@ export const runAriaSnapshotTest = ({
271271
272272 await page . waitForTimeout ( 1000 ) ; // We wait a little bit until everything loaded
273273
274- // Scope snapshot to the DBBreadcrumb section to avoid unrelated page-level landmarks
275- const breadcrumbSection = page
276- . getByRole ( 'heading' , { name : 'DBBreadcrumb' , level : 1 } )
277- . locator ( 'xpath=ancestor::section[1]' ) ;
278-
274+ // Prefer snapshotting only named breadcrumb navigation regions to avoid unlabeled landmarks
279275 let snapshot : string ;
280- try {
281- // If the section exists, snapshot only that region
282- await expect ( breadcrumbSection ) . toBeVisible ( { timeout : 5000 } ) ;
283- snapshot = await breadcrumbSection . ariaSnapshot ( ) ;
284- } catch {
285- // Fallback to the full main snapshot if section resolution fails
286- snapshot = await page . locator ( 'main' ) . ariaSnapshot ( ) ;
276+ const navs = page . getByRole ( 'navigation' ) ;
277+ const count = await navs . count ( ) ;
278+ const indices = Array . from ( { length : count } , ( _ , i ) => i ) ;
279+ const labels = await Promise . all (
280+ indices . map ( async ( i ) => navs . nth ( i ) . getAttribute ( 'aria-label' ) )
281+ ) ;
282+ const breadcrumbIndices = indices . filter ( ( i ) =>
283+ labels [ i ] ?. toLowerCase ( ) ?. includes ( 'breadcrumb' )
284+ ) ;
285+ const parts = await Promise . all (
286+ breadcrumbIndices . map ( async ( i ) => navs . nth ( i ) . ariaSnapshot ( ) )
287+ ) ;
288+
289+ if ( parts . length > 0 ) {
290+ // Join snapshots of all breadcrumb navigations in the page
291+ snapshot = parts . join ( '\n' ) ;
292+ } else {
293+ // Fallback: snapshot the DBBreadcrumb section or main
294+ const breadcrumbSection = page
295+ . getByRole ( 'heading' , { name : 'DBBreadcrumb' , level : 1 } )
296+ . locator ( 'xpath=ancestor::section[1]' ) ;
297+ try {
298+ await expect ( breadcrumbSection ) . toBeVisible ( { timeout : 5000 } ) ;
299+ snapshot = await breadcrumbSection . ariaSnapshot ( ) ;
300+ } catch {
301+ snapshot = await page . locator ( 'main' ) . ariaSnapshot ( ) ;
302+ }
287303 }
288304
289305 // Remove `/url` in snapshot because they differ in every showcase
@@ -299,6 +315,11 @@ export const runAriaSnapshotTest = ({
299315 line = line . replace ( ':' , '' ) ;
300316 }
301317
318+ // Drop unlabeled navigation landmarks appearing as just `- navigation:`
319+ if ( line . trim ( ) === '- navigation:' ) {
320+ return undefined ;
321+ }
322+
302323 return line ;
303324 } )
304325 . filter ( Boolean )
0 commit comments