1179 行
38 KiB
TypeScript
1179 行
38 KiB
TypeScript
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",
|
|
},
|
|
];
|
|
|
|
const projectDetail = {
|
|
id: "project-wave3",
|
|
projectNo: "HYB-W3",
|
|
name: "OA 试运行",
|
|
clientName: "海音达内部",
|
|
clientAlias: "海音达",
|
|
ownerEmployeeId: visualMe.id,
|
|
managerEmployeeId: visualMe.id,
|
|
status: "active",
|
|
startsAt: "2026-05-20",
|
|
targetEndAt: "2026-06-03",
|
|
actualEndAt: null,
|
|
summary: "真实试运行阶段,重点验证审批、报销、合同台账和移动入口。",
|
|
isConfidential: true,
|
|
createdAt: "2026-05-20T09:00:00.000Z",
|
|
updatedAt: "2026-05-27T09:30:00.000Z",
|
|
owner: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
manager: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
counts: {
|
|
members: 2,
|
|
milestones: 2,
|
|
tasks: 3,
|
|
risks: 1,
|
|
reimbursements: 1,
|
|
purchaseRequests: 1,
|
|
travelRequests: 0,
|
|
todoItems: 2,
|
|
weeklyReports: 1,
|
|
communicationLogs: 1,
|
|
closureChecklistItems: 3,
|
|
contracts: 1,
|
|
deliveries: 1,
|
|
documentRefs: 1,
|
|
},
|
|
members: [
|
|
{
|
|
id: "member-wave3",
|
|
employeeId: visualMe.id,
|
|
role: "manager",
|
|
joinedAt: "2026-05-20",
|
|
leftAt: null,
|
|
employee: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
},
|
|
],
|
|
milestones: [
|
|
{
|
|
id: "milestone-wave3",
|
|
title: "公网试运行准备",
|
|
description: null,
|
|
status: "in_progress",
|
|
dueDate: "2026-05-29",
|
|
completedAt: null,
|
|
ownerEmployeeId: visualMe.id,
|
|
sortOrder: 1,
|
|
},
|
|
],
|
|
tasks: [
|
|
{
|
|
id: "project-task-wave3",
|
|
title: "整理试运行反馈",
|
|
description: "跟进移动端和合同台账反馈",
|
|
status: "doing",
|
|
priority: "high",
|
|
assigneeEmployeeId: visualMe.id,
|
|
dueDate: "2026-05-30",
|
|
blockedReason: null,
|
|
createdBy: visualMe.id,
|
|
assignee: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
creator: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
createdAt: "2026-05-27T09:00:00.000Z",
|
|
updatedAt: "2026-05-27T09:10:00.000Z",
|
|
},
|
|
],
|
|
risks: [
|
|
{
|
|
id: "risk-wave3",
|
|
title: "移动端首屏信息过多",
|
|
detail: "需要保持办理摘要和主要动作优先。",
|
|
level: "medium",
|
|
status: "monitoring",
|
|
ownerEmployeeId: visualMe.id,
|
|
owner: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
createdAt: "2026-05-27T09:00:00.000Z",
|
|
updatedAt: "2026-05-27T09:00:00.000Z",
|
|
},
|
|
],
|
|
communicationSummary: {
|
|
totalCount: 1,
|
|
latestHappenedAt: "2026-05-27T10:00:00.000Z",
|
|
followUpDueTodayCount: 1,
|
|
overdueFollowUpCount: 0,
|
|
},
|
|
closureSummary: {
|
|
totalCount: 3,
|
|
pendingCount: 1,
|
|
waivedCount: 0,
|
|
warned: true,
|
|
facts: {
|
|
openRiskCount: 1,
|
|
openReimbursementCount: 1,
|
|
openTravelCount: 0,
|
|
deliveryRecordCount: 1,
|
|
contractCount: 1,
|
|
confidentialDocRefCount: 1,
|
|
},
|
|
},
|
|
capabilities: {
|
|
communicationLogEnabled: true,
|
|
closureChecklistEnabled: true,
|
|
},
|
|
};
|
|
|
|
const contractRegistryItem = {
|
|
id: "contract-wave3",
|
|
contractNo: "HT-2026-W3",
|
|
projectId: projectDetail.id,
|
|
contractType: "service",
|
|
counterpartyName: "北京示例服务有限公司",
|
|
summary: "OA 试运行服务协议台账摘要",
|
|
amount: "30000.00",
|
|
currency: "CNY",
|
|
signedDate: "2026-05-20",
|
|
effectiveDate: "2026-05-21",
|
|
expiryDate: "2026-06-20",
|
|
confidentialityLevel: "internal",
|
|
archiveLocation: "离线档案柜 A-01",
|
|
offlineArchiveNo: "OFF-2026-W3",
|
|
ownerEmployeeId: visualMe.id,
|
|
status: "active",
|
|
persistedStatus: "active",
|
|
createdAt: "2026-05-20T09:00:00.000Z",
|
|
updatedAt: "2026-05-27T09:00:00.000Z",
|
|
owner: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
project: { id: projectDetail.id, projectNo: projectDetail.projectNo, name: projectDetail.name },
|
|
};
|
|
|
|
const purchaseDetail = {
|
|
id: "purchase-wave3",
|
|
requestNo: "CG20260527001",
|
|
applicantId: visualMe.id,
|
|
submitterId: visualMe.id,
|
|
departmentId: "dept-wave3",
|
|
legalEntityId: "legal-wave3",
|
|
costCenterId: "cost-wave3",
|
|
supplierId: "supplier-wave3",
|
|
documentCategoryId: "category-wave3",
|
|
budgetPoolId: "budget-wave3",
|
|
projectId: projectDetail.id,
|
|
title: "试运行办公物料采购",
|
|
reason: "补齐试运行期间需要的标签纸和档案用品。",
|
|
currencyCode: "CNY",
|
|
totalAmount: "1280.00",
|
|
expectedDeliveryDate: "2026-05-30",
|
|
status: "reviewing",
|
|
createdAt: "2026-05-27T08:30:00.000Z",
|
|
updatedAt: "2026-05-27T09:30:00.000Z",
|
|
applicant: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
submitter: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
department: { id: "dept-wave3", name: "研发部" },
|
|
legalEntity: { id: "legal-wave3", code: "HYD", name: "海音达" },
|
|
costCenter: { id: "cost-wave3", code: "RD", name: "研发中心", legalEntityId: "legal-wave3" },
|
|
supplier: { id: "supplier-wave3", code: "SUP-W3", name: "北京示例服务有限公司" },
|
|
documentCategory: { id: "category-wave3", code: "OFFICE", name: "办公用品", entityType: "purchase_request" },
|
|
budgetPool: { id: "budget-wave3", code: "OPS", name: "运营预算" },
|
|
project: { id: projectDetail.id, projectNo: projectDetail.projectNo, name: projectDetail.name, status: projectDetail.status },
|
|
items: [
|
|
{
|
|
id: "purchase-item-wave3",
|
|
description: "档案标签纸",
|
|
specification: "A4 / 100 张",
|
|
quantity: "2",
|
|
unitPrice: "640.00",
|
|
lineAmount: "1280.00",
|
|
isAssetCandidate: false,
|
|
createdAt: "2026-05-27T08:30:00.000Z",
|
|
updatedAt: "2026-05-27T08:30:00.000Z",
|
|
},
|
|
],
|
|
attachments: [
|
|
{
|
|
id: "purchase-att-wave3",
|
|
originalName: "采购说明.pdf",
|
|
mimeType: "application/pdf",
|
|
fileSize: 64000,
|
|
fileSha256: "purchase-hash-wave3",
|
|
uploadedBy: visualMe.id,
|
|
createdAt: "2026-05-27T08:40:00.000Z",
|
|
uploader: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
governanceStatus: "approved",
|
|
sensitivityLevel: "internal",
|
|
attachmentType: "supporting_material",
|
|
downloadPolicy: "reason_required",
|
|
reviewedBy: visualMe.id,
|
|
reviewedAt: "2026-05-27T08:50:00.000Z",
|
|
reviewNote: "已复核",
|
|
archivedBy: null,
|
|
archivedAt: null,
|
|
archiveNote: null,
|
|
},
|
|
],
|
|
pendingWorkflow: {
|
|
instanceId: "workflow-purchase-wave3",
|
|
currentStatus: "reviewing",
|
|
currentStepId: "manager-review",
|
|
task: {
|
|
id: "task-purchase-wave3",
|
|
stepId: "manager-review",
|
|
stepName: "主管审批",
|
|
assigneeId: visualMe.id,
|
|
assigneeRole: "manager",
|
|
},
|
|
},
|
|
approvalHistory: [
|
|
{
|
|
id: "purchase-history-wave3",
|
|
taskId: "task-purchase-wave3",
|
|
actorId: visualMe.id,
|
|
actorName: visualMe.name,
|
|
actorEmployeeNo: visualMe.employeeNo,
|
|
action: "submit",
|
|
comment: "请审批",
|
|
createdAt: "2026-05-27T09:00:00.000Z",
|
|
},
|
|
],
|
|
archiveOrder: null,
|
|
permissions: { canEditDraft: false, canSubmit: false, canWithdraw: false, canArchiveOrder: false },
|
|
riskFlags: [],
|
|
};
|
|
|
|
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/project-wave3") {
|
|
await fulfillJson(route, { item: projectDetail });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/members") {
|
|
await fulfillJson(route, { items: projectDetail.members });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/milestones") {
|
|
await fulfillJson(route, { items: projectDetail.milestones });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/tasks") {
|
|
await fulfillJson(route, { items: projectDetail.tasks });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/risks") {
|
|
await fulfillJson(route, { items: projectDetail.risks });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/expenses/summary") {
|
|
await fulfillJson(route, {
|
|
totalAmount: reimbursementDetail.totalAmount,
|
|
items: [
|
|
{
|
|
id: reimbursementDetail.id,
|
|
formNumber: reimbursementDetail.formNumber,
|
|
status: reimbursementDetail.status,
|
|
totalAmount: reimbursementDetail.totalAmount,
|
|
reimbursementDate: reimbursementDetail.reimbursementDate,
|
|
updatedAt: "2026-05-27T09:20:00.000Z",
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/travel/summary") {
|
|
await fulfillJson(route, { totalAmount: "0.00", items: [] });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/purchase-requests/summary") {
|
|
await fulfillJson(route, {
|
|
totalAmount: purchaseDetail.totalAmount,
|
|
items: [
|
|
{
|
|
id: purchaseDetail.id,
|
|
requestNo: purchaseDetail.requestNo,
|
|
title: purchaseDetail.title,
|
|
status: purchaseDetail.status,
|
|
totalAmount: purchaseDetail.totalAmount,
|
|
updatedAt: purchaseDetail.updatedAt,
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/weekly-reports") {
|
|
await fulfillJson(route, {
|
|
items: [
|
|
{
|
|
id: "weekly-link-wave3",
|
|
weeklyReportId: "weekly-wave3",
|
|
weekStart: "2026-05-25",
|
|
status: "submitted",
|
|
employee: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
progressText: "完成 Wave3 视觉复核",
|
|
riskText: null,
|
|
nextStepText: "继续公网验证",
|
|
updatedAt: "2026-05-27T09:20:00.000Z",
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/deliveries") {
|
|
await fulfillJson(route, {
|
|
items: [
|
|
{
|
|
id: "delivery-wave3",
|
|
title: "试运行准备记录",
|
|
recordType: "stage_acceptance",
|
|
summary: "完成页面体验基线复核。",
|
|
occurredAt: "2026-05-27",
|
|
owner: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
createdAt: "2026-05-27T09:20:00.000Z",
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/document-refs") {
|
|
await fulfillJson(route, {
|
|
items: [
|
|
{
|
|
id: "doc-ref-wave3",
|
|
title: "试运行资料索引",
|
|
documentNo: "DOC-W3",
|
|
confidentialityLevel: "internal",
|
|
storageType: "offline_archive",
|
|
storagePath: "离线档案柜 A-01",
|
|
offlineArchiveNo: "OFF-2026-W3",
|
|
updatedAt: "2026-05-27T09:00:00.000Z",
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/communication-logs") {
|
|
await fulfillJson(route, {
|
|
items: [
|
|
{
|
|
id: "comm-wave3",
|
|
happenedAt: "2026-05-27T10:00:00.000Z",
|
|
channel: "meeting",
|
|
externalContactName: "试运行负责人",
|
|
externalOrgName: "海音达",
|
|
summary: "确认先优化详情页和移动入口。",
|
|
nextAction: "继续收集反馈",
|
|
nextFollowUpDate: "2026-05-29",
|
|
createdBy: visualMe.id,
|
|
createdAt: "2026-05-27T10:10:00.000Z",
|
|
updatedAt: "2026-05-27T10:10:00.000Z",
|
|
canEdit: true,
|
|
creator: { id: visualMe.id, employeeNo: visualMe.employeeNo, name: visualMe.name },
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects/project-wave3/closure-checklist") {
|
|
await fulfillJson(route, {
|
|
items: [
|
|
{
|
|
id: "closure-wave3",
|
|
itemKey: "contract",
|
|
title: "合同归档位置已登记",
|
|
status: "pending",
|
|
note: null,
|
|
sortOrder: 1,
|
|
completedAt: null,
|
|
completedBy: null,
|
|
canEdit: true,
|
|
completer: null,
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/projects") {
|
|
await fulfillJson(route, {
|
|
items: [
|
|
{
|
|
id: projectDetail.id,
|
|
projectNo: projectDetail.projectNo,
|
|
name: projectDetail.name,
|
|
clientName: projectDetail.clientName,
|
|
clientAlias: projectDetail.clientAlias,
|
|
status: projectDetail.status,
|
|
startsAt: projectDetail.startsAt,
|
|
targetEndAt: projectDetail.targetEndAt,
|
|
actualEndAt: projectDetail.actualEndAt,
|
|
summary: projectDetail.summary,
|
|
isConfidential: projectDetail.isConfidential,
|
|
owner: projectDetail.owner,
|
|
manager: projectDetail.manager,
|
|
counts: {
|
|
members: projectDetail.counts.members,
|
|
milestones: projectDetail.counts.milestones,
|
|
tasks: projectDetail.counts.tasks,
|
|
risks: projectDetail.counts.risks,
|
|
overdueMilestones: 0,
|
|
highPriorityTasks: 1,
|
|
openRisks: projectDetail.closureSummary.facts.openRiskCount,
|
|
},
|
|
updatedAt: projectDetail.updatedAt,
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/employees") {
|
|
await fulfillJson(route, {
|
|
page: 1,
|
|
pageSize: 100,
|
|
total: 1,
|
|
items: [
|
|
{
|
|
id: visualMe.id,
|
|
employeeNo: visualMe.employeeNo,
|
|
name: visualMe.name,
|
|
email: visualMe.email,
|
|
phone: visualMe.phone,
|
|
status: "active",
|
|
},
|
|
],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/contracts-registry/expiring") {
|
|
await fulfillJson(route, {
|
|
days: Number(url.searchParams.get("days") ?? 30),
|
|
total: 1,
|
|
items: [contractRegistryItem],
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/contracts-registry") {
|
|
await fulfillJson(route, { items: [contractRegistryItem] });
|
|
return;
|
|
}
|
|
|
|
if (pathName === "/api/purchase-requests/purchase-wave3") {
|
|
await fulfillJson(route, purchaseDetail);
|
|
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.getByTestId("reimbursement-overview")).toBeVisible();
|
|
await expect(page.getByTestId("reimbursement-summary")).toBeVisible();
|
|
await expect(page.getByTestId("reimbursement-first-screen-actions").locator("a,button")).toHaveCount(3);
|
|
await expect(page.getByTestId("reimbursement-first-screen-actions")).toContainText("看审批进度");
|
|
await expect(page.getByTestId("reimbursement-payment-status")).toHaveCount(0);
|
|
await page.getByTestId("reimbursement-more-toggle").click();
|
|
await expect(page.getByTestId("reimbursement-secondary-detail")).toBeVisible();
|
|
await expect(page.getByTestId("reimbursement-secondary-payment-status")).toHaveCount(0);
|
|
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.getByTestId("workflow-task-next-action")).toHaveCount(0);
|
|
await expect(page.getByText("审批动作")).toHaveCount(0);
|
|
await expect(page.getByRole("heading", { name: "处理", exact: true })).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 });
|
|
|
|
await page.goto("/projects");
|
|
await expect(page.getByRole("heading", { name: "项目", exact: true })).toBeVisible();
|
|
await expect(page.getByText("默认只看我负责/我参与")).toBeVisible();
|
|
await expect(page.getByText("新建项目")).toHaveCount(0);
|
|
await page.getByRole("button", { name: "台账工具" }).click();
|
|
await expect(page.getByText("新建项目")).toBeVisible();
|
|
|
|
await page.goto("/projects/project-wave3");
|
|
await expect(page.getByRole("heading", { name: /HYB-W3/ })).toBeVisible();
|
|
await expect(page.getByTestId("project-current-command")).toBeVisible();
|
|
await expect(page.locator("table").first()).toBeVisible();
|
|
await expect(page.getByText("离线档案柜 A-01")).toHaveCount(0);
|
|
await page.screenshot({ path: screenshotPath("03-pc-project-detail.png"), fullPage: true });
|
|
|
|
await page.goto("/contracts-registry?projectId=project-wave3");
|
|
await expect(page.getByRole("heading", { name: "合同台账", exact: true })).toBeVisible();
|
|
await expect(page.getByTestId("contracts-registry-summary")).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "导出 CSV" })).toHaveCount(0);
|
|
await page.getByRole("button", { name: "台账工具" }).click();
|
|
await expect(page.getByTestId("contracts-ledger-tools")).toBeVisible();
|
|
await expect(page.getByTestId("contracts-editor-panel")).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "导出 CSV" })).toBeVisible();
|
|
await expect(page.getByTestId("contracts-registry-row")).toBeVisible();
|
|
await page.getByTestId("contracts-registry-row").getByRole("button", { name: "归档" }).click();
|
|
await expect(page.getByTestId("action-confirm-dialog")).toContainText("确认归档");
|
|
await page.getByTestId("action-confirm-cancel").click();
|
|
await expect(page.getByTestId("action-confirm-dialog")).toHaveCount(0);
|
|
await page.screenshot({ path: screenshotPath("04-pc-contracts-registry.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-focus")).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/reimbursements/reim-wave3");
|
|
await expect(page.getByTestId("mobile-reimbursement-detail-focus")).toBeVisible();
|
|
await expect(page.getByTestId("mobile-reimbursement-items")).toBeVisible();
|
|
await expect(page.locator("table")).toHaveCount(0);
|
|
await expectNoHorizontalOverflow(page);
|
|
await page.screenshot({ path: screenshotPath("06-mobile-reimbursement-detail.png"), fullPage: true });
|
|
|
|
await page.goto("/mobile/approvals");
|
|
await expect(page.locator("h1", { hasText: "待我处理" })).toBeVisible();
|
|
await expect(page.getByTestId("mobile-approvals-focus")).toBeVisible();
|
|
await expect(page.getByTestId("mobile-approvals-list")).toBeVisible();
|
|
await expect(page.locator("table")).toHaveCount(0);
|
|
await expectNoHorizontalOverflow(page);
|
|
await page.screenshot({ path: screenshotPath("07-mobile-approvals.png"), fullPage: true });
|
|
|
|
await page.goto("/mobile/approvals/task-wave3");
|
|
await expect(page.getByTestId("mobile-approvals-detail")).toBeVisible();
|
|
await expect(page.getByTestId("mobile-approvals-detail-focus")).toBeVisible();
|
|
await expect(page.locator("table")).toHaveCount(0);
|
|
await expectNoHorizontalOverflow(page);
|
|
await page.screenshot({ path: screenshotPath("08-mobile-approval-detail.png"), fullPage: true });
|
|
|
|
await page.goto("/mobile/notifications");
|
|
await expect(page.getByTestId("mobile-notifications-focus")).toBeVisible();
|
|
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("09-mobile-notifications.png"), fullPage: true });
|
|
|
|
await page.goto("/mobile/purchase-requests/purchase-wave3");
|
|
await expect(page.getByTestId("mobile-purchase-detail-summary")).toBeVisible();
|
|
await expect(page.getByTestId("mobile-purchase-detail-related")).toBeVisible();
|
|
await expect(page.getByTestId("mobile-purchase-detail-items")).toBeVisible();
|
|
await expect(page.locator("table")).toHaveCount(0);
|
|
await expectNoHorizontalOverflow(page);
|
|
await page.screenshot({ path: screenshotPath("10-mobile-purchase-detail.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("11-mobile-me.png"), fullPage: true });
|
|
});
|