R93 修复真实 OCR 辅助等待逻辑
这个提交包含在:
@@ -35,6 +35,7 @@ export async function uploadLiveInvoiceAndWait(page: Page, invoiceFilePath: stri
|
||||
const detailPanel = page.getByTestId("invoice-detail-panel");
|
||||
await expect(detailPanel).toBeVisible({ timeout: 30_000 });
|
||||
|
||||
try {
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const text = await detailPanel.innerText().catch(() => "");
|
||||
@@ -42,7 +43,22 @@ export async function uploadLiveInvoiceAndWait(page: Page, invoiceFilePath: stri
|
||||
if (text.includes("状态:ocr_failed")) return "ocr_failed";
|
||||
return "pending_ocr";
|
||||
}, { timeout })
|
||||
.not.toBe("pending_ocr");
|
||||
.toMatch(/^(available|ocr_failed)$/);
|
||||
} catch (error) {
|
||||
const detailText = await detailPanel.innerText().catch(() => "");
|
||||
const bannerText = await page.getByTestId("invoice-ocr-status-banner").innerText().catch(() => "");
|
||||
const invoiceId = extractField(detailText, "票据ID:");
|
||||
throw new Error(
|
||||
[
|
||||
"live 腾讯 OCR 等待终态超时",
|
||||
`invoiceId=${invoiceId ?? "unknown"}`,
|
||||
`timeoutMs=${timeout}`,
|
||||
`detail=${detailText || "<empty>"}`,
|
||||
`banner=${bannerText || "<empty>"}`,
|
||||
`cause=${error instanceof Error ? error.message : String(error)}`,
|
||||
].join("\n"),
|
||||
);
|
||||
}
|
||||
|
||||
const detailText = await detailPanel.innerText();
|
||||
const bannerText = await page.getByTestId("invoice-ocr-status-banner").innerText().catch(() => "");
|
||||
|
||||
@@ -19,8 +19,9 @@ test("手工 live 腾讯 OCR 辅助复核:真实 VAT 发票上传后进入可
|
||||
throw new Error(`live 腾讯 OCR 失败:${result.bannerText || result.detailText}`);
|
||||
}
|
||||
|
||||
await expect(page.getByTestId("invoice-detail-panel")).not.toContainText("发票号:---");
|
||||
await expect(page.getByTestId("invoice-detail-panel")).not.toContainText("总金额:-");
|
||||
expect(result.invoiceCode ?? result.invoiceNumber, JSON.stringify(result)).toBeTruthy();
|
||||
expect(result.totalAmount, JSON.stringify(result)).toBeTruthy();
|
||||
expect(result.totalAmount, JSON.stringify(result)).not.toBe("-");
|
||||
|
||||
await logout(page, EMPLOYEE.name);
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户