mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 07:34:25 +00:00
feat(transcript): add Chinese script choices
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user