mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 08:59:50 +00:00
fix(webui): resolve upload card freeze for unsupported files (#284)
This commit is contained in:
@@ -68,7 +68,7 @@ apps/web/e2e/
|
||||
| Test | File |
|
||||
|---|---|
|
||||
| Owner creates a project with a cover image | `tests/project/create-project.spec.ts` |
|
||||
| Owner uploads a file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||
| Owner uploads a file or an unsupported file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
|
||||
| Owner creates a share link from a file context menu and lands on the share page | `tests/project/create-share-link.spec.ts` |
|
||||
| Owner protects a share with a password; guests must enter it to view | `tests/project/share-password.spec.ts` |
|
||||
|
||||
@@ -47,3 +47,39 @@ test('owner uploads a file via the "Upload File" context menu action', async ({
|
||||
const projectRow = await prisma.project.findUnique({ where: { id: projectId } })
|
||||
expect(asset!.parentId).toBe(projectRow?.rootFolderId)
|
||||
})
|
||||
|
||||
test('owner uploads an unsupported file via context menu action', async ({ project, prisma }) => {
|
||||
const { page, projectId } = project
|
||||
const fileName = `e2e-upload-${Date.now()}.bin`
|
||||
const binBuffer = Buffer.from([0x00, 0x01, 0x02, 0x03])
|
||||
|
||||
await page.goto(`/projects/${projectId}`)
|
||||
await expect(page.getByText('This folder is empty')).toBeVisible()
|
||||
|
||||
await page.getByText('This folder is empty').click({ button: 'right' })
|
||||
const [fileChooser] = await Promise.all([
|
||||
page.waitForEvent('filechooser'),
|
||||
page.getByRole('menuitem', { name: 'Upload File' }).click(),
|
||||
])
|
||||
await fileChooser.setFiles({
|
||||
name: fileName,
|
||||
mimeType: 'application/octet-stream',
|
||||
buffer: binBuffer,
|
||||
})
|
||||
|
||||
const card = fileCard(page, fileName)
|
||||
await expect(card).toBeVisible()
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const asset = await prisma.asset.findFirst({ where: { name: fileName } })
|
||||
return asset?.status
|
||||
},
|
||||
{ timeout: 30_000 },
|
||||
)
|
||||
.toBe('processed')
|
||||
|
||||
// Verify that the file card shows the generic file icon and is not stuck in uploading state
|
||||
await expect(card.locator('svg.lucide-file')).toBeVisible({ timeout: 10_000 })
|
||||
})
|
||||
|
||||
@@ -116,7 +116,15 @@ export function FileCard({
|
||||
},
|
||||
})
|
||||
|
||||
const displayItem = polledItem || item
|
||||
const displayItem = useMemo(() => {
|
||||
if (item.status === 'processed' || item.status === 'error') {
|
||||
return item
|
||||
}
|
||||
if (polledItem?.status === 'processed' || polledItem?.status === 'error') {
|
||||
return polledItem
|
||||
}
|
||||
return polledItem || item
|
||||
}, [item, polledItem])
|
||||
|
||||
// dnd-kit hooks
|
||||
const { ref: setDraggableRef, isDragging: isDraggableDragging } = useDraggable({
|
||||
|
||||
@@ -91,7 +91,15 @@ export function FileListItem({
|
||||
},
|
||||
})
|
||||
|
||||
const displayItem = polledItem || item
|
||||
const displayItem = useMemo(() => {
|
||||
if (item.status === 'processed' || item.status === 'error') {
|
||||
return item
|
||||
}
|
||||
if (polledItem?.status === 'processed' || polledItem?.status === 'error') {
|
||||
return polledItem
|
||||
}
|
||||
return polledItem || item
|
||||
}, [item, polledItem])
|
||||
|
||||
// dnd-kit hooks
|
||||
const { ref: setDraggableRef, isDragging: isDraggableDragging } = useDraggable({
|
||||
|
||||
Reference in New Issue
Block a user