From c90584670d7422e27b3c40bd945cfa3c90a9f978 Mon Sep 17 00:00:00 2001 From: yu <1919727607@qq.com> Date: Tue, 3 Nov 2026 14:59:48 +0800 Subject: [PATCH] =?UTF-8?q?test:=20OCR=E5=86=92=E7=83=9F=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E6=9C=AC=E6=9C=BA=E5=A4=B9=E5=85=B7=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=B7=B3=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/capabilities/ocr-smoke.test.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/capabilities/ocr-smoke.test.ts b/src/main/capabilities/ocr-smoke.test.ts index 45c584a..b23192e 100644 --- a/src/main/capabilities/ocr-smoke.test.ts +++ b/src/main/capabilities/ocr-smoke.test.ts @@ -1,3 +1,4 @@ +import { existsSync } from "node:fs"; import { describe, expect, it } from "vitest"; import { getHandler } from "../engine/registry"; import type { CatalogComponent, FlowNode } from "../../shared/types"; @@ -12,7 +13,19 @@ const ctx = { evidenceDir: "D:/office-test2/ocr-test" } as unknown as RunContext; -const node = { id: "smoke", componentId: "smoke", position: { x: 0, y: 0 }, values: {}, options: {} }; +const node: FlowNode = { + id: "smoke", + componentId: "smoke", + position: { x: 0, y: 0 }, + values: {}, + options: {}, +}; +const ocrFixtures = [ + "D:/office-test2/ocr-test/general.png", + "D:/office-test2/ocr-test/code.png", + "D:/office-test2/ocr-test/table.png", +]; +const ocrFixturesReady = ocrFixtures.every((file) => existsSync(file)); async function runOcr(id: string, args: Record) { const handler = getHandler(id); @@ -20,7 +33,7 @@ async function runOcr(id: string, args: Record) { return handler!(ctx, node, args, {} as CatalogComponent); } -describe("OCR 组件冒烟(本地离线识别,真实模型推理)", () => { +describe.skipIf(!ocrFixturesReady)("OCR 组件冒烟(本地离线识别,真实模型推理)", () => { it("OCR_GeneralTextV2 通用文本", async () => { const out = await runOcr("OCR_GeneralTextV2", { path: "D:/office-test2/ocr-test/general.png" }); console.log("[GeneralTextV2]", JSON.stringify(out)); @@ -86,3 +99,4 @@ describe("OCR 组件冒烟(本地离线识别,真实模型推理)", () => expect(rows.length).toBeGreaterThan(0); }, 300000); }); +