From 5a74cf86b7e8900ea317474df027fa9fdcbd6d4a Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sun, 4 Oct 2026 02:57:09 +0200 Subject: [PATCH] test(api): the wire-key checks send every filter field, and tsc says when one is new MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend/src/lib/api/feed.test.ts | 44 ++++++++++++-------- frontend/src/lib/api/plexFilters.dom.test.ts | 3 +- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/frontend/src/lib/api/feed.test.ts b/frontend/src/lib/api/feed.test.ts index fed12e06..bc05aa09 100644 --- a/frontend/src/lib/api/feed.test.ts +++ b/frontend/src/lib/api/feed.test.ts @@ -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 = { + 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 }); diff --git a/frontend/src/lib/api/plexFilters.dom.test.ts b/frontend/src/lib/api/plexFilters.dom.test.ts index f5bbe656..cdeef134 100644 --- a/frontend/src/lib/api/plexFilters.dom.test.ts +++ b/frontend/src/lib/api/plexFilters.dom.test.ts @@ -8,7 +8,8 @@ import { plexFiltersToParams, type PlexFilters } from "./plex"; // the backend renames does not fail anywhere — the filter silently stops narrowing while its chip // still shows (E32 S2, the sibling of lib/api/feed.test.ts). Every key the filter set can put on the // wire must be a field of the backend's LibraryFilters, which /library and /facets both inject. -const EVERYTHING: PlexFilters = { +// Required: a new filter field fails tsc here until it has a value, so the checks below see its key. +const EVERYTHING: Required = { genres: ["Drama"], genreMode: "all", contentRatings: ["PG"],