import { describe, expect, it } from "vitest";
import { DEFAULT_OVERVIEW_LAYOUT, sanitizeOverviewLayout } from "./overviewLayout";

describe("sanitizeOverviewLayout", () => {
  it("returns the default layout when input is null", () => {
    expect(sanitizeOverviewLayout(null)).toEqual(DEFAULT_OVERVIEW_LAYOUT);
  });

  it("drops unknown IDs and restores missing required IDs", () => {
    const result = sanitizeOverviewLayout({
      version: 1,
      leftZone: ["description", "unknown"],
      rightZone: [],
    });

    expect(result).toEqual({
      version: 1,
      leftZone: ["description"],
      rightZone: ["myTasks", "files", "info"],
    });
  });

  it("deduplicates IDs across zones and preserves zone split", () => {
    const result = sanitizeOverviewLayout({
      version: 1,
      leftZone: ["description", "files"],
      rightZone: ["files", "info", "description"],
    });

    expect(result).toEqual({
      version: 1,
      leftZone: ["description", "files"],
      rightZone: ["info", "myTasks"],
    });
  });
});
