CI / quality (push) Failing after 6m22s
Implements Max_Code_Quality_CICD_Production.md: TypeScript strict mode, ESLint flat config with type-checking and security plugin, Prettier, Husky + lint-staged, Vitest with 80%+ coverage (473 tests), Playwright e2e, Electron security hardening (contextIsolation, CSP, IPC validation), electron-builder + electron-updater, Dockerfile, Gitea Actions CI/release workflows, and SonarQube docker-compose setup. Also fixes two real bugs found while writing tests: unawaited clipboard promises and a mermaid container ref timing issue in CoachDrawingView. Fixes lint-staged on Windows/Node 24 by invoking eslint/prettier via `node <bin>.js` instead of their .cmd shims, which Node's child_process now refuses to spawn without shell:true. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
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()
|
|
})
|
|
})
|