import { describe, expect, it } from "vitest";
import { buildPromptBundle, listBuiltinPromptPresets, loadDefaultPrompts } from "../src/services/promptBuilder";

describe("promptBuilder", () => {
  it("loads default prompts", () => {
    const defaults = loadDefaultPrompts();
    expect(defaults.systemPrompt.length).toBeGreaterThan(20);
    expect(defaults.developerPrompt.length).toBeGreaterThan(20);
    expect(defaults.domainPrompt.length).toBeGreaterThan(20);
  });

  it("exposes v1, v1.1, v1.1.1, v1.1.2, v1.1.2.1, v2, v2.0.1 and v2.0.2 builtin presets", () => {
    const presets = listBuiltinPromptPresets();
    const versions = presets.map((item) => item.prompt_version);
    expect(versions).toContain("normalizer_v1");
    expect(versions).toContain("normalizer_v1_1");
    expect(versions).toContain("normalizer_v1_1_1");
    expect(versions).toContain("normalizer_v1_1_2");
    expect(versions).toContain("normalizer_v1_1_2_1");
    expect(versions).toContain("normalizer_v2");
    expect(versions).toContain("normalizer_v2_0_1");
    expect(versions).toContain("normalizer_v2_0_2");
  });

  it("merges user prompt values", () => {
    const bundle = buildPromptBundle({
      systemPrompt: "S",
      developerPrompt: "D",
      domainPrompt: "N",
      schemaNotes: "schema",
      fewShotExamples: "fewshot"
    });
    expect(bundle.systemPrompt).toBe("S");
    expect(bundle.developerPrompt).toBe("D");
    expect(bundle.domainPrompt).toBe("N");
    expect(bundle.combinedDeveloperPrompt.includes("fewshot")).toBe(true);
  });
});
