feat(transcript): add Chinese script choices

This commit is contained in:
yiling
2026-12-05 11:43:32 +08:00
parent 6c74413375
commit 70e4c63323
19 changed files with 242 additions and 29 deletions
@@ -144,7 +144,14 @@ describe('TranscriptService', () => {
})
it('validates provider capability, language and asset eligibility before queuing', async () => {
await expect(transcriptService.listLanguages()).resolves.toMatchObject({ model })
await expect(transcriptService.listLanguages()).resolves.toEqual({
model,
languages: [
{ code: 'en', name: 'English' },
{ code: 'zh-Hans', name: 'Chinese (Simplified)' },
{ code: 'zh-Hant', name: 'Chinese (Traditional)' },
],
})
await expect(transcriptService.generate(assetId, 'xx')).rejects.toMatchObject({ status: 400 })
await prisma.asset.update({ where: { id: assetId }, data: { mediaType: 'image/png' } })
await expect(transcriptService.generate(assetId, 'en')).rejects.toMatchObject({ status: 400 })
@@ -155,6 +162,20 @@ describe('TranscriptService', () => {
expect(await prisma.workflowTask.count({ where: { assetId } })).toBe(0)
})
it('only offers Chinese scripts when the provider supports Chinese', async () => {
const list = { model, languages: [{ code: 'en', name: 'English' }] }
vi.mocked(fetch).mockImplementation(async () => Response.json(list))
await expect(transcriptService.listLanguages()).resolves.toEqual(list)
await expect(transcriptService.generate(assetId, 'zh-Hans')).rejects.toMatchObject({
status: 400,
})
await expect(transcriptService.generate(assetId, 'zh-Hant')).rejects.toMatchObject({
status: 400,
})
expect(await prisma.workflowTask.count({ where: { assetId } })).toBe(0)
})
it('requires an enabled Transcript Agent before contacting the provider or queuing', async () => {
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', 'false')
await expect(transcriptService.isGenerationEnabled()).resolves.toBe(false)