import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import path from 'node:path'; import { afterEach, describe, expect, it } from 'vitest'; import { listFiles } from '../src/projects.js'; const tempRoots: string[] = []; async function makeProjectsRoot() { const root = await mkdtemp(path.join(tmpdir(), 'od-project-files-')); tempRoots.push(root); return path.join(root, 'projects'); } afterEach(async () => { await Promise.all(tempRoots.splice(0).map((root) => rm(root, { recursive: true, force: true }))); }); describe('listFiles', () => { it('includes the absolute local path for each visible project file', async () => { const projectsRoot = await makeProjectsRoot(); const projectId = 'project-1'; const projectDir = path.join(projectsRoot, projectId); const filePath = path.join(projectDir, 'alpha.html'); await mkdir(projectDir, { recursive: true }); await writeFile(filePath, ''); const files = await listFiles(projectsRoot, projectId); expect(files).toEqual([ expect.objectContaining({ name: 'alpha.html', path: 'alpha.html', localPath: filePath, }), ]); }); });