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,37 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { AiClientService } from '../../src/main/services/ai-client.service'
|
||||
import {
|
||||
buildNamingPrompt,
|
||||
collectChaptersPlain,
|
||||
parseNamingJson
|
||||
} from '../../src/main/services/naming-check.service'
|
||||
import { DEFAULT_AI_CONFIG } from '../../src/shared/types'
|
||||
|
||||
describe('naming check integration', () => {
|
||||
const client = new AiClientService(() => DEFAULT_AI_CONFIG)
|
||||
|
||||
it('IT-NAME-01: detects 林远 vs 林悦 from LM Studio', async () => {
|
||||
const prompt = buildNamingPrompt(
|
||||
['林远'],
|
||||
collectChaptersPlain([{ title: '第一章', content: '<p>林悦走进院子,环顾四周。</p>' }]),
|
||||
[]
|
||||
)
|
||||
let response = await client.chat([{ role: 'user', content: prompt }])
|
||||
let rows
|
||||
try {
|
||||
rows = parseNamingJson(response)
|
||||
} catch {
|
||||
response = await client.chat([
|
||||
{ role: 'user', content: `${prompt}\n\n仅返回 JSON 数组,不要 markdown 或其它说明。` }
|
||||
])
|
||||
rows = parseNamingJson(response)
|
||||
}
|
||||
expect(rows.length).toBeGreaterThan(0)
|
||||
const hit = rows.some(
|
||||
(r) =>
|
||||
(r.termA.includes('林远') && r.termB.includes('林悦')) ||
|
||||
(r.termA.includes('林悦') && r.termB.includes('林远'))
|
||||
)
|
||||
expect(hit).toBe(true)
|
||||
}, 180_000)
|
||||
})
|
||||
Reference in New Issue
Block a user