import { describe, expect, it } from "@jest/globals";

import {
  buildHardwareDiagram,
  buildNetworkDiagram,
  buildPipelineDiagram,
  fallbackHardware,
  fallbackMetrics,
  fallbackNetwork,
  fallbackServices,
} from "../../../frontend/src/data/sample.js";

describe("sample data builders", () => {
  it("exposes the atlas hardware and service inventory", () => {
    const hardware = fallbackHardware();
    const services = fallbackServices();

    expect(hardware.clusters[0].name).toBe("atlas");
    expect(hardware.clusters[0].nodes.map((node) => node.alias)).toContain("oceanus");
    expect(hardware.specialty.map((node) => node.alias)).toEqual(["atlas-db", "theia"]);
    expect(services.services.some((service) => service.name === "Keycloak")).toBe(true);
    expect(services.services.some((service) => service.name === "Oceanus")).toBe(false);
    expect(services.services.some((service) => service.name === "Cassandra")).toBe(true);
    expect(services.services.some((service) => service.name === "AI Chat")).toBe(true);
    expect(services.services.find((service) => service.name === "AI Chat").link).toBe("https://bstein.dev/ai/chat");
    expect(services.services.find((service) => service.name === "Monero").link).toBe("https://bstein.dev/monero");
  });

  it("builds the rendered diagrams and network summary", () => {
    expect(buildHardwareDiagram({})).toContain("Titan Lab");
    expect(buildHardwareDiagram({})).toContain("Atlas k3s cluster");
    expect(buildHardwareDiagram({})).toContain("Dedicated non-cluster hosts");
    expect(buildNetworkDiagram()).toContain("oauth2-proxy");
    expect(buildPipelineDiagram()).toContain("Flux");
    expect(fallbackNetwork().ingress_gateway).toContain("Traefik");
    expect(fallbackMetrics()).toEqual({
      dashboard: "https://metrics.bstein.dev",
      description: "Atlas platform metrics.",
    });
  });
});
