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);
    }
  });
});
