feat: ship v0.6.0 with cockpit, knowledge base, and chapter bridge
Deliver P5 writer workflow: writing cockpit, manual knowledge CRUD with review, chapter bridge with optional AI, publish status, and stock buffer reminders. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { describe, it, expect, 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 { ChapterRepository } from '../../src/main/db/repositories/chapter.repo'
|
||||
import { CockpitService } from '../../src/main/services/cockpit.service'
|
||||
import { GlobalSettingsService } from '../../src/main/services/global-settings'
|
||||
import type { SqliteDb } from '../../src/main/db/types'
|
||||
import { mkdtempSync, rmSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
|
||||
describe('CockpitService', () => {
|
||||
let db: SqliteDb
|
||||
let settingsDir: string
|
||||
afterEach(() => {
|
||||
db?.close()
|
||||
if (settingsDir) rmSync(settingsDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('UT-COCK-01: getSummary counts words and ready stock', () => {
|
||||
db = new DatabaseSync(':memory:')
|
||||
migrate(db)
|
||||
settingsDir = mkdtempSync(join(tmpdir(), 'bilin-cockpit-'))
|
||||
const settings = new GlobalSettingsService(settingsDir)
|
||||
const volId = new VolumeRepository(db).create('卷一', 0).id
|
||||
const chapterRepo = new ChapterRepository(db)
|
||||
const ch = chapterRepo.create(volId, 'A', 0, '<p>hello world</p>')
|
||||
chapterRepo.setPublishStatus(ch.id, 'ready')
|
||||
const service = new CockpitService(db, settings)
|
||||
const summary = service.getSummary(volId)
|
||||
expect(summary.totalWords).toBeGreaterThan(0)
|
||||
expect(summary.stockReadyCount).toBe(1)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user