feat: ship v0.3.0 with P2.1 editor polish and P3 AI collaboration
Add chapter reorder, search replace, inspiration capture, and AI chat with context editing, settings, offline handling, and naming checks. Fix dev black screen by keeping process.env reads in the main process only. 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 { mkdtempSync, rmSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
import { BookRegistryService } from '../../src/main/services/book-registry'
|
||||
import { ChapterRepository } from '../../src/main/db/repositories/chapter.repo'
|
||||
import { VolumeRepository } from '../../src/main/db/repositories/volume.repo'
|
||||
import { SettingRepository } from '../../src/main/db/repositories/setting.repo'
|
||||
import {
|
||||
collectChaptersPlain,
|
||||
buildNamingCorpus,
|
||||
findLocalNamingConflicts
|
||||
} from '../../src/main/services/naming-check.service'
|
||||
import type { SqliteDb } from '../../src/main/db/types'
|
||||
|
||||
describe('naming check data path', () => {
|
||||
let userDir: string
|
||||
let registry: BookRegistryService
|
||||
let bookId: string
|
||||
let volId: string
|
||||
let db: SqliteDb
|
||||
|
||||
beforeEach(() => {
|
||||
userDir = mkdtempSync(join(tmpdir(), 'bilin-name-repo-'))
|
||||
registry = new BookRegistryService(userDir)
|
||||
const meta = registry.create({ name: '测试书', category: '玄幻' })
|
||||
bookId = meta.id
|
||||
db = registry.getDb(bookId)
|
||||
volId = new VolumeRepository(db).create('卷一', 0).id
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
db?.close()
|
||||
rmSync(userDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('finds 林远 vs 林悦 from setting description in corpus', () => {
|
||||
new SettingRepository(db).create('character', '林远', '<p>正文中出现了林悦这一名字。</p>')
|
||||
|
||||
const settings = registry.getSettingRepo(bookId).list()
|
||||
const corpus = buildNamingCorpus(settings, registry.getChapterRepo(bookId).list())
|
||||
const local = findLocalNamingConflicts(
|
||||
settings.map((s) => s.name),
|
||||
corpus,
|
||||
[]
|
||||
)
|
||||
|
||||
expect(local.length).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user