|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { resizeHelper } from "../src/utils/pointer-interactions/resizeHelper"; |
| 3 | + |
| 4 | +// High level tests; more nuanced scenarios are covered by unit tests |
| 5 | +test.describe("default layouts", () => { |
| 6 | + test("should not cause layout shift for client components", async ({ |
| 7 | + page |
| 8 | + }) => { |
| 9 | + await page.goto("http://localhost:3012/"); |
| 10 | + await expect(page.getByText("No layout shift")).toBeVisible(); |
| 11 | + |
| 12 | + await resizeHelper(page, ["top", "bottom"], 0, -25); |
| 13 | + await page.waitForTimeout(1000); // Wait for saved layout to be flushed |
| 14 | + |
| 15 | + await page.reload({ waitUntil: "domcontentloaded" }); |
| 16 | + await expect(page.getByText("No layout shift")).toBeVisible(); |
| 17 | + }); |
| 18 | + |
| 19 | + test("should not cause layout shift for server-rendered client components", async ({ |
| 20 | + page |
| 21 | + }) => { |
| 22 | + await page.goto("http://localhost:3011/"); |
| 23 | + await expect(page.getByText("No layout shift")).toBeVisible(); |
| 24 | + |
| 25 | + await resizeHelper(page, ["top", "bottom"], 0, -25); |
| 26 | + await page.waitForTimeout(1000); // Wait for saved layout to be flushed |
| 27 | + |
| 28 | + await page.reload({ waitUntil: "domcontentloaded" }); |
| 29 | + await expect(page.getByText("No layout shift")).toBeVisible(); |
| 30 | + }); |
| 31 | + |
| 32 | + test("should not cause layout shift for server components", async ({ |
| 33 | + page |
| 34 | + }) => { |
| 35 | + await page.goto("http://localhost:3010/"); |
| 36 | + await expect(page.getByText("No layout shift")).toBeVisible(); |
| 37 | + |
| 38 | + await resizeHelper(page, ["top", "bottom"], 0, -25); |
| 39 | + await page.waitForTimeout(1000); // Wait for saved layout to be flushed |
| 40 | + |
| 41 | + await page.reload({ waitUntil: "domcontentloaded" }); |
| 42 | + await expect(page.getByText("No layout shift")).toBeVisible(); |
| 43 | + }); |
| 44 | +}); |
0 commit comments