mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-27 15:13:37 +08:00
test: 添加 PlantUML render 端点 + watcher 生命周期测试
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
bc7bb0a9a9
commit
375646546e
@ -887,3 +887,26 @@ describe('Activity Stats API', () => {
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
})
|
||||
|
||||
// ── PlantUML Render API ──────────────────────────────────────────────────
|
||||
|
||||
describe('PlantUML Render API', () => {
|
||||
it('POST plantuml/render returns valid response', async () => {
|
||||
const { req, url, segments } = makeRequest('POST', '/api/settings/plantuml/render', {
|
||||
code: '@startuml\nAlice -> Bob\n@enduml',
|
||||
})
|
||||
const res = await handleSettingsApi(req, url, segments)
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json() as { svg: string | null; error?: string }
|
||||
// svg 可能为 null(未配置 jar)或为有效 SVG 字符串
|
||||
expect(typeof body.svg === 'string' || body.svg === null).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects non-POST methods for plantuml render', async () => {
|
||||
const { req, url, segments } = makeRequest('GET', '/api/settings/plantuml/render')
|
||||
const res = await handleSettingsApi(req, url, segments)
|
||||
|
||||
expect(res.status).toBe(405)
|
||||
})
|
||||
})
|
||||
|
||||
@ -556,4 +556,22 @@ describe('WorkspaceService', () => {
|
||||
{ path: 'b.txt', oldPath: undefined, status: 'modified', additions: 2, deletions: 3 },
|
||||
])
|
||||
})
|
||||
|
||||
it('starts and stops a file watcher without errors', async () => {
|
||||
const workDir = await makeTempDir('workspace-service-watcher-')
|
||||
const service = new WorkspaceService(async () => workDir)
|
||||
|
||||
service.startWatcher('session-watcher', workDir)
|
||||
service.startWatcher('session-watcher', workDir)
|
||||
service.stopWatcher('session-watcher')
|
||||
})
|
||||
|
||||
it('stopAllWatchers cleans up all active watchers', async () => {
|
||||
const workDir = await makeTempDir('workspace-service-watcher-all-')
|
||||
const service = new WorkspaceService(async () => workDir)
|
||||
|
||||
service.startWatcher('session-1', workDir)
|
||||
service.startWatcher('session-2', workDir)
|
||||
service.stopAllWatchers()
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user