文件
hyb-oa/client/tests/e2e/visual-portal.spec.ts
T

47 行
1.9 KiB
TypeScript

import { expect, test, type Page, type TestInfo } from "@playwright/test";
import { EMPLOYEE, login, logout, type E2EUser } from "./helpers/auth";
const ADMIN: E2EUser = {
identifier: "[email protected]",
password: "AdminPassword1234",
name: "Admin",
};
async function attachScreenshot(page: Page, testInfo: TestInfo, name: string) {
await testInfo.attach(name, {
body: await page.screenshot({ fullPage: true }),
contentType: "image/png",
});
}
test.describe("visual portal", () => {
test("员工 Portal 视觉基线", async ({ page }, testInfo) => {
await page.setViewportSize({ width: 1440, height: 1200 });
await login(page, EMPLOYEE);
await expect(page.locator('[aria-label="portal-card-my_todos"]')).toBeVisible();
await expect(page.locator('[aria-label="portal-card-today_presence"]')).toBeVisible();
await expect(page.locator('[aria-label="portal-card-my_weekly_report"]')).toBeVisible();
await expect(page.locator('[aria-label="portal-card-my_projects"]')).toBeVisible();
await expect(page.getByText("我的申请与资产")).toBeVisible();
await attachScreenshot(page, testInfo, "portal-employee.png");
});
test("管理员 Portal 视觉基线", async ({ page }, testInfo) => {
await page.setViewportSize({ width: 1440, height: 1200 });
await login(page, ADMIN);
await expect(page.locator('[aria-label="portal-card-pending_approvals"]')).toBeVisible();
await expect(page.locator('[aria-label="portal-card-team_presence"]')).toBeVisible();
await expect(page.locator('[aria-label="portal-card-weekly_missing"]')).toBeVisible();
await expect(page.locator('[aria-label="portal-card-weekly_help"]')).toBeVisible();
await expect(page.getByText("今日管理重点")).toBeVisible();
await expect(page.getByText("试点观测摘要")).toBeVisible();
await attachScreenshot(page, testInfo, "portal-admin.png");
await logout(page, ADMIN.name);
});
});