diff --git a/src/app/download-torrent-menu.js b/src/app/download-torrent-menu.js index 25ad4e3..dd5e122 100644 --- a/src/app/download-torrent-menu.js +++ b/src/app/download-torrent-menu.js @@ -43,18 +43,35 @@ export default (props) => { {name: __('Download to') + '...', click: async () => { if(dialog) { - const path = (await dialog.showOpenDialog({ - properties: ['openDirectory'] - })).filePaths; - if(!path || path.length < 1) - return - console.log(path); + // Path using in testing + let testPath = window.downloadFolderTest; + if(testPath && testPath.length > 0) + testPath = [testPath]; + else + testPath = null + + // Main path + let path; + + if (!testPath) + { + path = (await dialog.showOpenDialog({ + properties: ['openDirectory'] + })).filePaths; + if(!path || path.length < 1) + return + } + else + { + path = testPath; + } window.torrentSocket.emit('download', props.torrent, path[0], (added) => { if(props.onAdded) props.onAdded(added) }) } }, + className: 'downloadDirectoryButton', icon: { + window.downloadFolderTest = folder + }, fileFolder) + await app.client.click('.torrentRow .downloadDirectoryButton') + // Downloading check + await app.client.waitUntil(async () => { + return (await app.client.getText('.torrentRow .progressDownloading')) === '100.0%' + }, 60000, 'expected that download will be finished', 200) + // Check downloaded to directory + assert(fs.existsSync(fileFolderTest)); + assert.equal(await md5(fileFolderTest), '7df171da63e2013c9b17e1857615b192'); + }) });