feat(torrent): complete lifecycle controls

This commit is contained in:
NimBold
2026-08-03 21:47:02 +03:30
parent 819a48bd4b
commit 55a905df14
32 changed files with 2390 additions and 136 deletions
+27
View File
@@ -167,6 +167,33 @@ describe('useDownloadStore', () => {
expect(useDownloadStore.getState().downloads[0].torrentRemoveUnselectedFile).toBe(false);
});
it('detaches a paused backend lifecycle even when the frontend registration set is stale', async () => {
useDownloadStore.setState({
downloads: [{
id: 'paused-stale-registration',
url: 'magnet:?xt=urn:btih:abc',
fileName: 'torrent',
status: 'paused',
category: 'Other',
dateAdded: '',
isTorrent: true,
torrentFileIndices: [1]
}] as any[],
backendRegisteredIds: new Set()
});
vi.mocked(ipc.invokeCommand).mockResolvedValue(undefined as never);
await useDownloadStore.getState().applyProperties('paused-stale-registration', {
torrentFileIndices: [2]
});
expect(ipc.invokeCommand).toHaveBeenCalledWith(
'detach_download_for_reconfigure',
{ id: 'paused-stale-registration' }
);
expect(useDownloadStore.getState().downloads[0].torrentFileIndices).toEqual([2]);
});
it('replaces stale media intent when an appended handoff reuses a URL', () => {
useDownloadStore.getState().openAddModalWithUrls(
'https://example.com/file.bin', '', '', '', '', true