Files
siftlode/frontend/src/lib/pageMeta.test.ts
T
peter 2d4ecdb6c5 refactor(api): honest FeedResponse; derive pageTitleKey from the registry (R7 S3a·2-3)
- FeedResponse claimed a required `limit`, but /api/search/youtube never
  returns it (only /api/feed does) and nothing in the app reads it. Drop the
  field so searchYoutube's Promise<FeedResponse> stops lying; documented for
  re-add if a consumer appears.
- pageMeta's hand-written 13-case Page->title switch now derives from the
  ModuleDef registry via a new optional `titleKey` (the longer tab title, e.g.
  "Channel manager"; falls back to the short nav labelKey). A new page is one
  touch (add it to MODULES) instead of also editing a switch. A test pins all
  13 title keys byte-identical to the old switch (suite 74).
2026-07-27 22:45:30 +02:00

31 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { pageTitleKey } from "./pageMeta";
import type { Page } from "./urlState";
// pageTitleKey now derives from the ModuleDef registry (titleKey ?? labelKey). These are the exact
// browser-tab title keys the old hand-written switch produced — pin every page so a future labelKey
// rename (or a dropped titleKey) can't silently change a tab title.
const EXPECTED: Record<Page, string> = {
feed: "header.account.feed",
channels: "header.channelManager",
playlists: "header.account.playlists",
notifications: "inbox.navLabel",
messages: "messages.navLabel",
downloads: "downloads.navLabel",
stats: "header.usageStats",
plex: "plex.navLabel",
scheduler: "header.scheduler",
config: "header.configuration",
users: "header.users",
audit: "audit.title",
settings: "settings.title",
};
describe("pageTitleKey", () => {
it("returns the exact title key for every page (registry-derived)", () => {
for (const [page, key] of Object.entries(EXPECTED)) {
expect(pageTitleKey(page as Page)).toBe(key);
}
});
});