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,44 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { DatabaseSync } from 'node:sqlite'
|
||||
import { migrate } from '../../src/main/db/migrate'
|
||||
import { BookmarkRepository } from '../../src/main/db/repositories/bookmark.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('BookmarkRepository', () => {
|
||||
let db: SqliteDb
|
||||
let repo: BookmarkRepository
|
||||
let chapterId: string
|
||||
|
||||
beforeEach(() => {
|
||||
db = new DatabaseSync(':memory:')
|
||||
migrate(db)
|
||||
repo = new BookmarkRepository(db)
|
||||
const vol = new VolumeRepository(db).create('卷一', 0)
|
||||
chapterId = new ChapterRepository(db).create(vol.id, '第一章', 0).id
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
db.close()
|
||||
})
|
||||
|
||||
it('creates and lists bookmarks by chapter', () => {
|
||||
repo.create(chapterId, 100, '待办:补充描写', 'todo')
|
||||
expect(repo.listByChapter(chapterId)).toHaveLength(1)
|
||||
expect(repo.listByChapter(chapterId)[0].label).toBe('待办:补充描写')
|
||||
})
|
||||
|
||||
it('resolves bookmark', () => {
|
||||
const bm = repo.create(chapterId, 50, '伏笔', 'foreshadow')
|
||||
repo.resolve(bm.id, true)
|
||||
expect(repo.get(bm.id)!.resolved).toBe(true)
|
||||
expect(repo.list(undefined, false)).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('deletes bookmark', () => {
|
||||
const bm = repo.create(chapterId, 0, '研究笔记', 'research')
|
||||
repo.delete(bm.id)
|
||||
expect(repo.get(bm.id)).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user