feat: 补齐报销付款待办交接(09-11-reimbursement-payment-handoffs)
这个提交包含在:
@@ -3,6 +3,9 @@ import path from "node:path";
|
||||
import { expect, test, type Page, type TestInfo } from "@playwright/test";
|
||||
|
||||
import { EMPLOYEE, FINANCE, login, type E2EUser } from "./helpers/auth";
|
||||
import type { PortalHomePayload } from "../../src/api/portal";
|
||||
|
||||
test.use({ serviceWorkers: "block" });
|
||||
|
||||
const ADMIN: E2EUser = {
|
||||
identifier: "[email protected]",
|
||||
@@ -109,7 +112,7 @@ function portalPayload(mode: "employee" | "admin" | "finance") {
|
||||
};
|
||||
}
|
||||
|
||||
async function mockVisualPortal(page: Page, mode: "employee" | "admin" | "finance") {
|
||||
async function mockVisualPortal(page: Page, mode: "employee" | "admin" | "finance", handoffs?: () => PortalHomePayload["businessHandoffs"]) {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.removeItem("hyb_oa_show_welcome");
|
||||
window.localStorage.removeItem("hyb_oa_onboarding_active");
|
||||
@@ -131,8 +134,8 @@ async function mockVisualPortal(page: Page, mode: "employee" | "admin" | "financ
|
||||
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(envelope({ enabled: false, entryEnabled: false, oauthEnabled: false, corpId: "", agentId: "", loginUrl: null, bindEnabled: false, defaultReturnTo: "/portal", status: "disabled", statusReasons: [] })) });
|
||||
return;
|
||||
}
|
||||
if (pathName === "/api/auth/login") {
|
||||
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(envelope({ accessToken: "visual-token", expiresIn: 900 })) });
|
||||
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: "visual-token", expiresIn: 900 })) });
|
||||
return;
|
||||
}
|
||||
if (pathName === "/api/me") {
|
||||
@@ -178,7 +181,12 @@ async function mockVisualPortal(page: Page, mode: "employee" | "admin" | "financ
|
||||
return;
|
||||
}
|
||||
if (pathName === "/api/portal/home") {
|
||||
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(envelope(portalPayload(mode))) });
|
||||
const payload = portalPayload(mode);
|
||||
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(envelope(handoffs ? {
|
||||
...payload, businessHandoffs: handoffs(), pendingTasks: { count: 0, href: "/workflow/tasks" },
|
||||
todoSummary: null, weeklyReport: null, projectSummary: null,
|
||||
financeSummary: mode === "finance" ? { ...payload.financeSummary, pendingBatchCount: 9, failedItemCount: 1, riskCount: 0 } : null,
|
||||
} : payload)) });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,6 +195,56 @@ async function mockVisualPortal(page: Page, mode: "employee" | "admin" | "financ
|
||||
}
|
||||
|
||||
test.describe("visual portal", () => {
|
||||
for (const mobile of [false, true]) {
|
||||
test(`业务交接${mobile ? "手机" : "PC"}显示真实事项并在处理后刷新消失`, async ({ page }, testInfo) => {
|
||||
test.skip(process.env.E2E_MODE === "live", "仅本地合成事项");
|
||||
let items: NonNullable<PortalHomePayload["businessHandoffs"]>["items"] = [
|
||||
{ key: "reimbursement-batch:synthetic", kind: "reimbursement_batch", reference: "BX-SYN", title: "报销待组建付款批次", nextStep: "核对付款资料后组批", ownerLabel: "财务", href: "/reimbursements/synthetic", mobileHref: "/mobile/reimbursements/synthetic" },
|
||||
{ key: "payment-execute:synthetic", kind: "payment_execute", reference: "PB-SYN", title: "付款与回单待处理", nextStep: "已生成银行制单,等待付款完成并上传回单", ownerLabel: "财务", href: "/payment-batches?id=synthetic", mobileHref: "/mobile/payment-batches?id=synthetic" },
|
||||
];
|
||||
await mockVisualPortal(page, "finance", () => ({ total: items.length, items }));
|
||||
await page.setViewportSize(mobile ? { width: 390, height: 844 } : { width: 1440, height: 1000 });
|
||||
await login(page, FINANCE);
|
||||
await page.goto(mobile ? "/mobile" : "/portal");
|
||||
await expect(page.getByText("报销待组建付款批次 · BX-SYN", { exact: true })).toBeVisible();
|
||||
await expect(page.getByText("付款与回单待处理 · PB-SYN", { exact: true })).toBeVisible();
|
||||
await expect(page.getByText("待付款批次 9 个", { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByText("异常付款 1 项", { exact: true })).toHaveCount(0);
|
||||
if (mobile) await expect(page.getByTestId("mobile-business-handoffs")).toContainText("2 项");
|
||||
else await expect(page.getByTestId("portal-work-summary")).toContainText("2");
|
||||
await page.screenshot({ path: testInfo.outputPath("handoffs.png"), fullPage: true });
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 2)).toBe(true);
|
||||
items = [];
|
||||
await page.reload();
|
||||
await expect(page.getByText("付款与回单待处理 · PB-SYN", { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByText("待付款批次 9 个", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
}
|
||||
|
||||
test("员工退回待修改直接进入本人的报销,不依赖通知未读数", async ({ page }) => {
|
||||
test.skip(process.env.E2E_MODE === "live", "仅本地合成事项");
|
||||
await mockVisualPortal(page, "employee", () => ({ total: 1, items: [{ key: "reimbursement-edit:synthetic", kind: "reimbursement_edit", reference: "BX-SYN", title: "报销退回待修改", nextStep: "修改后重新提交", ownerLabel: "报销人", href: "/reimbursements/synthetic", mobileHref: "/mobile/reimbursements/synthetic" }] }));
|
||||
await login(page, EMPLOYEE);
|
||||
await page.goto("/portal");
|
||||
const row = page.getByRole("link").filter({ hasText: "报销退回待修改" });
|
||||
await expect(row).toHaveCount(1);
|
||||
await expect(row).toHaveAttribute("href", "/reimbursements/synthetic");
|
||||
});
|
||||
|
||||
test("超过八条业务事项时计数与展示不截断", async ({ page }) => {
|
||||
test.skip(process.env.E2E_MODE === "live", "仅本地合成事项");
|
||||
const items: NonNullable<PortalHomePayload["businessHandoffs"]>["items"] = Array.from({ length: 9 }, (_, index) => ({
|
||||
key: `reimbursement-batch:synthetic-${index}`, kind: "reimbursement_batch", reference: `BX-SYN-${index}`,
|
||||
title: "报销待组建付款批次", nextStep: "核对付款资料后组批", ownerLabel: "财务",
|
||||
href: `/reimbursements/synthetic-${index}`, mobileHref: `/mobile/reimbursements/synthetic-${index}`,
|
||||
}));
|
||||
await mockVisualPortal(page, "finance", () => ({ total: items.length, items }));
|
||||
await login(page, FINANCE);
|
||||
await page.goto("/portal");
|
||||
await expect(page.getByRole("link").filter({ hasText: "报销待组建付款批次" })).toHaveCount(9);
|
||||
await expect(page.getByTestId("portal-work-summary")).toContainText("9");
|
||||
});
|
||||
|
||||
test("员工 Portal 视觉基线", async ({ page }, testInfo) => {
|
||||
await mockVisualPortal(page, "employee");
|
||||
await page.setViewportSize({ width: 1440, height: 1200 });
|
||||
|
||||
在新工单中引用
屏蔽一个用户