test: OCR冒烟缺少本机夹具时自动跳过

This commit is contained in:
yu 2026-11-03 14:59:48 +08:00
parent c973209418
commit c90584670d

View File

@ -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<string, unknown>) {
const handler = getHandler(id);
@ -20,7 +33,7 @@ async function runOcr(id: string, args: Record<string, unknown>) {
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);
});