wrolpi/app/src/Events.test.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

import {handleEvents} from './Events';
import {toast} from './components/ui';
jest.mock('./components/ui', () => ({toast: jest.fn()}));
const notify = (url) => ({event: 'user_notify_message', message: 'Transcoding video.mp4', dt: '2026-10-12', url});
afterEach(() => {
toast.mockClear();
});
describe('user_notify_message', () => {
it('a notification without a URL is plain text, not a link', () => {
handleEvents([notify(null)]);
expect(toast).toHaveBeenCalledTimes(1);
const options = toast.mock.calls[0][0];
expect(options.title).toBe('Transcoding video.mp4');
expect(options.description).toBeFalsy();
expect(options.onClick).toBeFalsy();
});
it('a shared page opens its URL when clicked', () => {
const open = jest.spyOn(window, 'open').mockImplementation(() => null);
handleEvents([notify('/archive/1')]);
const options = toast.mock.calls[0][0];
expect(options.description).toBe('Click here to view the shared page');
options.onClick();
expect(open).toHaveBeenCalledWith('/archive/1', '_self');
open.mockRestore();
});
});
Torrents: refuse to download into the media directory itself (#1038) * Torrents: refuse to download into the media directory itself A torrent's files are chosen by whoever made it. Saved in the media directory itself, a torrent holding a config directory would put its files in WROLPi's config directory. Downloads now need a directory in the media directory. Share still seeds a top-level directory from the media directory: its files are the shared directory's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Torrents: refuse a WebUI save path WROLPi would refuse A torrent added in qBittorrent's WebUI to the media directory itself (or outside the library) is removed from qBittorrent, its files kept, and a "Torrent Refused" event says why. A torrent moved there in the WebUI is moved back to its config's save path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Torrents: keep an untagged WROLPi torrent; refuse a WebUI download path A WROLPi torrent whose tag was removed in the WebUI was removed from qBittorrent when its save path was refused, and forgotten (config and .torrent deleted) on the next pass. It is now tagged again and kept as the config says, as adopt() did before. qBittorrent keeps a downloading torrent's incomplete files in its download path, which the WebUI can set per torrent. A WebUI torrent with a refused download path is removed (files kept); a WROLPi torrent's is set back to its save path. A finished torrent's download path is unused, and left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 15:05:52 -07:00
describe('torrent_refused', () => {
it('says which torrent was refused, and why', () => {
handleEvents([{event: 'torrent_refused', subject: 'torrents', dt: '2026-11-29',
message: 'planet was removed: Torrents cannot be saved in the media directory itself'}]);
expect(toast).toHaveBeenCalledTimes(1);
const options = toast.mock.calls[0][0];
expect(options.title).toBe('Torrent Refused');
expect(options.description).toContain('planet was removed');
});
});