feat: ship v0.4.0 with interactive writing mode
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { DatabaseSync } from 'node:sqlite'
|
||||
import { migrate } from '../../src/main/db/migrate'
|
||||
import { VolumeRepository } from '../../src/main/db/repositories/volume.repo'
|
||||
import { AiSessionRepository } from '../../src/main/db/repositories/ai-session.repo'
|
||||
import { InteractiveRepository } from '../../src/main/db/repositories/interactive.repo'
|
||||
import { ChapterRepository } from '../../src/main/db/repositories/chapter.repo'
|
||||
import { InteractiveWritingService } from '../../src/main/services/interactive-writing.service'
|
||||
import type { SqliteDb } from '../../src/main/db/types'
|
||||
|
||||
describe('InteractiveWritingService.finishChapter', () => {
|
||||
let db: SqliteDb
|
||||
let service: InteractiveWritingService
|
||||
let volId: string
|
||||
let flowId: string
|
||||
|
||||
beforeEach(() => {
|
||||
db = new DatabaseSync(':memory:')
|
||||
migrate(db)
|
||||
volId = new VolumeRepository(db).create('卷一', 0).id
|
||||
const session = new AiSessionRepository(db).create('测试', 'test-model')
|
||||
const flow = new InteractiveRepository(db).create(session.id)
|
||||
flowId = flow.id
|
||||
const repo = new InteractiveRepository(db)
|
||||
repo.addScene(flowId, '<p>场景一</p>', 'A')
|
||||
repo.addScene(flowId, '<p>场景二</p>', 'B')
|
||||
service = new InteractiveWritingService(db, {
|
||||
chat: async () => ''
|
||||
} as never)
|
||||
})
|
||||
|
||||
afterEach(() => db.close())
|
||||
|
||||
it('IT-INT-04: merges scenes into new interactive chapter', () => {
|
||||
const { chapterId } = service.finishChapter(flowId, volId, '交互初稿')
|
||||
const ch = new ChapterRepository(db).get(chapterId)!
|
||||
expect(ch.origin).toBe('interactive')
|
||||
expect(ch.content).toContain('场景一')
|
||||
expect(ch.content).toContain('场景二')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user