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); }); +