This commit is contained in:
+24
-3
@@ -2,8 +2,29 @@ import { expect, test } from "@playwright/test";
|
||||
|
||||
test("未登录时显示中文登录入口", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await expect(page.getByText("TallyNote")).toBeVisible();
|
||||
await expect(page.getByLabel("用户名")).toBeVisible();
|
||||
await expect(page.getByLabel("密码")).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "登录到 TallyNote", exact: true })).toBeVisible();
|
||||
await expect(page.locator(".tn-login-header")).toHaveCount(0);
|
||||
await expect(page.getByLabel("用户名", { exact: true })).toBeVisible();
|
||||
await expect(page.getByLabel("密码", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "登录" })).toBeVisible();
|
||||
});
|
||||
|
||||
for (const viewport of [
|
||||
{ width: 320, height: 800 },
|
||||
{ width: 375, height: 812 },
|
||||
{ width: 768, height: 1024 },
|
||||
]) {
|
||||
test(`未登录入口适配 ${viewport.width}px`, async ({ page }) => {
|
||||
await page.setViewportSize(viewport);
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("heading", { name: "登录到 TallyNote", exact: true })).toBeVisible();
|
||||
await expect(page.getByLabel("用户名", { exact: true })).toBeVisible();
|
||||
await expect(page.getByLabel("密码", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "登录" })).toBeVisible();
|
||||
const width = await page.evaluate(() => ({
|
||||
scrollWidth: document.documentElement.scrollWidth,
|
||||
clientWidth: document.documentElement.clientWidth,
|
||||
}));
|
||||
expect(width.scrollWidth).toBeLessThanOrEqual(width.clientWidth);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user