mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(upload): allow canceling in-progress upload tasks from sidebar (#511)
* feat(upload): allow canceling in-progress upload tasks from sidebar * fix(upload): resolve concurrent confirmation race and store counter issues on cancellation * fix(webui): immediately remove cancelled upload files from file list view
This commit is contained in:
@@ -220,4 +220,27 @@ describe('Upload API', () => {
|
||||
key: 'files/test.mp4',
|
||||
})
|
||||
})
|
||||
|
||||
it('POST /teams/:teamId/upload/tasks/:taskId/cancel', async () => {
|
||||
vi.spyOn(uploadService, 'cancelUploadTask').mockResolvedValue({
|
||||
success: true,
|
||||
})
|
||||
|
||||
const res = await app.request('/teams/team1/upload/tasks/task1/cancel', {
|
||||
method: 'POST',
|
||||
headers: { Authorization: 'Bearer test' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const json = await res.json()
|
||||
expect(json).toEqual({ success: true })
|
||||
expect(authzService.hasPermission).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: ResourceType.Team,
|
||||
id: 'team1',
|
||||
permission: Permission.Edit,
|
||||
}),
|
||||
)
|
||||
expect(uploadService.cancelUploadTask).toHaveBeenCalledWith('team1', 'user1', 'task1')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user