feat(web): subscription calendar view, reset action and quality preset fields
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
70d56645fe
commit
05350460f0
7 files changed
+638
-166
No files matched your search
@@ -5,10 +5,15 @@ import {
|
||||
draftFromSubscription,
|
||||
draftToParams,
|
||||
emptyDraft,
|
||||
entriesByDate,
|
||||
foldNames,
|
||||
monthGrid,
|
||||
monthKey,
|
||||
monthStart,
|
||||
moveItem,
|
||||
progressText,
|
||||
seasonLabel,
|
||||
shiftMonth,
|
||||
slotBadge,
|
||||
upgradeOf,
|
||||
} from "./model.ts";
|
||||
@@ -153,4 +158,51 @@ describe("表单 ↔ params", () => {
|
||||
expect(d.keywords).toBe("a\nb");
|
||||
expect(d.upgrade).toBe("per_unit");
|
||||
});
|
||||
it("质量预设:草稿 ↔ params;未知值回填为空", () => {
|
||||
const d = { ...emptyDraft("movie"), resolution: "4k" as const, source: "remux" as const, effect: "dv" as const };
|
||||
const { params } = draftToParams(
|
||||
d,
|
||||
{ resolution: "720p", effect: "sdr" },
|
||||
{ upgradeChanged: false, totalChanged: false },
|
||||
);
|
||||
expect(params).toEqual({ resolution: "4k", source: "remux", effect: "dv" });
|
||||
const cleared = draftToParams(
|
||||
emptyDraft("movie"),
|
||||
{ resolution: "720p" },
|
||||
{ upgradeChanged: false, totalChanged: false },
|
||||
);
|
||||
expect(cleared.params.resolution).toBeUndefined();
|
||||
const back = draftFromSubscription(
|
||||
{
|
||||
mediaKind: "movie",
|
||||
seasonScope: "current_season",
|
||||
mode: "once",
|
||||
priority: "tracking",
|
||||
seasonUnitId: null,
|
||||
policyRevisionId: null,
|
||||
params: { resolution: "1080p", source: "bogus", effect: "hdr" },
|
||||
} as unknown as Subscription,
|
||||
"off",
|
||||
);
|
||||
expect([back.resolution, back.source, back.effect]).toEqual(["1080p", "", "hdr"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("日历", () => {
|
||||
it("月网格从周一开始,整周铺满;跨年切月", () => {
|
||||
const first = monthStart("2026-09");
|
||||
const g = monthGrid(first);
|
||||
expect(g[0]).toEqual({ date: "2026-08-31", inMonth: false });
|
||||
expect(g.length % 7).toBe(0);
|
||||
expect(g.at(-1)).toEqual({ date: "2026-10-04", inMonth: false });
|
||||
expect(g.filter((d) => d.inMonth)).toHaveLength(30);
|
||||
expect(monthKey(shiftMonth(monthStart("2026-12"), 1))).toBe("2027-01");
|
||||
expect(monthKey(monthStart("bad", new Date(2026, 4, 9)))).toBe("2026-05");
|
||||
});
|
||||
it("按日期分桶", () => {
|
||||
const e = (date: string) => ({ date, subscriptionId: date }) as never;
|
||||
const m = entriesByDate([e("2026-09-01"), e("2026-09-01"), e("2026-09-02")]);
|
||||
expect(m.get("2026-09-01")).toHaveLength(2);
|
||||
expect(m.get("2026-09-03")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user