文件
hyb-oa/client/tests/e2e/helpers/pageObjects/ReimbursementDetailPage.ts
T
wangsli 1f8d5b658a 完善借款、编号、付款与预算并发及验收(09-06-release-gate-integrity)
汇总已落盘的借款本金与还款、兼容历史编号的周期化编号、付款责任与回单核验、报销进度和排序、PWA/采购事务、错误原因与日期校验及ERP退役。
统一共享预算池锁序和锁后判断,恢复差旅原预算选择,补原因码固定夹具及反向完整性检查。
纳入配套迁移、测试、受管QA、分层验收合同、规约及任务记录;原始证据留在ignored artifacts。

关联任务:09-17-company-loan-principal-repayment、09-17-erp-exclusive-retirement、09-18-reimbursement-periodic-numbering、09-08-reimbursement-payment-closeout、09-18-local-concurrency-product-fixes、09-19-budget-pool-concurrency、09-05-error-explainability-payment-readiness。
预算补审由Claude定向验证2文件928项通过,原4446/28及r6结果仍仅对应各自历史输入;本轮未重跑测试。
完整新候选门禁、R1真实入口接入与12项公网义务仍开放。生产编号未启用、差旅仍冻结;不推送、不部署,不宣称发布资格。
2026-09-19 13:11:04 +08:00

149 行
5.7 KiB
TypeScript

import { expect, type Page } from "@playwright/test";
import { TEST_IDS } from "../testIds";
export class ReimbursementDetailPageObject {
readonly page: Page;
constructor(page: Page) {
this.page = page;
}
get overview() {
return this.page.getByTestId("reimbursement-desktop-workspace");
}
get summary() {
return this.overview.locator("section.workbench-hero");
}
get itemsTable() {
return this.page.getByTestId("reimbursement-expense-items");
}
get addItemBtn() {
return this.page.getByTestId(TEST_IDS.reimbursement.itemAdd);
}
get budgetHint() {
return this.page.getByTestId(TEST_IDS.reimbursement.budgetHint);
}
get workflowProgress() {
return this.page.getByTestId(TEST_IDS.reimbursement.workflowProgress);
}
get invoices() {
return this.page.getByTestId("approval-invoices");
}
get invoiceAddBtn() {
return this.page.getByTestId(TEST_IDS.reimbursement.invoiceAdd);
}
get invoiceDialog() {
return this.page.getByTestId(TEST_IDS.reimbursement.invoiceDialog);
}
get invoiceUploadFile() {
return this.page.getByTestId(TEST_IDS.reimbursement.invoiceUploadFile);
}
get invoiceUploadSubmit() {
return this.page.getByTestId(TEST_IDS.reimbursement.invoiceUploadSubmit);
}
get submitBtn() {
return this.page.getByTestId(TEST_IDS.reimbursement.submit);
}
get withdrawBtn() {
return this.page.getByTestId(TEST_IDS.reimbursement.withdraw);
}
get payBtn() {
return this.page.getByTestId(TEST_IDS.reimbursement.pay);
}
async assertLoaded() {
await expect(this.overview).toBeVisible({ timeout: 15_000 });
await expect(this.summary).toBeVisible({ timeout: 15_000 });
}
async assertStatus(statusText: string) {
await expect(this.summary).toContainText(statusText);
}
async uploadInvoicePdf(fileName: string, buffer: Buffer) {
const invoiceCards = this.invoices.getByTestId("approval-invoice-evidence");
const invoiceCountBeforeUpload = await invoiceCards.count();
await this.invoiceAddBtn.click();
await expect(this.invoiceDialog).toBeVisible();
const uploadResponsePromise = this.page.waitForResponse((response) => {
const url = new URL(response.url());
return response.request().method() === "POST" && url.pathname === "/api/invoice-pool/upload" && response.ok();
});
await this.invoiceUploadFile.setInputFiles({
name: fileName,
mimeType: "application/pdf",
buffer,
});
await this.invoiceUploadSubmit.scrollIntoViewIfNeeded();
await this.invoiceUploadSubmit.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)}`);
}
// OCR selects the invoice; binding remains an explicit user action.
const invoiceRow = this.invoiceDialog.locator("label").filter({ hasText: fileName });
await expect(invoiceRow.getByRole("checkbox")).toBeChecked({ timeout: 90_000 });
const target = invoiceRow.getByRole("combobox", { name: "添加到哪条明细" });
const existingItems = target.locator('option:not([value=""])');
await expect(existingItems).toHaveCount(1);
await target.selectOption((await existingItems.getAttribute("value"))!);
await this.invoiceDialog.getByRole("button", { name: "添加到报销单", exact: true }).click();
await expect(invoiceCards).toHaveCount(invoiceCountBeforeUpload + 1);
await expect(this.itemsTable.getByTestId("approval-item-evidence")).toHaveCount(1);
await expect(this.invoiceDialog).toHaveCount(0);
return invoiceId;
}
async addItem(amount = "10.00") {
await this.addItemBtn.click();
const expenseType = this.page.getByTestId("reimbursement-item-expense-type");
await expect(expenseType.locator("option")).not.toHaveCount(1);
const value = await expenseType.locator("option").evaluateAll(options =>
(options as HTMLOptionElement[]).find(option => option.textContent === "邮寄快递")?.value);
expect(value, "synthetic fixture requires the seeded courier expense type").toBeTruthy();
await expenseType.selectOption(value!);
await this.page.getByTestId("reimbursement-item-amount").fill(amount);
await this.page.getByTestId("reimbursement-item-description").fill("合成快递费用,低于票面金额部分为非报销支出");
await this.page.getByTestId("reimbursement-item-save").click();
await expect(this.page.getByTestId("reimbursement-item-editor")).toHaveCount(0);
await expect(this.itemsTable.getByTestId("approval-item-evidence")).toHaveCount(1);
}
async submitReimbursement() {
const precheck = this.page.waitForResponse(response =>
new URL(response.url()).pathname.endsWith("/precheck") && response.request().method() === "POST");
const submitted = this.page.waitForResponse(response =>
new URL(response.url()).pathname.endsWith("/submit") && response.request().method() === "POST");
await this.submitBtn.click();
const check = await precheck;
expect(check.ok()).toBe(true);
const data = (await check.json()).data;
if (data?.decision === "warn" || data?.decision === "manual_review" || data?.standardChecks?.some((item: {exceeded: boolean; controlMode: string}) => item.exceeded && item.controlMode === "warn")) {
await this.page.getByRole("dialog", { name: "确认提交报销单?" }).getByRole("button", { name: "确认提交", exact: true }).click();
}
const response = await submitted;
expect(response.ok(), `synthetic submit HTTP ${response.status()}`).toBe(true);
return (await response.json()).data as {currentTaskId: string};
}
}