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

import { parseHwpodNativeAccessProfile } from "./hwpod-native-vite.config";
import { firstAllowedNavPath } from "../src/stores/auth";

describe("HWPOD native Cloud Console profile", () => {
  it("accepts the YAML-rendered HWPOD-only navigation profile", () => {
    const profile = parseHwpodNativeAccessProfile(JSON.stringify({
      id: "hwpod-native-l1",
      allowedNavIds: ["admin.hwpodGroups"],
      startPath: "/hwpods/devices",
    }));
    expect(profile).toEqual({ id: "hwpod-native-l1", allowedNavIds: ["admin.hwpodGroups"], startPath: "/hwpods/devices" });
    expect(firstAllowedNavPath(profile.allowedNavIds)).toBe(profile.startPath);
  });

  it("fails closed without a declared navigation profile", () => {
    expect(() => parseHwpodNativeAccessProfile(undefined)).toThrow(/HWPOD_WEB_ACCESS_PROFILE_JSON/u);
  });
});
