52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import type { Locator, Page } from "@playwright/test";
|
|
import { test, expect } from "../fixtures/test-base";
|
|
import { AutomationsPage } from "../pages/automations-page";
|
|
|
|
/** Swipe up on a scroll container — the touch equivalent of wheel-down at scroll bottom. */
|
|
async function swipeUpOnElement(page: Page, element: Locator): Promise<void> {
|
|
const box = await element.boundingBox();
|
|
if (!box) throw new Error("scroll container has no bounding box");
|
|
|
|
const cdp = await page.context().newCDPSession(page);
|
|
const centerX = box.x + box.width / 2;
|
|
const startY = box.y + box.height - 20;
|
|
const endY = box.y + 20;
|
|
|
|
await cdp.send("Input.dispatchTouchEvent", {
|
|
type: "touchStart",
|
|
touchPoints: [{ x: centerX, y: startY }],
|
|
});
|
|
for (let i = 1; i <= 8; i++) {
|
|
const y = startY + ((endY - startY) * i) / 8;
|
|
await cdp.send("Input.dispatchTouchEvent", {
|
|
type: "touchMove",
|
|
touchPoints: [{ x: centerX, y }],
|
|
});
|
|
}
|
|
await cdp.send("Input.dispatchTouchEvent", {
|
|
type: "touchEnd",
|
|
touchPoints: [],
|
|
});
|
|
}
|
|
|
|
test.describe("Automations settings on mobile", () => {
|
|
test("create page does not hand off bottom overscroll to the document", async ({
|
|
testPage,
|
|
seedData,
|
|
}) => {
|
|
const automations = new AutomationsPage(testPage, seedData.workspaceId);
|
|
await automations.gotoNew();
|
|
|
|
const settingsScroller = testPage.getByTestId("settings-scroll-container");
|
|
await expect(settingsScroller).toBeVisible();
|
|
await expect(settingsScroller).toHaveCSS("overscroll-behavior-y", "contain");
|
|
|
|
await settingsScroller.evaluate((el) => {
|
|
el.scrollTop = el.scrollHeight;
|
|
});
|
|
await swipeUpOnElement(testPage, settingsScroller);
|
|
|
|
await expect.poll(() => testPage.evaluate(() => window.scrollY), { timeout: 5_000 }).toBe(0);
|
|
});
|
|
});
|