Skip to content

Commit f484da9

Browse files
committed
test(e2e): adds scrollbar compensation test and scopes footer selector
1 parent 0c9a282 commit f484da9

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

e2e/smoke.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,36 @@ test("switching tabs changes active tab indicator", async ({ page }) => {
165165
await expect(actionsTab).toHaveAttribute("aria-selected", "true");
166166
});
167167

168+
test("fixed elements compensate for scrollbar width when scroll is locked", async ({ page }) => {
169+
await setupAuth(page);
170+
await page.goto("/dashboard");
171+
172+
const navbar = page.locator(".navbar");
173+
const footer = page.locator(".app-footer");
174+
await expect(navbar).toBeVisible();
175+
await expect(footer).toBeVisible();
176+
177+
// Baseline: navbar 0.5rem (8px) from daisyUI, footer 0px (no base padding)
178+
expect(parseFloat(await navbar.evaluate((el) => getComputedStyle(el).paddingRight))).toBeCloseTo(8, 0);
179+
expect(parseFloat(await footer.evaluate((el) => getComputedStyle(el).paddingRight))).toBeCloseTo(0, 0);
180+
181+
// Simulate solid-prevent-scroll setting --scrollbar-width on body
182+
await page.evaluate(() => {
183+
document.body.style.setProperty("--scrollbar-width", "15px");
184+
});
185+
186+
// Navbar: 8px + 15px = 23px, footer: 0px + 15px = 15px
187+
expect(parseFloat(await navbar.evaluate((el) => getComputedStyle(el).paddingRight))).toBeCloseTo(23, 0);
188+
expect(parseFloat(await footer.evaluate((el) => getComputedStyle(el).paddingRight))).toBeCloseTo(15, 0);
189+
190+
// Clear — both return to baseline
191+
await page.evaluate(() => {
192+
document.body.style.removeProperty("--scrollbar-width");
193+
});
194+
expect(parseFloat(await navbar.evaluate((el) => getComputedStyle(el).paddingRight))).toBeCloseTo(8, 0);
195+
expect(parseFloat(await footer.evaluate((el) => getComputedStyle(el).paddingRight))).toBeCloseTo(0, 0);
196+
});
197+
168198
test("dashboard shows empty state with no data", async ({ page }) => {
169199
await setupAuth(page);
170200
await page.goto("/dashboard");

src/app/components/dashboard/DashboardPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export default function DashboardPage() {
428428
</main>
429429
</div>
430430

431-
<footer class="fixed bottom-0 left-0 right-0 z-30 border-t border-base-300 bg-base-100 py-3 text-xs text-base-content/50">
431+
<footer class="app-footer fixed bottom-0 left-0 right-0 z-30 border-t border-base-300 bg-base-100 py-3 text-xs text-base-content/50">
432432
<div class="max-w-6xl mx-auto w-full px-4 grid grid-cols-3 items-center">
433433
<div />
434434
<div class="flex items-center justify-center gap-3">

src/app/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
.navbar {
115115
padding-right: calc(0.5rem + var(--scrollbar-width, 0px));
116116
}
117-
footer {
117+
.app-footer {
118118
padding-right: var(--scrollbar-width, 0px);
119119
}
120120

0 commit comments

Comments
 (0)