OINV1 加固真实发票OCR脱敏报告
这个提交包含在:
@@ -3,7 +3,7 @@ import path from "node:path";
|
||||
|
||||
import { test, expect } from "../helpers/fixtures";
|
||||
import { EMPLOYEE, login } from "../helpers/auth";
|
||||
import { openInvoicePool, resolveLiveOcrUser, uploadLiveInvoiceAndWait } from "../helpers/liveInvoiceOcr";
|
||||
import { createSafeLiveInvoiceOcrEvidence, openInvoicePool, resolveLiveOcrUser, uploadLiveInvoiceAndWait } from "../helpers/liveInvoiceOcr";
|
||||
|
||||
test("手工 live 腾讯 OCR 辅助复核:真实 VAT 发票上传后进入可处理状态", async ({ page }, testInfo) => {
|
||||
test.skip(process.env.PLAYWRIGHT_MANUAL !== "1", "仅在显式手工 Playwright 模式下执行");
|
||||
@@ -18,17 +18,7 @@ test("手工 live 腾讯 OCR 辅助复核:真实 VAT 发票上传后进入可
|
||||
await openInvoicePool(page);
|
||||
|
||||
const result = await uploadLiveInvoiceAndWait(page, invoiceFilePath);
|
||||
const evidence = {
|
||||
status: result.status,
|
||||
durationMs: result.durationMs,
|
||||
invoiceId: result.invoiceId,
|
||||
invoiceCode: result.invoiceCode,
|
||||
invoiceNumber: result.invoiceNumber,
|
||||
sellerName: result.sellerName,
|
||||
totalAmount: result.totalAmount,
|
||||
invoiceDate: result.invoiceDate,
|
||||
bannerText: result.bannerText,
|
||||
};
|
||||
const evidence = createSafeLiveInvoiceOcrEvidence(result, process.env.PLAYWRIGHT_OCR_LIVE_ALIAS?.trim() || "SAMPLE-PDF-001");
|
||||
console.log(`[live-ocr] ${JSON.stringify(evidence)}`);
|
||||
await testInfo.attach("live-ocr-result.json", {
|
||||
body: JSON.stringify(evidence, null, 2),
|
||||
@@ -37,18 +27,17 @@ test("手工 live 腾讯 OCR 辅助复核:真实 VAT 发票上传后进入可
|
||||
|
||||
if (result.status === "ocr_failed") {
|
||||
const allowDuplicate = process.env.PLAYWRIGHT_OCR_ALLOW_DUPLICATE === "1";
|
||||
const resultText = `${result.bannerText}\n${result.detailText}`;
|
||||
const explainableTerminal = /重复|相同发票|duplicate|已用于报销|已使用|used/i.test(resultText);
|
||||
const explainableTerminal = ["duplicate_or_same_invoice", "already_used"].includes(evidence.reasonCategory);
|
||||
if (!allowDuplicate || !explainableTerminal) {
|
||||
throw new Error(`live 腾讯 OCR 失败:${result.bannerText || result.detailText}`);
|
||||
throw new Error(`live 腾讯 OCR 失败:reasonCategory=${evidence.reasonCategory}`);
|
||||
}
|
||||
await page.context().clearCookies().catch(() => undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
expect(result.invoiceCode ?? result.invoiceNumber, JSON.stringify(result)).toBeTruthy();
|
||||
expect(result.totalAmount, JSON.stringify(result)).toBeTruthy();
|
||||
expect(result.totalAmount, JSON.stringify(result)).not.toBe("-");
|
||||
expect(result.invoiceCode ?? result.invoiceNumber, JSON.stringify(evidence)).toBeTruthy();
|
||||
expect(result.totalAmount, JSON.stringify(evidence)).toBeTruthy();
|
||||
expect(result.totalAmount, JSON.stringify(evidence)).not.toBe("-");
|
||||
|
||||
await page.context().clearCookies().catch(() => undefined);
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户