fix(frontend): errorCode 统一自 generation/cards 去重复定义(CR-H10)

This commit is contained in:
Yaojia Wang
2026-07-08 11:06:30 +02:00
parent f4c2c4e8ec
commit 5665cc9a16
3 changed files with 21 additions and 12 deletions

View File

@@ -0,0 +1,19 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
// CR-H10 回归守卫errorCode 只应有一份权威实现lib/generation/cards
// style 侧两个 hook 不得再各自本地定义 `function errorCode(`,须统一 import。
describe("errorCode 去重CR-H10", () => {
it.each(["useRefine.ts", "useStyleLearn.ts"])(
"%s 不再本地定义 errorCode且从 generation/cards 引入",
(file) => {
const src = readFileSync(new URL(`./${file}`, import.meta.url), "utf-8");
expect(src).not.toMatch(/function\s+errorCode\s*\(/);
expect(src).toMatch(
/import\s*\{[^}]*\berrorCode\b[^}]*\}\s*from\s*["']@\/lib\/generation\/cards["']/,
);
},
);
});