test(browser): cover scrollintoview

This commit is contained in:
Peter Steinberger
2026-01-12 21:56:10 +00:00
parent 6857f16609
commit fcaeee7073
2 changed files with 29 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ const pwMocks = vi.hoisted(() => ({
fillFormViaPlaywright: vi.fn(async () => {}),
getConsoleMessagesViaPlaywright: vi.fn(async () => []),
hoverViaPlaywright: vi.fn(async () => {}),
scrollIntoViewViaPlaywright: vi.fn(async () => {}),
navigateViaPlaywright: vi.fn(async () => ({ url: "https://example.com" })),
pdfViaPlaywright: vi.fn(async () => ({ buffer: Buffer.from("pdf") })),
pressKeyViaPlaywright: vi.fn(async () => {}),
@@ -416,6 +417,18 @@ describe("browser control server", () => {
ref: "2",
});
const scroll = (await realFetch(`${base}/act`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "scrollIntoView", ref: "2" }),
}).then((r) => r.json())) as { ok: boolean };
expect(scroll.ok).toBe(true);
expect(pwMocks.scrollIntoViewViaPlaywright).toHaveBeenCalledWith({
cdpUrl: cdpBaseUrl,
targetId: "abcd1234",
ref: "2",
});
const drag = (await realFetch(`${base}/act`, {
method: "POST",
headers: { "Content-Type": "application/json" },