44 行
1.4 KiB
TypeScript
44 行
1.4 KiB
TypeScript
|
|
import { expect, test } from "@playwright/test";
|
|||
|
|
|
|||
|
|
const viewports = [
|
|||
|
|
{ width: 1280, height: 720 },
|
|||
|
|
{ width: 1024, height: 720 },
|
|||
|
|
{ width: 680, height: 720 },
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
for (const viewport of viewports) {
|
|||
|
|
test(`keeps the desktop shell usable at ${viewport.width}px`, async ({
|
|||
|
|
page,
|
|||
|
|
}) => {
|
|||
|
|
await page.setViewportSize(viewport);
|
|||
|
|
await page.goto("/");
|
|||
|
|
|
|||
|
|
await expect(
|
|||
|
|
page.getByText("AstrBot Desktop", { exact: true }).first(),
|
|||
|
|
).toBeVisible();
|
|||
|
|
await expect(page.getByRole("button", { name: /⌁ 聊天/ })).toBeVisible();
|
|||
|
|
|
|||
|
|
const dimensions = (await page.evaluate(
|
|||
|
|
"({ clientWidth: document.documentElement.clientWidth, scrollWidth: document.documentElement.scrollWidth })",
|
|||
|
|
)) as { clientWidth: number; scrollWidth: number };
|
|||
|
|
expect(dimensions.scrollWidth).toBeLessThanOrEqual(
|
|||
|
|
dimensions.clientWidth + 1,
|
|||
|
|
);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
test("keeps page navigation and diagnostic fields accessible", async ({
|
|||
|
|
page,
|
|||
|
|
}) => {
|
|||
|
|
await page.goto("/");
|
|||
|
|
await page.getByRole("button", { name: /诊断与设置/ }).click();
|
|||
|
|
|
|||
|
|
await expect(page.getByText("Rust Core")).toBeVisible();
|
|||
|
|
await expect(page.getByLabel("主机")).toBeVisible();
|
|||
|
|
await expect(page.getByLabel("端口")).toBeVisible();
|
|||
|
|
await expect(page.getByLabel("进程 ID")).toBeVisible();
|
|||
|
|
|
|||
|
|
await page.keyboard.press("Tab");
|
|||
|
|
await expect(page.locator(":focus")).toBeVisible();
|
|||
|
|
});
|