feat(episode-mapping): 映射规则接口与模拟预览、待处理确认 / 忽略、作品页集数映射分区与订阅摘要

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-03 19:28:09 +08:00
1 parent fe597187dd
commit 45a114263b
26 files changed
+2770 -9

No files matched your search

@@ -0,0 +1,72 @@
import type { EpisodeMappingPreviewItem } from "@umt/contracts";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { PreviewTable } from "./preview-table.tsx";
const item = (over: Partial<EpisodeMappingPreviewItem>): EpisodeMappingPreviewItem => ({
sourceReleaseId: "7d3f7f5e-8a8c-4b8e-9f0a-1b2c3d4e5f60",
title: "[Lilith-Raws] Kusuriya no Hitorigoto - 40",
publishedAt: "2025-03-14T15:00:00.000Z",
releaseGroup: "Lilith-Raws",
current: {
method: "unresolved",
source: { season: 1, episodes: { start: 40, end: 40 } },
canonical: null,
evidence: [],
},
preview: {
method: "rule",
source: { season: 1, episodes: { start: 40, end: 40 } },
canonical: { season: 2, episodes: { start: 10, end: 10 } },
ruleId: "draft",
evidence: [],
},
validation: "pass",
changed: true,
...over,
});
describe("模拟预览表格", () => {
it("原始 → 当前 → 套用后、方式、校验;有变化的行高亮", () => {
const html = renderToStaticMarkup(createElement(PreviewTable, { items: [item({})], hasDraft: true }));
expect(html).toContain("套用后");
expect(html).toContain("S01E40");
expect(html).toContain("待确认");
expect(html).toContain("S02E10");
expect(html).toContain("按规则");
expect(html).toContain("对得上");
expect(html).toContain("有变化");
expect(html).toContain('data-changed="true"');
});
it("没变化不高亮;校验不通过显示对不上;没有草稿时列名是重算", () => {
const html = renderToStaticMarkup(
createElement(PreviewTable, {
items: [
item({
changed: false,
validation: "fail",
preview: {
method: "unresolved",
source: { season: 1, episodes: { start: 40, end: 40 } },
canonical: null,
evidence: [],
},
}),
],
hasDraft: false,
}),
);
expect(html).toContain("重算");
expect(html).toContain("对不上");
expect(html).not.toContain("data-changed");
expect(html).not.toContain("有变化");
});
it("没有资源时显示空态", () => {
expect(renderToStaticMarkup(createElement(PreviewTable, { items: [], hasDraft: false }))).toContain(
"还没有绑定的资源",
);
});
});