test(api): the wire-key checks send every filter field, and tsc says when one is new

The Plex and feed filter fixtures were typed as the filter type itself, whose scalar filters are
optional: a new optional field compiled without a test value, so its wire key went unchecked.
Both are Required<…> now (a probe field fails typecheck on each). The feed set gained the fields
it omitted (year, librarySource, the scope and show switches) and goes out with and without year,
which wins over the other date filters; a misspelt year key is now red in the wire check, which
passed it before.
This commit is contained in:
2026-10-04 02:57:09 +02:00
parent e432dc2780
commit 5a74cf86b7
2 changed files with 28 additions and 19 deletions
+26 -18
View File
@@ -106,24 +106,32 @@ describe("feed filters on the wire", () => {
[...(block?.[1] ?? "").matchAll(/^\s{4}(\w+):/gm)].flatMap((m) => (m[1] ? [m[1]] : [])),
);
known.add("sort").add("seed").add("cursor").add("limit"); // read by /feed itself
const everything = sent(
{
tags: [1],
tagModes: { language: "and", topic: "and", other: "and" },
channelIds: ["UC"],
untagged: true,
q: "x",
maxAgeDays: 3,
dateFrom: "2024-01-01",
dateTo: "2024-01-02",
minDuration: 1,
maxDuration: 2,
sort: "shuffle",
seed: 1,
},
"C",
);
const unknown = [...new Set(everything.keys())].filter((k) => !known.has(k));
// Every field set (Required: a new filter field fails tsc here until it has a value, so its key
// is checked too). `year` wins over the other date filters, so the set goes out once with it
// and once without.
const all: Required<FeedFilters> = {
tags: [1],
tagModes: { language: "and", topic: "and", other: "and" },
q: "x",
sort: "shuffle",
seed: 1,
scope: "all",
includeNormal: false,
includeShorts: true,
includeLive: true,
show: "all",
librarySource: "search",
untagged: true,
channelIds: ["UC"],
maxAgeDays: 3,
minDuration: 1,
maxDuration: 2,
dateFrom: "2024-01-01",
dateTo: "2024-01-02",
year: 2020,
};
const everything = [...sent(all, "C").keys(), ...sent({ ...all, year: undefined }, "C").keys()];
const unknown = [...new Set(everything)].filter((k) => !known.has(k));
expect(unknown).toEqual([]);
expect(known.has("tag_mode_topic")).toBe(true); // the parse found the real list
});