import { describe, expect, it } from 'vitest';
import {
  MemoryProjectStorage,
  projectFilePath,
} from '@learnitive/project-storage';
import { collectProjectCompileFiles } from '../project-files';

describe('collectProjectCompileFiles', () => {
  it('preserves arbitrary binary files and excludes Git internals', async () => {
    const storage = new MemoryProjectStorage();
    await storage.writeFile(projectFilePath('main.tex'), new TextEncoder().encode('test'));
    await storage.writeFile(projectFilePath('figures/a.pdf'), new Uint8Array([0, 255, 1]));
    await storage.writeFile(projectFilePath('.git/HEAD'), new TextEncoder().encode('ref'));

    const snapshot = await collectProjectCompileFiles(storage, 'main.tex');
    expect(snapshot.files.map((file) => file.path)).toEqual([
      'figures/a.pdf',
      'main.tex',
    ]);
    expect(snapshot.files[0]?.content).toEqual(new Uint8Array([0, 255, 1]));
  });
});
