import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; import os from 'node:os'; import path from 'node:path'; import test from 'node:test'; import { createCleanupService } from './mindspace-cleanup.mjs'; test('lists workspace temp files for cleanup', async () => { const h5Root = await fs.mkdtemp(path.join(os.tmpdir(), 'mindspace-cleanup-')); const storageRoot = path.join(h5Root, 'data', 'mindspace'); const username = 'john'; const tempFile = path.join(h5Root, 'temp', username, 'draft.html'); await fs.mkdir(path.dirname(tempFile), { recursive: true }); await fs.writeFile(tempFile, ''); const pool = { query: async () => [[], []], }; const cleanup = createCleanupService(pool, { h5Root, storageRoot }); const items = await cleanup.listCandidates('user-1', username); assert.equal(items.length, 1); assert.equal(items[0].kind, 'workspace_temp'); assert.equal(items[0].label, 'draft.html'); });