feat: deliver P2 v0.2.0 with unified editor, search, and snapshots
Implement schema v2 migration, outline/setting/inspiration CRUD, unified TipTap editing, reference panel with mentions, FTS global search, chapter version history, writing landmarks, word frequency analysis, light theme contrast fixes, and full unit/E2E test coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { DatabaseSync } from 'node:sqlite'
|
||||
import { migrate } from '../../src/main/db/migrate'
|
||||
import { SettingRepository } from '../../src/main/db/repositories/setting.repo'
|
||||
import { VolumeRepository } from '../../src/main/db/repositories/volume.repo'
|
||||
import { ChapterRepository } from '../../src/main/db/repositories/chapter.repo'
|
||||
import type { SqliteDb } from '../../src/main/db/types'
|
||||
|
||||
describe('SettingRepository', () => {
|
||||
let db: SqliteDb
|
||||
let repo: SettingRepository
|
||||
let chapterId: string
|
||||
|
||||
beforeEach(() => {
|
||||
db = new DatabaseSync(':memory:')
|
||||
migrate(db)
|
||||
repo = new SettingRepository(db)
|
||||
const vol = new VolumeRepository(db).create('卷一', 0)
|
||||
chapterId = new ChapterRepository(db).create(vol.id, '第一章', 0).id
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
db.close()
|
||||
})
|
||||
|
||||
it('creates and lists settings by type', () => {
|
||||
repo.create('character', '林远')
|
||||
repo.create('location', '青云山')
|
||||
expect(repo.list('character')).toHaveLength(1)
|
||||
expect(repo.list('character')[0].name).toBe('林远')
|
||||
})
|
||||
|
||||
it('syncs chapter refs', () => {
|
||||
const setting = repo.create('character', '主角')
|
||||
repo.syncChapterRefs(setting.id, [chapterId])
|
||||
const updated = repo.get(setting.id)!
|
||||
expect(updated.chapterIds).toEqual([chapterId])
|
||||
})
|
||||
|
||||
it('updates and deletes setting', () => {
|
||||
const setting = repo.create('character', '旧名')
|
||||
repo.update(setting.id, { name: '新名' })
|
||||
expect(repo.get(setting.id)!.name).toBe('新名')
|
||||
repo.delete(setting.id)
|
||||
expect(repo.get(setting.id)).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user