import { describe, it, expect, vi, beforeEach } from 'vitest' const NotificationShow = vi.fn() class NotificationMock { show = NotificationShow constructor(public options: { title: string; body: string }) {} } vi.mock('electron', () => ({ Notification: NotificationMock })) const synthesizeSpeech = vi.fn(async () => Buffer.from([1, 2, 3])) vi.mock('../../src/main/ai/elevenlabs', () => ({ synthesizeSpeech })) const sendToRenderer = vi.fn() vi.mock('../../src/main/windowBridge', () => ({ sendToRenderer })) interface DueReview { conceptId: number subject: string concept: string } const getDueReviews = vi.fn((): DueReview[] => []) const markReminded = vi.fn() vi.mock('../../src/main/coach/coachStore', () => ({ getDueReviews, markReminded })) const { startReviewScheduler } = await import('../../src/main/coach/reviewScheduler') describe('startReviewScheduler()', () => { beforeEach(() => { vi.clearAllMocks() vi.useFakeTimers() }) it('should not notify anything when no review is due', async () => { getDueReviews.mockReturnValue([]) startReviewScheduler() await vi.advanceTimersByTimeAsync(5 * 60 * 1000) expect(NotificationShow).not.toHaveBeenCalled() vi.useRealTimers() }) it('should show a notification, speak and mark reviews as reminded when due', async () => { getDueReviews.mockReturnValue([ { conceptId: 1, subject: 'algebre', concept: 'equations' }, { conceptId: 2, subject: 'algebre', concept: 'fractions' } ]) startReviewScheduler() await vi.advanceTimersByTimeAsync(5 * 60 * 1000) expect(NotificationShow).toHaveBeenCalled() expect(sendToRenderer).toHaveBeenCalledWith('proactive-speech', expect.anything()) expect(markReminded).toHaveBeenCalledWith(1) expect(markReminded).toHaveBeenCalledWith(2) vi.useRealTimers() }) })