Phase 7~8 구현: 테스트 + 빌드 + CI/CD + SoundEffect + AutoLaunch + UI 리디자인
- vitest 41개 단위 테스트 (HistoryService, DictionaryService, CustomInstructionService, VoiceModeService, D3ROError) - electron-builder.yml (NSIS, asarUnpack, extraResources) - .gitlab-ci.yml (lint, typecheck, test, build, release) - SoundEffectService: WAV 프리로드 + PowerShell 재생 + VoiceMode 연동 - AutoLaunchService: app.setLoginItemSettings + ConfigService 동기화 - TextInsertService: 간이 삽입 검증 (EditMonitor 경량) - 번들링 인프라: SoX 다운로드 스크립트, PyInstaller 빌드, 경로 해상도 유틸 - AudioCaptureService/LocalSTTService: 번들 경로 자동 감지 - 08-design-system.md 기반 MUI 테마 (다크+라이트+auto 테마 시스템) - 전체 UI 컴포넌트 리디자인: AppLayout, Dashboard, StatusBar, History, Dictionary, Commands, Settings - 효과음 WAV 생성: recording-start, recording-stop, error - EPIPE 에러 핸들링 추가
This commit is contained in:
parent
ed5541f769
commit
3f4d0c5828
40 changed files with 6034 additions and 580 deletions
116
tests/main/services/DictionaryService.test.ts
Normal file
116
tests/main/services/DictionaryService.test.ts
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// tests/main/services/DictionaryService.test.ts
|
||||
// DictionaryService 단위 테스트 — DB 모킹
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||
|
||||
function createMockQueryBuilder(data: unknown[] = []) {
|
||||
const builder: Record<string, unknown> = {}
|
||||
|
||||
builder.values = vi.fn(() => ({ run: vi.fn(() => ({ changes: 1 })) }))
|
||||
builder.from = vi.fn(() => builder)
|
||||
builder.where = vi.fn(() => builder)
|
||||
builder.orderBy = vi.fn(() => builder)
|
||||
builder.limit = vi.fn(() => builder)
|
||||
builder.offset = vi.fn(() => builder)
|
||||
builder.set = vi.fn(() => builder)
|
||||
builder.get = vi.fn(() => data[0] ?? null)
|
||||
builder.all = vi.fn(() => data)
|
||||
builder.run = vi.fn(() => ({ changes: 1 }))
|
||||
|
||||
return builder
|
||||
}
|
||||
|
||||
const mockDb = {
|
||||
insert: vi.fn(() => createMockQueryBuilder()),
|
||||
select: vi.fn(() => createMockQueryBuilder()),
|
||||
update: vi.fn(() => createMockQueryBuilder()),
|
||||
delete: vi.fn(() => createMockQueryBuilder())
|
||||
}
|
||||
|
||||
vi.mock('../../../src/main/db', () => ({
|
||||
getDatabase: () => mockDb
|
||||
}))
|
||||
|
||||
vi.mock('../../../src/main/services/LoggerService', () => ({
|
||||
getLogger: () => ({
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
debug: vi.fn()
|
||||
})
|
||||
}))
|
||||
|
||||
let getDictionaryService: () => ReturnType<typeof import('../../../src/main/services/DictionaryService')['getDictionaryService']>
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules()
|
||||
vi.clearAllMocks()
|
||||
const mod = await import('../../../src/main/services/DictionaryService')
|
||||
getDictionaryService = mod.getDictionaryService
|
||||
})
|
||||
|
||||
describe('DictionaryService', () => {
|
||||
describe('add', () => {
|
||||
it('insert를 호출하고 엔트리를 반환한다', () => {
|
||||
const svc = getDictionaryService()
|
||||
const entry = svc.add({ word: 'AI', pronunciation: '에이아이', category: 'technical' })
|
||||
|
||||
expect(mockDb.insert).toHaveBeenCalled()
|
||||
expect(entry.id).toBeDefined()
|
||||
expect(entry.word).toBe('AI')
|
||||
expect(entry.pronunciation).toBe('에이아이')
|
||||
expect(entry.category).toBe('technical')
|
||||
expect(entry.usageCount).toBe(0)
|
||||
})
|
||||
|
||||
it('기본 카테고리는 user이다', () => {
|
||||
const svc = getDictionaryService()
|
||||
const entry = svc.add({ word: '테스트' })
|
||||
expect(entry.category).toBe('user')
|
||||
})
|
||||
|
||||
it('pronunciation 미지정 시 null이다', () => {
|
||||
const svc = getDictionaryService()
|
||||
const entry = svc.add({ word: 'test' })
|
||||
expect(entry.pronunciation).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('update', () => {
|
||||
it('없는 ID에 대해 null을 반환한다', () => {
|
||||
// select().from().where().get()이 null 반환
|
||||
const svc = getDictionaryService()
|
||||
expect(svc.update({ id: 'nonexistent', word: 'test' })).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('delete', () => {
|
||||
it('delete 쿼리를 실행하고 changes > 0이면 true를 반환한다', () => {
|
||||
const svc = getDictionaryService()
|
||||
expect(svc.delete('some-id')).toBe(true)
|
||||
expect(mockDb.delete).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('incrementUsage', () => {
|
||||
it('update 쿼리를 실행한다', () => {
|
||||
const svc = getDictionaryService()
|
||||
svc.incrementUsage('some-id')
|
||||
expect(mockDb.update).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('getPromptHints', () => {
|
||||
it('빈 목록에서 빈 문자열을 반환한다', () => {
|
||||
const svc = getDictionaryService()
|
||||
expect(svc.getPromptHints()).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('dispose', () => {
|
||||
it('에러 없이 호출된다', () => {
|
||||
const svc = getDictionaryService()
|
||||
expect(() => svc.dispose()).not.toThrow()
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue