mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +00:00
feat(file): optimize upload and transcoding status polling with batch api (#512)
* feat(file): optimize upload and transcoding status polling with batch api * fix(webui): throttle search invalidation during upload and fix stuck 100% progress ring * fix(webui): deduplicate upload search invalidation and stabilize batch polling
This commit is contained in:
@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { FileCard } from './file-card'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { useUploadStore } from '@/ui/stores/upload'
|
||||
|
||||
vi.mock('@dnd-kit/react', () => ({
|
||||
useDraggable: () => ({
|
||||
@@ -341,6 +342,35 @@ describe('FileCard', () => {
|
||||
expect(screen.queryByText(/Alice/i)).toBeNull()
|
||||
})
|
||||
|
||||
it('transitions from uploading to preparing circle when upload store marks file completed', () => {
|
||||
useUploadStore.setState({
|
||||
fileProgress: {
|
||||
'file-uploading': {
|
||||
fileId: 'file-uploading',
|
||||
name: 'clip.mp4',
|
||||
loaded: 1000,
|
||||
total: 1000,
|
||||
status: 'completed',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const uploadingItem: AssetInfo = {
|
||||
...fileItem,
|
||||
id: 'file-uploading',
|
||||
status: 'uploading',
|
||||
creator: { id: 'u1', name: 'Alice' },
|
||||
} as AssetInfo
|
||||
|
||||
renderComponent({ item: uploadingItem })
|
||||
|
||||
expect(screen.queryByTestId('file-card-preview-media')).toBeNull()
|
||||
const circle = screen.getByTestId('file-card-preparing-circle')
|
||||
expect(circle.tagName.toLowerCase()).toBe('svg')
|
||||
expect(screen.getByText(/Preparing|准备中/i)).toBeTruthy()
|
||||
expect(screen.queryByText(/Alice/i)).toBeNull()
|
||||
})
|
||||
|
||||
it('shows a preparing circle and "Preparing..." when processing without a preview yet', () => {
|
||||
const processingItem: AssetInfo = {
|
||||
...fileItem,
|
||||
|
||||
Reference in New Issue
Block a user