mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
fix(video): transcribe archived videos and show progress (#560)
This commit is contained in:
@@ -29,6 +29,30 @@ describe('Transcript API', () => {
|
||||
expect(await response.json()).toEqual(list)
|
||||
})
|
||||
|
||||
it('requires project edit access to list file IDs with active transcription', async () => {
|
||||
const request = () => app.request('/projects/project-id/transcription-status')
|
||||
const permission = vi
|
||||
.spyOn(authzService, 'hasPermission')
|
||||
.mockRejectedValue(new HTTPException(403))
|
||||
const list = vi.spyOn(transcriptService, 'listActiveAssetIds').mockResolvedValue(['file-id'])
|
||||
|
||||
expect((await request()).status).toBe(403)
|
||||
expect(list).not.toHaveBeenCalled()
|
||||
|
||||
permission.mockResolvedValue(undefined)
|
||||
const response = await request()
|
||||
expect(response.status).toBe(200)
|
||||
expect(await response.json()).toEqual({ assetIds: ['file-id'] })
|
||||
expect(permission).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
type: ResourceType.Project,
|
||||
permission: Permission.Edit,
|
||||
id: 'project-id',
|
||||
}),
|
||||
)
|
||||
expect(list).toHaveBeenCalledWith('project-id')
|
||||
})
|
||||
|
||||
it('returns saved languages and segments with asset read access', async () => {
|
||||
const permission = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
|
||||
const list = vi
|
||||
|
||||
@@ -12,6 +12,16 @@ import { z } from 'zod'
|
||||
|
||||
const route = new Hono<{ Variables: { user: User } }>()
|
||||
.get('/transcription/languages', async (c) => c.json(await transcriptService.listLanguages()))
|
||||
.get('/projects/:projectId/transcription-status', async (c) => {
|
||||
const projectId = c.req.param('projectId')
|
||||
await authzService.hasPermission({
|
||||
user: c.get('user'),
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Project,
|
||||
id: projectId,
|
||||
})
|
||||
return c.json({ assetIds: await transcriptService.listActiveAssetIds(projectId) })
|
||||
})
|
||||
.get('/files/:fileId/transcripts', async (c) => {
|
||||
const assetId = c.req.param('fileId')
|
||||
await authzService.hasPermission({
|
||||
|
||||
Reference in New Issue
Block a user