import { describe, it, expect } from 'vitest';
import { readFileSync } from 'fs';
import { parse } from 'yaml';

describe('config/default.yaml', () => {
  const asRecord = (value: unknown): Record<string, unknown> => (
    value && typeof value === 'object' ? value as Record<string, unknown> : {}
  );

  it('does not use deprecated server.tailscale_only key', () => {
    const raw = readFileSync('config/default.yaml', 'utf-8');
    const parsed = asRecord(parse(raw));
    const server = asRecord(parsed.server);

    expect(parsed).toBeTruthy();
    expect(server).toBeTruthy();
    expect(server.tailscale_only).toBeUndefined();
  });

  it('documents server.tailscale.* shape', () => {
    const raw = readFileSync('config/default.yaml', 'utf-8');
    const parsed = asRecord(parse(raw));
    const server = asRecord(parsed.server);
    const tailscale = asRecord(server.tailscale);

    expect(tailscale).toBeTruthy();
    expect(typeof tailscale).toBe('object');
    expect(typeof tailscale.serve).toBe('boolean');
  });
});
