fix(video): transcribe from the smallest full proxy

This commit is contained in:
yiling
2026-12-03 21:05:40 +08:00
parent cdd45429c4
commit 659ed5dab4
15 changed files with 210 additions and 53 deletions
@@ -31,6 +31,15 @@ describe('FileBrowserContextMenu', () => {
updatedAt: '2026-01-01T00:00:00Z',
} as AssetInfo
const fullProxy = {
id: 'proxy-480p',
url: '/video-480p.mp4',
key: 'video-480p.mp4',
width: 854,
height: 480,
size: 100,
}
const renderWithMenu = (
item: AssetInfo,
props: Partial<React.ComponentProps<typeof FileBrowserContextMenu>> = {},
@@ -93,6 +102,7 @@ describe('FileBrowserContextMenu', () => {
{
...stackItem,
proxyType: 'video',
media: { videoTranscodes: [fullProxy] },
versionStack: {
id: stackItem.id,
versions: [
@@ -110,6 +120,24 @@ describe('FileBrowserContextMenu', () => {
expect(onGenerateTranscripts).toHaveBeenCalledWith('current', 'current.mp4')
})
it.each([
{ status: 'uploaded', media: undefined },
{ status: 'processing', media: { videoTranscodes: [fullProxy] } },
{ status: 'processed', media: { videoPreview: { url: '/preview.mp4', key: 'preview.mp4' } } },
])('disables generation for a $status video until a full proxy is ready', ({ status, media }) => {
const onGenerateTranscripts = vi.fn()
renderWithMenu(
{ ...fileItem, mediaType: 'video/mp4', status, media },
{ onGenerateTranscripts },
)
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
const action = screen.getByRole('menuitem', { name: 'Generate Transcripts' })
expect(action.getAttribute('aria-disabled')).toBe('true')
fireEvent.click(action)
expect(onGenerateTranscripts).not.toHaveBeenCalled()
})
it.each([
{
label: 'a read-only member',
@@ -117,6 +145,11 @@ describe('FileBrowserContextMenu', () => {
canEdit: false,
},
{ label: 'a non-video asset', item: fileItem, canEdit: true },
{
label: 'an audio-only upload with a video MIME type',
item: { ...fileItem, proxyType: 'audio' as const, mediaType: 'video/mp4' },
canEdit: true,
},
{
label: 'an archived video',
item: { ...fileItem, proxyType: 'video' as const, status: 'archived' },