@@ -143,16 +143,27 @@ export const getDefaultScreenshotTest = ({
143143 await expect ( byHeadingSection ) . toBeVisible ( { timeout : 1500 } ) ;
144144 } catch {
145145 if ( isStencil ( showcaseEnv ) ) {
146- // In stencil showcase, snapshot the component root or its labeled nav
147- const wcComponent = page . locator ( 'db-breadcrumb' ) ;
148- const labeledNav = page . getByRole ( 'navigation' , {
146+ // In stencil showcase, snapshot the component within the section or its labeled nav
147+ const wcComponents = page . locator ( 'db-breadcrumb' ) ;
148+ const labeledNavs = page . getByRole ( 'navigation' , {
149149 name : / b r e a d c r u m b / i
150150 } ) ;
151- if ( await wcComponent . count ( ) ) {
152- target = wcComponent ;
151+ const wcInSection = byHeadingSection . locator ( 'db-breadcrumb' ) ;
152+ const navInSection = byHeadingSection . getByRole ( 'navigation' , {
153+ name : / b r e a d c r u m b / i
154+ } ) ;
155+
156+ if ( ( await wcInSection . count ( ) ) > 0 ) {
157+ target = wcInSection . first ( ) ;
158+ await expect ( target ) . toBeVisible ( { timeout : 3000 } ) ;
159+ } else if ( ( await navInSection . count ( ) ) > 0 ) {
160+ target = navInSection . first ( ) ;
161+ await expect ( target ) . toBeVisible ( { timeout : 3000 } ) ;
162+ } else if ( ( await wcComponents . count ( ) ) === 1 ) {
163+ target = wcComponents . first ( ) ;
153164 await expect ( target ) . toBeVisible ( { timeout : 3000 } ) ;
154- } else if ( await labeledNav . count ( ) ) {
155- target = labeledNav . first ( ) ;
165+ } else if ( ( await labeledNavs . count ( ) ) > 0 ) {
166+ target = labeledNavs . first ( ) ;
156167 await expect ( target ) . toBeVisible ( { timeout : 3000 } ) ;
157168 } else {
158169 // Fallback to main if component/nav not found
0 commit comments