Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions site/src/tests/e2e/cart_drawer_overflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ test.use({ viewport: { width: 420, height: 560 } });
const MANY = Array.from({ length: 40 }, (_, i) => i + 1).join(',');

test('cart drawer footer stays on-screen with a full cart (no overflow)', async ({ page }) => {
// Pre-set the analytics-consent choice so the first-visit consent banner
// never appears — it otherwise overlays the drawer's footer buttons and
// intercepts pointer events on a fresh context.
await page.addInitScript(() => {
try {
localStorage.setItem('ohbm2026.analytics.consent.v1', 'denied');
} catch {
/* storage unavailable — banner will show; not this test's concern */
}
});
Comment on lines +29 to +35

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To make the consent suppression even more robust, we can also set window.__ohbmAnalyticsConsent = 'denied' directly in the init script.

Since ConsentBanner.svelte checks window.__ohbmAnalyticsConsent on mount and suppresses the banner if it is set to 'denied', doing this ensures the banner is successfully blocked even in test environments where localStorage is disabled or throws an error.

Suggested change
await page.addInitScript(() => {
try {
localStorage.setItem('ohbm2026.analytics.consent.v1', 'denied');
} catch {
/* storage unavailable — banner will show; not this test's concern */
}
});
await page.addInitScript(() => {
try {
localStorage.setItem('ohbm2026.analytics.consent.v1', 'denied');
} catch {
/* storage unavailable — banner will show; not this test's concern */
}
(window as any).__ohbmAnalyticsConsent = 'denied';
});

await page.goto(`./?cart=ohbm2026:${MANY}`);
await expect(page.getByTestId('header-cart')).toBeVisible({ timeout: 20_000 });
// Dismiss the first-visit analytics consent banner so it doesn't overlay the
// drawer's footer buttons (it intercepts pointer events on a fresh context).
const consent = page.getByTestId('consent-decline');
if (await consent.isVisible().catch(() => false)) {
await consent.click();
await expect(page.getByTestId('consent-banner')).toHaveCount(0, { timeout: 5_000 });
}

await page.getByTestId('header-cart').click();
await expect(page.getByTestId('cart-drawer')).toBeVisible({ timeout: 5_000 });
Expand Down
Loading