import { readFileSync } from "node:fs"; import path from "node:path"; import { expect, test } from "@playwright/test"; import { buildReimbursementApprovalEvidence } from "../../src/lib/reimbursementApprovalProjection"; import { buildReimbursementAmountSummary, parseMoneyToMinorUnits, } from "../../src/lib/reimbursementWorkspace"; function source(relativePath: string) { return readFileSync(path.resolve(process.cwd(), relativePath), "utf8"); } test("报销金额使用整数分判断完整性且不产生展示用第二总额", () => { expect(parseMoneyToMinorUnits("0")).toBe(0n); expect(parseMoneyToMinorUnits("0.1")).toBe(10n); expect(parseMoneyToMinorUnits("1234.56")).toBe(123456n); expect(parseMoneyToMinorUnits("1,234.56")).toBeNull(); expect(parseMoneyToMinorUnits("0.001")).toBeNull(); expect(parseMoneyToMinorUnits("NaN")).toBeNull(); expect(parseMoneyToMinorUnits(null)).toBeNull(); expect(buildReimbursementAmountSummary("0.30", [{ amount: "0.1" }, { amount: "0.20" }])).toEqual({ authoritativeTotalAmount: "0.30", integrity: "ready", }); expect(buildReimbursementAmountSummary("1000.00", [{ amount: "400" }, { amount: "600.00" }])).toEqual({ authoritativeTotalAmount: "1000.00", integrity: "ready", }); expect(buildReimbursementAmountSummary("100.00", [{ amount: "99.99" }])).toEqual({ authoritativeTotalAmount: "100.00", integrity: "mismatch", }); expect(buildReimbursementAmountSummary("100.00", [{ amount: "invalid" }])).toEqual({ authoritativeTotalAmount: "100.00", integrity: "unavailable", }); expect(buildReimbursementAmountSummary("0.00", [])).toEqual({ authoritativeTotalAmount: "0.00", integrity: "ready", }); }); test("PC 与移动明细只展示共享模型中的服务端权威合计", () => { const evidenceList = source("src/components/reimbursements/ReimbursementItemEvidenceList.tsx"); const desktopDetail = source("src/pages/ReimbursementDetailPage.tsx"); const mobileDetail = source("src/pages/MobileReimbursementDetailPage.tsx"); const approvalAdapter = source("src/pages/reimbursement-workspace/ReimbursementApprovalAdapter.tsx"); const desktopShell = source("src/components/reimbursements/ReimbursementDesktopWorkspaceShell.tsx"); const mobileShell = source("src/components/reimbursements/ReimbursementMobileWorkspaceShell.tsx"); expect(evidenceList).toContain("
{ const desktopShell = source("src/components/reimbursements/ReimbursementDesktopWorkspaceShell.tsx"); const mobileShell = source("src/components/reimbursements/ReimbursementMobileWorkspaceShell.tsx"); const approvalAdapter = source("src/pages/reimbursement-workspace/ReimbursementApprovalAdapter.tsx"); expect(desktopShell).not.toContain("slots.timeline"); expect(desktopShell.indexOf("slots.actionPanel")).toBeLessThan(desktopShell.indexOf("slots.asideContext")); expect(mobileShell.indexOf("slots.afterEvidence")).toBeLessThan(mobileShell.indexOf("slots.timeline")); expect(approvalAdapter).toContain("asideContext: timeline"); expect(approvalAdapter.match(/^\s+timeline,$/gm)).toHaveLength(1); }); test("申请人进度与审批历史保持有意分工", () => { const desktopDetail = source("src/pages/ReimbursementDetailPage.tsx"); const mobileDetail = source("src/pages/MobileReimbursementDetailPage.tsx"); const approvalAdapter = source("src/pages/reimbursement-workspace/ReimbursementApprovalAdapter.tsx"); expect(desktopDetail).toContain("