- 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 에러 핸들링 추가
87 lines
3 KiB
TypeScript
87 lines
3 KiB
TypeScript
// tests/helpers/createTestDb.ts
|
|
// in-memory SQLite + drizzle-orm 스키마 적용
|
|
|
|
import Database from 'better-sqlite3'
|
|
import { drizzle, type BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'
|
|
import * as schema from '../../src/main/db/schema'
|
|
|
|
/**
|
|
* 테스트용 in-memory SQLite DB를 생성한다.
|
|
* 각 테스트에서 독립적인 DB를 사용할 수 있다.
|
|
*/
|
|
export function createTestDb(): {
|
|
db: BetterSQLite3Database<typeof schema>
|
|
sqlite: Database.Database
|
|
close: () => void
|
|
} {
|
|
const sqlite = new Database(':memory:')
|
|
|
|
sqlite.pragma('journal_mode = WAL')
|
|
sqlite.pragma('foreign_keys = ON')
|
|
|
|
// 테이블 생성 (src/main/db/index.ts의 SQL과 동일)
|
|
sqlite.exec(`
|
|
CREATE TABLE IF NOT EXISTS history (
|
|
id TEXT PRIMARY KEY,
|
|
original_text TEXT NOT NULL,
|
|
polished_text TEXT,
|
|
focused_app TEXT,
|
|
focused_app_name TEXT,
|
|
focused_app_window_title TEXT,
|
|
mode TEXT NOT NULL DEFAULT 'dictation',
|
|
status TEXT NOT NULL DEFAULT 'completed',
|
|
error_code TEXT,
|
|
audio_local_path TEXT,
|
|
duration REAL NOT NULL,
|
|
detected_language TEXT,
|
|
mic_device TEXT,
|
|
word_count INTEGER NOT NULL DEFAULT 0,
|
|
stt_model TEXT,
|
|
llm_model TEXT,
|
|
stt_latency_ms INTEGER,
|
|
llm_latency_ms INTEGER,
|
|
created_at INTEGER NOT NULL,
|
|
updated_at INTEGER NOT NULL,
|
|
app_version TEXT NOT NULL DEFAULT '1.0.0'
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_history_created_at ON history(created_at DESC);
|
|
CREATE INDEX IF NOT EXISTS idx_history_status ON history(status);
|
|
|
|
CREATE TABLE IF NOT EXISTS dictionary (
|
|
id TEXT PRIMARY KEY,
|
|
word TEXT NOT NULL,
|
|
pronunciation TEXT,
|
|
category TEXT NOT NULL DEFAULT 'user',
|
|
usage_count INTEGER NOT NULL DEFAULT 0,
|
|
last_used_at INTEGER,
|
|
created_at INTEGER NOT NULL,
|
|
updated_at INTEGER NOT NULL
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_dictionary_word_category ON dictionary(word, category);
|
|
CREATE INDEX IF NOT EXISTS idx_dictionary_created_at ON dictionary(created_at);
|
|
CREATE INDEX IF NOT EXISTS idx_dictionary_usage_count ON dictionary(usage_count DESC);
|
|
|
|
CREATE TABLE IF NOT EXISTS stats (
|
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
total_duration REAL NOT NULL DEFAULT 0,
|
|
total_words INTEGER NOT NULL DEFAULT 0,
|
|
session_count INTEGER NOT NULL DEFAULT 0,
|
|
streak_days INTEGER NOT NULL DEFAULT 0,
|
|
last_session_at INTEGER,
|
|
last_updated INTEGER NOT NULL
|
|
);
|
|
|
|
INSERT OR IGNORE INTO stats (id, total_duration, total_words, session_count, streak_days, last_updated)
|
|
VALUES (1, 0, 0, 0, 0, ${Date.now()});
|
|
`)
|
|
|
|
const db = drizzle(sqlite, { schema })
|
|
|
|
return {
|
|
db,
|
|
sqlite,
|
|
close: () => sqlite.close()
|
|
}
|
|
}
|