import { describe, expect, it } from "vitest";

import { normalizeProfileModelCatalog } from "./profileCatalog";

describe("normalizeProfileModelCatalog", () => {
  it("wraps the legacy bare array response with unknown compatibility", () => {
    expect(
      normalizeProfileModelCatalog([
        {
          adapter: "codex",
          modelId: "gpt-5-codex",
          displayName: "GPT-5 Codex",
          aliases: ["codex"],
          recommended: true,
        },
      ]),
    ).toEqual({
      models: [
        {
          adapter: "codex",
          modelId: "gpt-5-codex",
          displayName: "GPT-5 Codex",
          aliases: ["codex"],
          recommended: true,
          compatibility: "unknown",
          source: "catalogue",
        },
      ],
      cliVersion: null,
      warnings: [],
    });
  });

  it("defaults missing enriched fields without dropping warnings", () => {
    expect(
      normalizeProfileModelCatalog({
        models: [{ adapter: "claude", modelId: "claude-sonnet-5" }],
        warnings: ["version inconnue"],
      }),
    ).toEqual({
      models: [
        {
          adapter: "claude",
          modelId: "claude-sonnet-5",
          displayName: "claude-sonnet-5",
          aliases: [],
          recommended: false,
          compatibility: "unknown",
          source: "catalogue",
        },
      ],
      cliVersion: null,
      warnings: ["version inconnue"],
    });
  });
});
