import { expect, test, type Page, type TestInfo } from "@playwright/test"; import { EMPLOYEE, FINANCE, login, logout, type E2EUser } from "./helpers/auth"; const ADMIN: E2EUser = { identifier: "admin@hyinda.com", 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.locator("summary").filter({ hasText: "我的申请与资产 / 继续工作" })).toBeVisible(); await expect(page.getByRole("tab", { name: "公告" })).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"]')).toHaveCount(0); 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.locator("summary").filter({ hasText: "角色重点 / 常用入口" })).toBeVisible(); await expect(page.getByText("试点观测摘要")).toBeVisible(); await expect(page.getByRole("tab", { name: "公告" })).toBeVisible(); await attachScreenshot(page, testInfo, "portal-admin.png"); await logout(page, ADMIN.name); }); test("财务 Portal 显示财务待处理入口", async ({ page }, testInfo) => { await page.setViewportSize({ width: 1440, height: 1200 }); await login(page, FINANCE); await expect(page.getByText("财务工作台")).toBeVisible(); await expect(page.getByText("财务处理")).toBeVisible(); await expect(page.locator("summary").filter({ hasText: "角色重点 / 常用入口" })).toBeVisible(); await attachScreenshot(page, testInfo, "portal-finance.png"); await logout(page, FINANCE.name); }); });