import { describe, it, expect, vi } from 'vitest' import fs from 'fs' import path from 'path' import { getLocalLLMService, startLocalLLMAvailability } from '../../src/main/services/LocalLLMService' import { useRedHarness } from './harness' useRedHarness() describe('유스케이스: 앱 시작 시 로컬 LLM 폴링', () => { it('startLocalLLMAvailability 는 ensureRunning 과 startPolling 을 호출한다', async () => { const llm = getLocalLLMService() const ensure = vi.spyOn(llm, 'ensureRunning').mockResolvedValue('not-installed') const poll = vi.spyOn(llm, 'startPolling') await startLocalLLMAvailability() expect(ensure).toHaveBeenCalledTimes(1) expect(poll).toHaveBeenCalledTimes(1) llm.stopPolling() }) it('bootstrap llm-polling 스텝은 startLocalLLMAvailability 를 호출하고 no-op 주석이 아니다', () => { const src = fs.readFileSync( path.join(__dirname, '../../src/main/bootstrap.ts'), 'utf-8', ) expect(src).toContain('startLocalLLMAvailability') expect(src).not.toContain('LocalLLMService replaced by PremiumLLMService') }) it('폴링을 건너뛰면 isAvailable 이 계속 false 인 채 남는 경로를 허용하지 않는다', async () => { const llm = getLocalLLMService() expect(llm.isAvailable()).toBe(false) const poll = vi.spyOn(llm, 'startPolling') await startLocalLLMAvailability() expect(poll).toHaveBeenCalled() llm.stopPolling() }) })