feat: ship v1.1.0 writer toolkit with templates, import, export, and inspiration capture
Implement chapter templates, txt/md/docx import, submission export presets, and global inspiration shortcut. Split import handlers into a separate main bundle and fix EditorLayout setTarget loop that broke E2E. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { replaceChapterTemplate, plainTextToEditorHtml } from '../../src/shared/chapter-template'
|
||||
|
||||
const baseCtx = {
|
||||
chapterNumber: 1,
|
||||
chapterTitle: '测试',
|
||||
penName: '笔名',
|
||||
date: '2026-07-08',
|
||||
volumeName: '第一卷',
|
||||
previousChapterTitle: '上一章',
|
||||
outlineItem: '',
|
||||
characterList: '甲,乙'
|
||||
}
|
||||
|
||||
describe('chapter-template', () => {
|
||||
it('UT-TEMPL-01: replaces chapterNumber and chapterTitle', () => {
|
||||
const result = replaceChapterTemplate('第{chapterNumber}章 {chapterTitle}', {
|
||||
...baseCtx,
|
||||
chapterNumber: 5,
|
||||
chapterTitle: '觉醒'
|
||||
})
|
||||
expect(result).toBe('第5章 觉醒')
|
||||
})
|
||||
|
||||
it('UT-TEMPL-02: replaces volumeName', () => {
|
||||
const result = replaceChapterTemplate('卷:{volumeName}', {
|
||||
...baseCtx,
|
||||
volumeName: '第一卷 觉醒'
|
||||
})
|
||||
expect(result).toBe('卷:第一卷 觉醒')
|
||||
})
|
||||
|
||||
it('UT-TEMPL-03: replaces characterList', () => {
|
||||
const result = replaceChapterTemplate('出场:{characterList}', baseCtx)
|
||||
expect(result).toBe('出场:甲,乙')
|
||||
})
|
||||
|
||||
it('plainTextToEditorHtml wraps paragraphs', () => {
|
||||
const html = plainTextToEditorHtml('第一段\n\n第二段')
|
||||
expect(html).toContain('<p>')
|
||||
expect(html).toContain('第一段')
|
||||
expect(html).toContain('第二段')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user