Skip to content

Commit 264473e

Browse files
committed
fix(screenshot): improve handling of DBBreadcrumb section visibility for screenshots
1 parent dea346d commit 264473e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

showcases/e2e/default.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,24 @@ export const getDefaultScreenshotTest = ({
131131

132132
await gotoPage(page, path, lvl1, fixedHeight);
133133

134-
// Target the DBBreadcrumb section to avoid page-level layout noise
134+
// Prefer scoping to the DBBreadcrumb section when present; otherwise fallback to default page
135135
const breadcrumbSection = page
136136
.getByRole('heading', { name: 'DBBreadcrumb', level: 1 })
137137
.locator('xpath=ancestor::section[1]');
138138

139-
// Ensure section is present and stable
140-
await expect(breadcrumbSection).toBeVisible();
139+
let target = breadcrumbSection;
140+
try {
141+
await expect(breadcrumbSection).toBeVisible({ timeout: 2000 });
142+
} catch {
143+
// Breadcrumb section not found for non-breadcrumb showcases; use full main content
144+
target = page.locator('main');
145+
}
141146

142147
if (preScreenShot) {
143148
await preScreenShot(page, project);
144149
}
145150

146-
await expect(breadcrumbSection).toHaveScreenshot(config);
151+
await expect(target).toHaveScreenshot(config);
147152
});
148153
};
149154

0 commit comments

Comments
 (0)