B1-B8 建立项目级流程与QA门禁

这个提交包含在:
2026-05-09 01:57:05 +08:00
父节点 555e7b7e29
当前提交 485328426a
共修改 29 个文件,包含 1633 行新增和 102 行删除
+13 -14
查看文件
@@ -3,14 +3,6 @@ import { EMPLOYEE, FINANCE, MANAGER, login, logout } from "./helpers/auth";
import { openNavLink } from "./helpers/navigation";
import { TEST_IDS } from "./helpers/testIds";
function extractId(text: string, label: string) {
const match = text.match(new RegExp(`${label}:([0-9a-f-]{36})`));
if (!match?.[1]) {
throw new Error(`Failed to parse ${label} from text: ${text}`);
}
return match[1];
}
test("E2E 主链路:登录→报销→待办审批→票据OCR→支付→登出", async ({ page, reimbursementDetail, workflowDetail }) => {
// 主链路包含 OCR 等待和三角色切换,full-local 下会超过默认 120s。
test.setTimeout(240_000);
@@ -38,22 +30,29 @@ test("E2E 主链路:登录→报销→待办审批→票据OCR→支付→登
// 2) employee: upload invoice and wait OCR
await (await openNavLink(page, "票据中心")).click();
const marker = `MOCK_E2E_${Date.now()}_${Math.random().toString(16).slice(2)}`;
const invoiceFileName = `e2e-${Date.now()}.png`;
const uploadResponsePromise = page.waitForResponse((response) => {
const url = new URL(response.url());
return response.request().method() === "POST" && url.pathname === "/api/invoice-pool/upload" && response.ok();
});
await page.getByTestId("invoice-upload-file").setInputFiles({
name: `e2e-${Date.now()}.png`,
name: invoiceFileName,
mimeType: "image/png",
buffer: Buffer.from(marker, "utf8"),
});
await page.getByTestId("invoice-upload-submit").click();
const uploadPayload = (await (await uploadResponsePromise).json()) as { data?: { invoicePoolId?: string | null } };
const invoiceId = uploadPayload.data?.invoicePoolId;
if (!invoiceId) {
throw new Error(`上传发票后未返回票据 ID: ${JSON.stringify(uploadPayload)}`);
}
await expect(page.getByTestId("invoice-detail-panel")).toBeVisible();
await expect(page.getByTestId("invoice-detail-panel")).toContainText("状态:available", { timeout: 90_000 });
const invoiceDetailText = await page.getByTestId("invoice-detail-panel").innerText();
const invoiceId = extractId(invoiceDetailText, "票据ID");
await expect(page.getByTestId("invoice-detail-panel")).toContainText("状态:可用", { timeout: 90_000 });
// 预览(popup 存在即可)
const popupPromise = page.waitForEvent("popup");
const invoiceRow = page.getByTestId("invoice-row").filter({ hasText: invoiceId }).first();
const invoiceRow = page.getByTestId("invoice-row").filter({ hasText: invoiceFileName }).first();
await expect(invoiceRow).toBeVisible();
await invoiceRow.getByRole("button").click();
await page.getByTestId("invoice-preview-button").click();