import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';

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

const root = resolve(__dirname, '..');

describe('user file system frontend wiring', () => {
  it('routes API client helpers to user file endpoints', () => {
    const apiSource = readFileSync(resolve(root, 'lib/api.ts'), 'utf8');

    expect(apiSource).toContain('/api/user-files/browse');
    expect(apiSource).toContain('/api/user-files/upload');
    expect(apiSource).toContain('/api/user-files/download');
    expect(apiSource).toContain('/api/user-files/preview');
    expect(apiSource).toContain('/api/user-files/delete');
    expect(apiSource).toContain('/api/user-files/mkdir');
  });

  it('does not wire the Files page to workspace or MinIO management APIs', () => {
    const pageSource = readFileSync(resolve(root, 'app/(app)/files/page.tsx'), 'utf8');

    expect(pageSource).toContain('browseUserFiles');
    expect(pageSource).toContain('uploadUserFile');
    expect(pageSource).not.toContain('browseWorkspace');
    expect(pageSource).not.toContain('uploadToWorkspace');
    expect(pageSource).not.toContain('MinIO');
    expect(pageSource).not.toContain('bucket');
    expect(pageSource).not.toContain('accessKey');
    expect(pageSource).not.toContain('secretKey');
  });
});
