Skip to content

Commit e1d96ac

Browse files
committed
e2e(stencil): align visual snapshots with full-page baseline; wait for hydrated breadcrumb
1 parent 537ed70 commit e1d96ac

File tree

1 file changed

+11
-39
lines changed

1 file changed

+11
-39
lines changed

showcases/e2e/default.ts

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -131,55 +131,27 @@ export const getDefaultScreenshotTest = ({
131131

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

134-
// Prefer scoping to the DBBreadcrumb section/component; for Stencil, target the component/nav explicitly
135-
const byHeadingSection = page
136-
.getByRole('heading', { name: 'DBBreadcrumb', level: 1 })
137-
.locator('xpath=ancestor::section[1]');
138-
134+
// For visual snapshots, compare full-page screenshots to match baselines
139135
const showcaseEnv = process.env.showcase;
140-
let target = byHeadingSection;
141136

142-
try {
143-
await expect(byHeadingSection).toBeVisible({ timeout: 1500 });
144-
} catch {
145-
if (isStencil(showcaseEnv)) {
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', {
149-
name: /breadcrumb/i
150-
});
151-
const wcInSection = byHeadingSection.locator('db-breadcrumb');
152-
const navInSection = byHeadingSection.getByRole('navigation', {
153-
name: /breadcrumb/i
137+
// Ensure Stencil component is hydrated before taking the full-page screenshot
138+
if (isStencil(showcaseEnv)) {
139+
const hydratedBreadcrumb = page.locator('db-breadcrumb.hydrated');
140+
try {
141+
await expect(hydratedBreadcrumb.first()).toBeVisible({
142+
timeout: 5000
154143
});
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();
164-
await expect(target).toBeVisible({ timeout: 3000 });
165-
} else if ((await labeledNavs.count()) > 0) {
166-
target = labeledNavs.first();
167-
await expect(target).toBeVisible({ timeout: 3000 });
168-
} else {
169-
// Fallback to main if component/nav not found
170-
target = page.locator('main');
171-
}
172-
} else {
173-
// Non-breadcrumb showcases: use full main content
174-
target = page.locator('main');
144+
} catch {
145+
// If hydration class not present, wait briefly for stability
146+
await page.waitForTimeout(500);
175147
}
176148
}
177149

178150
if (preScreenShot) {
179151
await preScreenShot(page, project);
180152
}
181153

182-
await expect(target).toHaveScreenshot(config);
154+
await expect(page).toHaveScreenshot(config);
183155
});
184156
};
185157

0 commit comments

Comments
 (0)