import type { SiteRelease } from "@umt/adapters"; import { describe, expect, it } from "vitest"; import { mergeDetailOverList } from "../../src/modules/sources-identity/service/snapshot.ts"; // HHClub 2026-09-29 实测:div 详情页没有做种 / 完成数 / 分类名,刷新详情后这些列被 null 冲掉。 describe("详情刷新沿用列表字段", () => { const detail: SiteRelease = { siteId: "hhanclub", siteReleaseId: "91001", title: "示例短剧 1080p WEB-DL H265 AAC-HHWEB", category: { id: "412", name: null }, sizeBytes: 194385019, seeders: null, leechers: null, snatched: null, promotion: { type: "none", downloadFactor: 1, uploadFactor: 1, expiresAt: null }, hr: "unknown", uploadedAt: "2026-09-29T06:07:03.000Z", detailUrl: "https://hhanclub.net/details.php?id=91001", downloadUrl: "https://hhanclub.net/download.php?id=91001", tags: [], raw: {}, observedAt: "2026-09-29T06:19:28.000Z", }; const rel = { seeders: 1, leechers: 58, category_raw: "412", tags_raw: ["官方"], raw: { _site: { hr: false, snatched: 0, categoryName: "短剧" } }, }; it("详情缺的做种 / 下载 / 完成 / 分类名 / H&R / 标签取列表快照值", () => { expect(mergeDetailOverList(detail, rel)).toMatchObject({ seeders: 1, leechers: 58, snatched: 0, category: { id: "412", name: "短剧" }, hr: false, tags: ["官方"], }); }); it("详情有值时以详情为准", () => { const m = mergeDetailOverList({ ...detail, seeders: 9, hr: true, category: { id: "402", name: "电视剧" } }, rel); expect(m).toMatchObject({ seeders: 9, hr: true, category: { id: "402", name: "电视剧" } }); }); });