import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { GitOpsService } from '../src/services/gitops.service.js'; import { AppsService } from '../src/services/apps.service.js'; import os from 'os'; import path from 'path'; import fs from 'fs/promises'; describe('AppsService', () => { let gitops: GitOpsService; let apps: AppsService; let testRepoDir: string; beforeEach(async () => { testRepoDir = path.join(os.tmpdir(), `naxos-apps-test-${Date.now()}-${Math.random().toString(36).slice(2)}`); gitops = new GitOpsService(testRepoDir); await gitops.init(); apps = new AppsService(gitops); }); afterEach(async () => { try { await fs.rm(testRepoDir, { recursive: true, force: true }); } catch {} }); it('should return the curated app catalog', () => { const catalog = apps.getCatalog(); expect(catalog.length).toBeGreaterThanOrEqual(5); const immich = catalog.find((c) => c.id === 'immich'); expect(immich).toBeDefined(); expect(immich?.recommendedRuntime).toBe('systemd'); }); it('should install app into active workloads', async () => { const installed = await apps.installApp({ appId: 'vaultwarden' }); expect(installed.appId).toBe('vaultwarden'); expect(installed.status).toBe('running'); const list = apps.getInstalledApps(); expect(list.some((a) => a.appId === 'vaultwarden')).toBe(true); }); });