- board organize hint uses DEAI-2 reasonLine; add transfer_failed, blocked, blocked_by_conflict, main_failed, not_imported_kind, target_root_not_managed, download_removed to the reason table with tests - download detail / plans tab: internal ids, raw codes and JSON moved into TechInfo - library versions tech block switched to TechInfo (TODO(DEAI-2)) - copy: glossary terms (no 接管/候选), plan reason codes no longer shown raw Co-Authored-By: Claude Opus 5.5 <[email protected]>
35 lines
2.0 KiB
TypeScript
35 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { looksLikeCode, reasonSentence, reasonText } from "../src/reasons.ts";
|
|
|
|
describe("reasonText(DEAI-2 原因码人话化)", () => {
|
|
it("裸码、blocked:多码、带后缀的码都能翻译", () => {
|
|
expect(reasonText("identity_unknown")).toEqual({ text: "没识别出作品", action: "指定作品后重新整理" });
|
|
expect(reasonText("blocked:target_exists")?.text).toBe("媒体库里已有同名文件");
|
|
expect(reasonText("blocked:target_exists,hnr_unknown")?.text).toBe("媒体库里已有同名文件;不确定做种要求是否满足");
|
|
expect(reasonText("move_downgraded_to_copy:hnr_unknown")?.text).toBe("做种未完成,已改为复制");
|
|
expect(reasonText("below_min_size")?.text).toContain("最小体积");
|
|
});
|
|
|
|
it("下载面板用到的码(DL-2b):整理失败、冲突、下载被删", () => {
|
|
expect(reasonSentence("transfer_failed")).toBe("文件没有整理成功。在整理记录里查看失败的文件");
|
|
expect(reasonSentence("blocked")).toBe("有冲突要先处理。去待处理");
|
|
expect(reasonText("download_removed")?.text).toBe("下载任务已从下载器删除");
|
|
expect(reasonText("target_root_not_managed")?.text).toContain("本工具管理");
|
|
for (const c of ["blocked_by_conflict", "main_failed", "not_imported_kind"]) expect(reasonText(c)).not.toBeNull();
|
|
});
|
|
|
|
it("不认识的码返回 null;句子兜底不把码原样给人看", () => {
|
|
expect(reasonText("some_new_code")).toBeNull();
|
|
expect(reasonSentence("some_new_code")).toBe("处理失败");
|
|
expect(reasonSentence("磁盘已满")).toBe("磁盘已满");
|
|
expect(reasonSentence("identity_unknown")).toBe("没识别出作品。指定作品后重新整理");
|
|
});
|
|
|
|
it("looksLikeCode 只认内部码", () => {
|
|
expect(looksLikeCode("blocked:target_exists")).toBe(true);
|
|
expect(looksLikeCode("identity_unknown")).toBe(true);
|
|
expect(looksLikeCode("目标已存在")).toBe(false);
|
|
expect(looksLikeCode("Connection refused")).toBe(false);
|
|
});
|
|
});
|