test(app): reproduce settings sidebar scroll reset on section select (#1532)

Selecting a settings section mounts a new settings screen, so the
desktop sidebar's scroll body starts again at offset 0. This test
scrolls the sidebar to its end and selects two host sections; it fails
on main with the offset dropping from 236 to 0.
This commit is contained in:
paseo-bot[bot]
2026-10-04 09:36:03 +02:00
parent 8216e86ecb
commit 0c1b4e7898
2 changed files with 37 additions and 0 deletions
@@ -40,6 +40,8 @@ import {
expectSettingsHostPickerLabel,
openSettingsHostSection,
removeCurrentHostFromSettings,
scrollSettingsSidebarToEnd,
expectSettingsSidebarScrollOffset,
} from "../support/helpers/settings";
import { getServerId } from "../support/helpers/server-id";
import { expectAppRoute } from "../support/helpers/route-assertions";
@@ -77,6 +79,23 @@ test.describe("Settings sidebar navigation", () => {
await expect(page).not.toHaveURL(/\/settings(\/|$)/);
});
test.describe("in a short window", () => {
test.use({ viewport: { width: 1280, height: 480 } });
test("selecting a section keeps the sidebar scroll position", async ({ page }) => {
const serverId = getServerId();
await gotoAppShell(page);
await openSettings(page);
const offset = await scrollSettingsSidebarToEnd(page);
await openSettingsHostSection(page, serverId, "plugins");
await expectSettingsSidebarScrollOffset(page, offset);
await openSettingsHostSection(page, serverId, "terminals");
await expectSettingsSidebarScrollOffset(page, offset);
});
});
test("/h/[serverId]/settings redirects to the host connections section", async ({ page }) => {
await gotoAppShell(page);
await verifyLegacyHostSettingsRedirect(page);
@@ -453,3 +453,21 @@ export async function expectHostOnlineWithoutError(page: Page): Promise<void> {
await expect(page.getByTestId("host-page-identity")).toContainText("Online");
await expect(page.getByTestId("host-connection-error")).toHaveCount(0);
}
export async function scrollSettingsSidebarToEnd(page: Page): Promise<number> {
const scrollBody = page.getByTestId("settings-sidebar-scroll-body");
await expect(scrollBody).toBeVisible();
await scrollBody.hover();
await page.mouse.wheel(0, 10_000);
const readOffset = () => scrollBody.evaluate((node) => node.scrollTop);
await expect
.poll(readOffset, { message: "settings sidebar must overflow for this check" })
.toBeGreaterThan(0);
await expect.poll(async () => (await readOffset()) - (await readOffset())).toBe(0);
return readOffset();
}
export async function expectSettingsSidebarScrollOffset(page: Page, offset: number): Promise<void> {
const scrollBody = page.getByTestId("settings-sidebar-scroll-body");
await expect.poll(() => scrollBody.evaluate((node) => node.scrollTop)).toBe(offset);
}