import { describe, it, expect } from "vitest";
import { configuredNavEntries, SERVICE_TYPE_NAV_ENTRIES } from "../navEntries";

describe("navEntries", () => {
	it("returns no entries when no types are configured", () => {
		expect(configuredNavEntries(new Set())).toEqual([]);
	});

	it("returns Jellyfin when jellyfin is configured", () => {
		const entries = configuredNavEntries(new Set(["jellyfin"]));
		expect(entries).toHaveLength(1);
		expect(entries[0].label).toBe("Jellyfin");
		expect(entries[0].path).toBe("/services/jellyfin");
	});

	it("returns one SSH Tasks entry when ssh_tasks is configured", () => {
		const entries = configuredNavEntries(new Set(["ssh_tasks"]));
		expect(entries).toHaveLength(1);
		expect(entries[0].label).toBe("SSH Tasks");
	});

	it("returns all observability entries", () => {
		const entries = configuredNavEntries(
			new Set(["alertmanager", "prometheus"]),
		);
		expect(entries.map((e) => e.label)).toEqual(["Alertmanager", "Prometheus"]);
	});

	it("returns Backups + Authentik when configured", () => {
		const entries = configuredNavEntries(new Set(["backups", "authentik"]));
		expect(entries.map((e) => e.label)).toEqual(["Backups", "Authentik"]);
	});

	it("nextcloud has no nav entries in the static map", () => {
		expect(
			SERVICE_TYPE_NAV_ENTRIES.filter((e) => e.serviceType === "nextcloud"),
		).toEqual([]);
	});

	it("preserves declaration order across mixed types", () => {
		const entries = configuredNavEntries(
			new Set(["authentik", "ssh_tasks", "jellyfin"]),
		);
		expect(entries.map((e) => e.label)).toEqual([
			"Jellyfin",
			"SSH Tasks",
			"Authentik",
		]);
	});
});
