fix(downloads): restore queue reorder interactions

This commit is contained in:
NimBold
2026-07-23 06:45:49 +03:30
parent 3559c69968
commit 18e9200b74
4 changed files with 67 additions and 43 deletions
+16
View File
@@ -1780,6 +1780,22 @@ describe('useDownloadStore', () => {
expect(new Set(positions).size).toBe(4);
});
it('rolls back and rejects a failed keyboard or header queue move', async () => {
useDownloadStore.setState({
downloads: [
{ id: 'first', status: 'queued', queueId: 'move-failure-queue', queuePosition: 0 },
{ id: 'second', status: 'queued', queueId: 'move-failure-queue', queuePosition: 1 }
] as any[],
backendRegisteredIds: new Set(['second'])
});
vi.mocked(ipc.invokeCommand).mockRejectedValue(new Error('backend unavailable'));
await expect(
useDownloadStore.getState().moveInQueue('second', 'up')
).rejects.toThrow('backend unavailable');
expect(useDownloadStore.getState().downloads.map(item => item.queuePosition)).toEqual([0, 1]);
});
it('translates a drag target around staged rows before the atomic backend move', async () => {
useDownloadStore.setState({
downloads: [
+1
View File
@@ -948,6 +948,7 @@ export const useDownloadStore = create<DownloadState>((set, get) => {
? { ...download, queuePosition: previousPositions.get(download.id) }
: download)
}));
throw error;
}
});
const trackedOperation = operation.finally(() => {