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,50 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { DatabaseSync } from 'node:sqlite'
|
||||
import { migrate } from '../../src/main/db/migrate'
|
||||
import { OutlineRepository } from '../../src/main/db/repositories/outline.repo'
|
||||
import type { SqliteDb } from '../../src/main/db/types'
|
||||
|
||||
describe('OutlineRepository', () => {
|
||||
let db: SqliteDb
|
||||
let repo: OutlineRepository
|
||||
|
||||
beforeEach(() => {
|
||||
db = new DatabaseSync(':memory:')
|
||||
migrate(db)
|
||||
repo = new OutlineRepository(db)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
db.close()
|
||||
})
|
||||
|
||||
it('creates nested outline items', () => {
|
||||
const parent = repo.create(null, '第一幕', 0)
|
||||
const child = repo.create(parent.id, '开端', 0)
|
||||
expect(repo.listTree()).toHaveLength(1)
|
||||
expect(repo.listTree()[0].children).toHaveLength(1)
|
||||
expect(repo.listTree()[0].children![0].id).toBe(child.id)
|
||||
})
|
||||
|
||||
it('lists uncovered items without chapter link', () => {
|
||||
const item = repo.create(null, '未覆盖', 0)
|
||||
repo.update(item.id, { chapterId: null })
|
||||
expect(repo.listUncovered()).toHaveLength(1)
|
||||
expect(repo.listUncovered()[0].id).toBe(item.id)
|
||||
})
|
||||
|
||||
it('deletes parent and cascades children', () => {
|
||||
const parent = repo.create(null, '父节点', 0)
|
||||
repo.create(parent.id, '子节点', 0)
|
||||
repo.delete(parent.id)
|
||||
expect(repo.listFlat()).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('moves item to new parent', () => {
|
||||
const a = repo.create(null, 'A', 0)
|
||||
const b = repo.create(null, 'B', 1)
|
||||
const child = repo.create(a.id, 'child', 0)
|
||||
repo.move(child.id, b.id, 0)
|
||||
expect(repo.get(child.id)!.parentId).toBe(b.id)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user