import { expect, test } from "@playwright/test" for (const width of [600, 1024, 1440]) { test(`connection controls stay aligned at ${width}px`, async ({ page }) => { await page.setViewportSize({ width, height: 900 }) await page.goto("/e2e/paas/index.html") const remember = page.getByRole("checkbox", { name: "记住连接(加密保存凭证)" }) await expect(remember).toBeVisible() const geometry = await remember.evaluate((input) => { const label = input.closest("label")! const checkbox = input.getBoundingClientRect() const text = label.querySelector("span")!.getBoundingClientRect() const buttons = [...document.querySelectorAll(".paas-connection-page form button")].map((el) => el.getBoundingClientRect(), ) const panel = document.querySelector(".paas-connection-page")! return { width: checkbox.width, gap: text.left - checkbox.right, aligned: checkbox.top >= text.top && checkbox.bottom <= text.bottom + 1, buttonTop: buttons.map((box) => box.top), overflow: panel.scrollWidth - panel.clientWidth, } }) expect(geometry.width).toBe(16) expect(geometry.gap).toBe(8) expect(geometry.aligned).toBe(true) expect(geometry.buttonTop[0]).toBe(geometry.buttonTop[1]) expect(geometry.overflow).toBeLessThanOrEqual(1) await page.getByText("记住连接(加密保存凭证)", { exact: true }).click() await expect(remember).not.toBeChecked() await remember.focus() await page.keyboard.press("Space") await expect(remember).toBeChecked() }) }