优化详情与移动关键页视觉 Wave3(05-27-pc-detail-mobile-visual-wave3)

这个提交包含在:
2026-05-27 20:41:16 +08:00
父节点 2e9e68e614
当前提交 6e1e00f176
共修改 17 个文件,包含 1194 行新增和 173 行删除
@@ -0,0 +1,666 @@
import { mkdirSync } from "node:fs";
import path from "node:path";
import type { Page, Route } from "@playwright/test";
import { expect, test } from "./helpers/fixtures";
test.use({ serviceWorkers: "block" });
const outputDir = path.resolve(process.cwd(), "../output/playwright/pc-detail-mobile-visual-wave3");
const visualUser = {
identifier: "[email protected]",
password: "VisualWave3Password1234",
name: "王顺理",
};
const visualMe = {
id: "employee-wave3",
employeeNo: "HYD-W3",
name: visualUser.name,
email: visualUser.identifier,
phone: null,
roleCodes: ["employee", "manager", "finance"],
permissions: [
"expense.create",
"expense.submit",
"expense.view_own",
"expense.view_all",
"expense.delete_own",
"expense.approve",
"leave.approve",
"procurement.approve",
"invoice.upload",
"invoice.view_own",
"invoice.manage",
"payment.batch.manage",
"risk.review.manage",
"leave.view_own",
"attendance.view_own",
],
profileCompleteness: {
hasEmergencyContact: true,
hasBankAccount: true,
hasAvatar: false,
hasIdNumber: false,
score: 88,
},
notificationPushEnabled: true,
departmentId: "dept-wave3",
};
const workflowTask = {
id: "task-wave3",
instanceId: "workflow-wave3",
stepId: "manager-review",
stepName: "主管审批",
assigneeId: visualMe.id,
assigneeRole: "manager",
status: "pending",
outcome: null,
createdAt: "2026-05-27T09:05:00.000Z",
completedAt: null,
workflowInstance: {
entityType: "reimbursement",
entityId: "reim-wave3",
currentStatus: "reviewing",
},
businessSummary: {
reference: "BX20260527003",
title: "项目差旅资料补充",
applicantName: "李明",
amount: "¥1,860.00",
duration: null,
businessStatus: "reviewing",
},
allowedActions: ["approve", "reject", "return", "transfer"],
};
const reimbursementDetail = {
id: "reim-wave3",
formNumber: "BX20260527003",
submitterId: visualMe.id,
ownerId: visualMe.id,
departmentId: "dept-wave3",
department: { id: "dept-wave3", name: "研发部" },
status: "reviewing",
createdAt: "2026-05-27T08:50:00.000Z",
submittedAt: "2026-05-27T09:00:00.000Z",
reimbursementDate: "2026-05-27",
totalAmount: "1860.00",
description: "项目现场资料与交通报销",
payment: {
paymentVoucherNo: null,
paymentDate: null,
paymentChannel: null,
paidAt: null,
paidBy: null,
},
projectId: "project-wave3",
linkedTravelRequestId: null,
linkedTravelRequest: null,
project: { id: "project-wave3", projectNo: "HYB-W3", name: "OA 试运行" },
owner: { id: visualMe.id, employee_no: visualMe.employeeNo, name: visualMe.name },
submitter: { id: visualMe.id, employee_no: visualMe.employeeNo, name: visualMe.name },
invoices: [
{
id: "invoice-wave3",
status: "available",
invoiceCode: "0440026",
invoiceNumber: "00012890",
invoiceDate: "2026-05-26",
sellerName: "北京示例服务有限公司",
totalAmount: "860.00",
originalName: "invoice-wave3.pdf",
linkedItemId: "item-wave3-1",
},
],
attachments: [
{
id: "att-wave3",
originalName: "现场说明.pdf",
mimeType: "application/pdf",
fileSize: 128000,
fileSha256: "hash-wave3",
uploadedBy: { id: visualMe.id, name: visualMe.name, employeeNo: visualMe.employeeNo },
createdAt: "2026-05-27T09:10:00.000Z",
},
],
budgetHint: null,
pendingWorkflow: {
instanceId: "workflow-wave3",
stepId: "manager-review",
task: {
id: "task-wave3",
step_name: "主管审批",
assignee_id: visualMe.id,
assignee_role: "manager",
},
},
workflowProgress: {
currentStepIndex: 0,
totalSteps: 2,
steps: [
{ id: "step-1", name: "主管审批", status: "current" },
{ id: "step-2", name: "财务复核", status: "pending" },
],
},
approvalHistory: [
{
id: "history-wave3-1",
stepName: "提交",
action: "start",
actorName: visualMe.name,
comment: "请审批",
createdAt: "2026-05-27T09:00:00.000Z",
},
],
riskFlags: [],
items: [
{
id: "item-wave3-1",
expenseTypeId: "expense-travel",
expenseDate: "2026-05-26",
amount: "860.00",
description: "交通与资料",
expenseType: {
id: "expense-travel",
code: "TRAVEL",
name: "交通费",
category: "travel",
enabled: true,
},
},
{
id: "item-wave3-2",
expenseTypeId: "expense-service",
expenseDate: "2026-05-27",
amount: "1000.00",
description: "现场服务",
expenseType: {
id: "expense-service",
code: "SERVICE",
name: "服务费",
category: "service",
enabled: true,
},
},
],
};
const workflowDetail = {
task: {
id: workflowTask.id,
instanceId: workflowTask.instanceId,
stepId: workflowTask.stepId,
stepName: workflowTask.stepName,
assigneeId: workflowTask.assigneeId,
assigneeRole: workflowTask.assigneeRole,
status: workflowTask.status,
outcome: null,
comment: null,
createdAt: workflowTask.createdAt,
completedAt: null,
},
workflowInstance: {
id: "workflow-wave3",
entityType: "reimbursement",
currentStatus: "reviewing",
currentStepId: "manager-review",
contextData: { standardViolations: [] },
startedAt: "2026-05-27T09:00:00.000Z",
completedAt: null,
},
reimbursement: {
id: reimbursementDetail.id,
formNumber: reimbursementDetail.formNumber,
status: reimbursementDetail.status,
reimbursementDate: reimbursementDetail.reimbursementDate,
totalAmount: reimbursementDetail.totalAmount,
description: reimbursementDetail.description,
owner: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
submitter: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
},
leaveRequest: null,
attendanceCorrection: null,
purchaseRequest: null,
travelRequest: null,
allowedActions: workflowTask.allowedActions,
history: [
{
id: "workflow-history-wave3",
taskId: workflowTask.id,
actorId: visualMe.id,
actorName: visualMe.name,
actorEmployeeNo: visualMe.employeeNo,
action: "start",
comment: "进入审批",
payload: null,
createdAt: "2026-05-27T09:00:00.000Z",
},
],
};
const notifications = [
{
id: "notification-wave3-1",
type: "workflow.task_assigned",
title: "你有新的报销审批",
body: "BX20260527003 等待主管审批",
targetType: "workflow_task",
targetId: workflowTask.id,
readAt: null,
createdAt: "2026-05-27T09:12:00.000Z",
},
{
id: "notification-wave3-2",
type: "reimbursement.approved",
title: "报销已通过",
body: "项目资料报销进入财务复核",
targetType: "reimbursement",
targetId: reimbursementDetail.id,
readAt: "2026-05-27T09:20:00.000Z",
createdAt: "2026-05-27T09:18:00.000Z",
},
];
function envelope<T>(data: T) {
return { requestId: "mock-wave3", data };
}
async function fulfillJson<T>(route: Route, data: T) {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(envelope(data)),
});
}
function screenshotPath(fileName: string) {
mkdirSync(outputDir, { recursive: true });
return path.join(outputDir, fileName);
}
function navigationItem(key: string, href: string, label: string, icon: string, placement = "main") {
return { key, href, label, icon, placement, permissionCodes: [], featureFlagKey: null };
}
async function mockWave3Apis(page: Page) {
await page.route((url) => url.pathname.startsWith("/api/"), async (route) => {
const request = route.request();
const url = new URL(request.url());
const pathName = url.pathname;
if (pathName === "/api/auth/capabilities") {
await fulfillJson(route, {
emailDelivery: { ready: true, statusReasons: [] },
emailLoginCode: { enabled: true },
passwordReset: { enabled: true },
});
return;
}
if (pathName === "/api/auth/sso/providers") {
await fulfillJson(route, []);
return;
}
if (pathName === "/api/auth/wecom/config") {
await fulfillJson(route, {
enabled: true,
entryEnabled: true,
oauthEnabled: true,
corpId: "wx-wave3",
agentId: "1000002",
loginUrl: "/api/auth/wecom/login?returnTo=%2Fmobile",
bindEnabled: true,
defaultReturnTo: "/mobile",
status: "ready",
statusReasons: [],
});
return;
}
if (pathName === "/api/auth/login" || pathName === "/api/auth/refresh") {
await route.fulfill({
status: 200,
contentType: "application/json",
headers: { "set-cookie": "has_session=1; Path=/; SameSite=Lax" },
body: JSON.stringify(envelope({ accessToken: "mock-wave3-token", expiresIn: 900, mustChangePassword: false })),
});
return;
}
if (pathName === "/api/me") {
await fulfillJson(route, visualMe);
return;
}
if (pathName === "/api/system/navigation") {
await fulfillJson(route, {
workspace: {
id: "workspace-wave3",
persisted: true,
profile: "small_team_internal",
orgMode: "single_company",
primaryEntryMode: "password",
notificationStrategy: "in_app",
devicePriority: "desktop",
moduleVisibility: {},
createdAt: null,
updatedAt: null,
updatedBy: null,
},
sections: {
main: [
navigationItem("portal", "/portal", "工作台", "home_app_logo"),
navigationItem("workflow", "/workflow/tasks", "审批待办", "fact_check"),
navigationItem("expense", "/reimbursements", "报销", "request_quote"),
navigationItem("notifications", "/notifications", "通知", "notifications"),
],
admin: [],
backup: [],
},
recommendedRolePresets: [],
});
return;
}
if (pathName === "/api/notifications/mark-all-read") {
await fulfillJson(route, { updatedCount: 1 });
return;
}
if (pathName.startsWith("/api/notifications/") && pathName.endsWith("/mark-read")) {
await fulfillJson(route, { id: pathName.split("/")[3], readAt: "2026-05-27T09:30:00.000Z" });
return;
}
if (pathName === "/api/notifications") {
const unreadOnly = url.searchParams.get("unreadOnly") === "1";
const items = unreadOnly ? notifications.filter((item) => !item.readAt) : notifications;
await fulfillJson(route, {
page: Number(url.searchParams.get("page") ?? 1),
pageSize: Number(url.searchParams.get("pageSize") ?? 20),
total: items.length,
unreadOnly,
unreadCount: notifications.filter((item) => !item.readAt).length,
items,
});
return;
}
if (pathName === "/api/reimbursements/reim-wave3") {
await fulfillJson(route, reimbursementDetail);
return;
}
if (pathName === "/api/reimbursements") {
await fulfillJson(route, {
page: 1,
pageSize: Number(url.searchParams.get("pageSize") ?? 20),
total: 2,
scope: url.searchParams.get("scope") ?? "own",
items: [
{
id: reimbursementDetail.id,
formNumber: reimbursementDetail.formNumber,
status: reimbursementDetail.status,
reimbursementDate: reimbursementDetail.reimbursementDate,
totalAmount: reimbursementDetail.totalAmount,
description: reimbursementDetail.description,
payment: reimbursementDetail.payment,
owner: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
submitter: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
project: reimbursementDetail.project,
pendingWorkflow: {
instanceId: "workflow-wave3",
stepId: "manager-review",
allowedActions: ["approve", "reject"],
task: { id: workflowTask.id, stepName: "主管审批", assigneeId: visualMe.id, assigneeRole: "manager" },
},
createdAt: reimbursementDetail.createdAt,
updatedAt: "2026-05-27T09:20:00.000Z",
},
],
});
return;
}
if (pathName === "/api/expense-types") {
await fulfillJson(route, {
enabled: true,
items: [
{
id: "expense-travel",
code: "TRAVEL",
name: "交通费",
description: null,
category: "travel",
sortOrder: 1,
accountCodeDefault: null,
isSystemDefault: true,
enabled: true,
createdAt: null,
updatedAt: null,
},
],
});
return;
}
if (pathName === "/api/projects") {
await fulfillJson(route, { items: [reimbursementDetail.project] });
return;
}
if (pathName === "/api/workflow/tasks/summary") {
await fulfillJson(route, {
scope: "mine",
pendingTotal: 1,
overdueTotal: 0,
earliestPendingAt: workflowTask.createdAt,
averagePendingAgeHours: 1,
byEntityType: [{ key: "reimbursement", pendingTotal: 1, overdueTotal: 0 }],
byStep: [{ key: "主管审批", pendingTotal: 1, overdueTotal: 0 }],
byAssigneeRole: [{ key: "manager", pendingTotal: 1, overdueTotal: 0 }],
});
return;
}
if (pathName === "/api/workflow/tasks/task-wave3") {
await fulfillJson(route, workflowDetail);
return;
}
if (pathName === "/api/workflow/tasks") {
await fulfillJson(route, {
page: 1,
pageSize: Number(url.searchParams.get("pageSize") ?? 100),
total: 1,
items: [workflowTask],
});
return;
}
if (pathName === "/api/workflow/approvers") {
await fulfillJson(route, {
page: 1,
pageSize: 50,
total: 1,
items: [
{
id: "approver-wave3",
employeeNo: "HYD-A1",
name: "审批人",
email: "[email protected]",
roleCodes: ["manager"],
},
],
});
return;
}
if (pathName === "/api/portal/home") {
await fulfillJson(route, {
workspace: { id: "workspace-wave3", persisted: true, profile: "small_team_internal" },
greeting: { name: visualMe.name },
cards: [],
pendingTasks: { count: 1, href: "/workflow/tasks" },
myApplications: [],
riskSummary: null,
announcements: [],
quickLinks: [],
todayPresence: null,
teamPresence: null,
weeklyReport: null,
weeklySummary: null,
todoSummary: null,
projectSummary: null,
peopleLifecycle: null,
financeSummary: {
pendingBatchCount: 2,
failedItemCount: 0,
riskCount: 1,
paymentBatchEnabled: true,
href: "/payment-batches",
},
adoptionSummary: null,
recentActivities: [],
teamStatusBoard: [],
});
return;
}
if (pathName === "/api/leave-requests") {
await fulfillJson(route, { page: 1, pageSize: 8, total: 0, scope: "own", items: [] });
return;
}
if (pathName === "/api/purchase-requests") {
await fulfillJson(route, { page: 1, pageSize: 8, total: 0, items: [] });
return;
}
if (pathName === "/api/employees/employee-wave3/profile") {
await fulfillJson(route, {
employee: {
id: visualMe.id,
employeeNo: visualMe.employeeNo,
name: visualMe.name,
phone: "",
email: visualMe.email,
status: "active",
employmentStatus: "active",
departmentId: "dept-wave3",
title: "项目经理",
directManagerId: null,
hireDate: "2026-01-01",
probationEndDate: null,
lastWorkingDate: null,
workLocation: "北京",
emergencyContactName: null,
emergencyContactPhone: null,
notes: null,
avatarUrl: null,
archivedAt: null,
roleCodes: visualMe.roleCodes,
department: { id: "dept-wave3", name: "研发部" },
directManager: null,
},
lifecycle: { events: [], checklistTasks: [], blockers: { openAssetCount: 0, pendingWorkflowTaskCount: 0, canCompleteOffboarding: true } },
assignedAssets: [],
organization: { reportingChain: [], directReports: [] },
});
return;
}
await fulfillJson(route, {});
});
}
async function login(page: Page) {
await page.goto("/login");
await page.getByTestId("login-identifier").fill(visualUser.identifier);
await page.getByTestId("login-password").fill(visualUser.password);
await page.getByTestId("login-submit").click();
await page.waitForURL(/\/(portal|mobile)/);
await page.waitForLoadState("networkidle").catch(() => undefined);
}
async function expectNoHorizontalOverflow(page: Page) {
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
expect(overflow).toBeLessThanOrEqual(2);
}
test.beforeEach(async ({ page }) => {
await mockWave3Apis(page);
await login(page);
});
test("Wave3 PC 详情和通知中心视觉截图", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 960 });
await page.goto("/reimbursements/reim-wave3");
await expect(page.getByRole("heading", { name: /报销详情/ })).toBeVisible();
await expect(page.getByText("办理摘要")).toBeVisible();
await expect(page.getByTestId("reimbursement-payment-status")).toBeVisible();
await page.screenshot({ path: screenshotPath("01-pc-reimbursement-detail.png"), fullPage: true });
await page.goto("/workflow/tasks/task-wave3");
await expect(page.getByRole("heading", { name: /任务详情/ })).toBeVisible();
await expect(page.getByText("审批动作")).toBeVisible();
await expect(page.getByTestId("workflow-task-overview")).toBeVisible();
await page.screenshot({ path: screenshotPath("02-pc-workflow-detail.png"), fullPage: true });
await page.goto("/notifications");
await expect(page.getByRole("heading", { name: "通知" })).toBeVisible();
await expect(page.getByTestId("notification-row").first()).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await page.screenshot({ path: screenshotPath("03-pc-notifications.png"), fullPage: true });
});
test("Wave3 移动关键页视觉截图", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/mobile");
await expect(page.getByRole("heading", { name: "今天待办" })).toBeVisible();
await expect(page.getByTestId("mobile-action-grid")).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await expectNoHorizontalOverflow(page);
await page.screenshot({ path: screenshotPath("04-mobile-home.png"), fullPage: true });
await page.goto("/mobile/reimbursements");
await expect(page.getByRole("heading", { name: "移动报销" })).toBeVisible();
await expect(page.getByTestId("mobile-reimbursements-list")).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await expectNoHorizontalOverflow(page);
await page.screenshot({ path: screenshotPath("05-mobile-reimbursements.png"), fullPage: true });
await page.goto("/mobile/approvals");
await expect(page.getByRole("heading", { name: "审批", exact: true })).toBeVisible();
await expect(page.getByTestId("mobile-approvals-list")).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await expectNoHorizontalOverflow(page);
await page.screenshot({ path: screenshotPath("06-mobile-approvals.png"), fullPage: true });
await page.goto("/mobile/approvals/task-wave3");
await expect(page.getByTestId("mobile-approvals-detail")).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await expectNoHorizontalOverflow(page);
await page.screenshot({ path: screenshotPath("07-mobile-approval-detail.png"), fullPage: true });
await page.goto("/mobile/notifications");
await expect(page.getByTestId("mobile-notifications-list")).toBeVisible();
await expect(page.getByTestId("mobile-notification-card").first()).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await expectNoHorizontalOverflow(page);
await page.screenshot({ path: screenshotPath("08-mobile-notifications.png"), fullPage: true });
await page.goto("/mobile/me");
await expect(page.getByRole("heading", { name: "我的" })).toBeVisible();
await expect(page.getByTestId("mobile-more-links")).toBeVisible();
await expect(page.locator("table")).toHaveCount(0);
await expectNoHorizontalOverflow(page);
await page.screenshot({ path: screenshotPath("09-mobile-me.png"), fullPage: true });
});