mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-18 23:26:18 +00:00
fix(downloads): restore queue reorder interactions
This commit is contained in:
@@ -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: [
|
||||
|
||||
@@ -948,6 +948,7 @@ export const useDownloadStore = create<DownloadState>((set, get) => {
|
||||
? { ...download, queuePosition: previousPositions.get(download.id) }
|
||||
: download)
|
||||
}));
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
const trackedOperation = operation.finally(() => {
|
||||
|
||||
Reference in New Issue
Block a user