test(download): testing file folder download

This commit is contained in:
Alexey Kasyanchuk
2019-10-01 23:54:17 +03:00
parent f121c118a3
commit bbc68d73f4
2 changed files with 51 additions and 6 deletions

View File

@ -43,18 +43,35 @@ export default (props) => {
{name: __('Download to') + '...', click: async () => {
if(dialog)
{
const path = (await dialog.showOpenDialog({
// 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
console.log(path);
}
else
{
path = testPath;
}
window.torrentSocket.emit('download', props.torrent, path[0], (added) => {
if(props.onAdded)
props.onAdded(added)
})
}
},
className: 'downloadDirectoryButton',
icon: <svg viewBox="0 0 60 60">
<g>
<path d="M54.168,0H5.832C4.271,0,3,1.271,3,2.832v54.336C3,58.729,4.271,60,5.832,60h48.336C55.729,60,57,58.729,57,57.168V2.832

View File

@ -8,10 +8,14 @@ describe("download", function() {
this.timeout(30000);
const fileTest = config.client.downloadPath + "/Roblox_setup.exe"
const fileFolder = config.client.downloadPath + "/folderTest"
const fileFolderTest = fileFolder + "/Roblox_setup.exe"
it("cleanup", function() {
if(fs.existsSync(fileTest))
fs.unlinkSync(fileTest);
if(fs.existsSync(fileFolderTest))
fs.unlinkSync(fileFolderTest);
})
it("click download", async function() {
@ -97,4 +101,28 @@ describe("download", function() {
assert(fs.existsSync(fileTest));
assert.equal(await md5(fileTest), '7df171da63e2013c9b17e1857615b192');
})
it("download file to folder", async function() {
this.timeout(60000);
const { app } = this
await app.client.waitForExist('#searchInput')
await app.client.$('#searchInput').setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
await app.client.click('#search')
await app.client.waitForExist('.torrentRow .downloadButton')
// Click download button (must open menu)
await app.client.click('.torrentRow .downloadButton')
await app.client.waitForExist('.torrentRow .downloadDirectoryButton')
// Click download to folder and start download
await app.client.execute((folder) => {
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');
})
});