- sites/spiders: Haidan/HDDolby/RousiPro/SunnyPT/TNode/TorrentLeech/Yema (+mTorrent wrapper), specialized SiteAdapter, indirect download resolved at download time - sites/user-parsers: SiteParserBase + all 20 MP SiteSchema parsers (lxml XPath via xpath+xmldom), refreshSiteUserData with schema fallback - sites/definitions: zod SiteDefinition schemas, 23 MovieClaw v0.27.0 (MIT) definitions via scripts/mp-sync/movieclaw-import.mjs, registry getSiteDefinition/listSiteDefinitions, NOTICE - scripts/mp-sync: ledger.json (upstream sha256), check.mjs, build-ledger.mjs; docs/porting/mp-sync-ledger.md - license-and-provenance: add copied-mit kind, re-anchor MovieClaw rows to v0.27.0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import {
|
|
createMockFetch,
|
|
NEXUS_PHP_LOGIN_PAGE,
|
|
RABBIT_USER_DETAILS,
|
|
RABBIT_USER_INDEX,
|
|
RABBIT_USER_SEEDING_JSON,
|
|
} from "@umt/testkit";
|
|
import { describe, expect, it } from "vitest";
|
|
import { NexusRabbitSiteUserInfo } from "./nexus-rabbit.ts";
|
|
import { runParser } from "./testing.ts";
|
|
|
|
describe("NexusRabbitSiteUserInfo(MP nexus_rabbit.py)", () => {
|
|
it("首页奶糖余额 + 详情 layui-hares + api/general JSON 做种", async () => {
|
|
const m = createMockFetch({
|
|
"/": { body: RABBIT_USER_INDEX },
|
|
"/user.php": { body: RABBIT_USER_DETAILS },
|
|
"POST /api/general": { body: RABBIT_USER_SEEDING_JSON },
|
|
});
|
|
const info = await runParser(NexusRabbitSiteUserInfo, { fetch: m.fetch });
|
|
expect(info).toMatchObject({
|
|
schema: "NexusRabbit",
|
|
userId: "5",
|
|
username: "dave",
|
|
userLevel: "Power User",
|
|
joinAt: "2022-01-02 03:04:05",
|
|
upload: Math.round(1.5 * 1024 ** 4),
|
|
download: 500 * 1024 ** 3,
|
|
ratio: 3.072,
|
|
bonus: 1024.5,
|
|
seeding: 2,
|
|
seedingSize: Math.round(3.5 * 1024 ** 3),
|
|
seedingInfo: [
|
|
[3, 1024 ** 3],
|
|
[7, Math.round(2.5 * 1024 ** 3)],
|
|
],
|
|
});
|
|
const api = m.requests.find((r) => r.url.pathname === "/api/general")!;
|
|
expect(api.headers["x-requested-with"]).toBe("XMLHttpRequest");
|
|
expect(JSON.parse(api.body!)).toMatchObject({ action: "userTorrentsList", data: { type: "seeding", id: 5 } });
|
|
});
|
|
|
|
it("未登录:errMsg 且不请求 API", async () => {
|
|
const m = createMockFetch({ "/": { body: NEXUS_PHP_LOGIN_PAGE } });
|
|
const info = await runParser(NexusRabbitSiteUserInfo, { fetch: m.fetch });
|
|
expect(info.errMsg).toContain("未检测到已登陆");
|
|
expect(m.requests).toHaveLength(1);
|
|
});
|
|
});
|