import { describe, expect, it } from 'vitest';
import { readFileSync } from 'node:fs';

describe('Coolify and Nixpacks deployment config', () => {
  it('defines a production start script that serves dist without Vite host blocking', () => {
    const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));

    expect(packageJson.scripts.start).toContain('sirv dist');
    expect(packageJson.scripts.start).toContain('--host 0.0.0.0');
    expect(packageJson.scripts.start).toContain('${PORT:-4321}');
    expect(packageJson.scripts.start).not.toContain('astro preview');
  });

  it('pins Nixpacks install, build, and start commands for Coolify', () => {
    const nixpacks = readFileSync('nixpacks.toml', 'utf8');

    expect(nixpacks).toContain('npm ci');
    expect(nixpacks).toContain('npm run build');
    expect(nixpacks).toContain('npm run start');
  });
});
