|
|
@ -1,4 +1,4 @@
|
|
|
|
import { assert } from "chai";
|
|
|
|
import { assert, expect } from "chai";
|
|
|
|
const asyncWait = require('../src/background/asyncWait')
|
|
|
|
const asyncWait = require('../src/background/asyncWait')
|
|
|
|
const md5 = require('md5-file/promise')
|
|
|
|
const md5 = require('md5-file/promise')
|
|
|
|
const config = require('../src/background/config')
|
|
|
|
const config = require('../src/background/config')
|
|
|
@ -21,52 +21,50 @@ describe("download", function() {
|
|
|
|
it("click download", async function() {
|
|
|
|
it("click download", async function() {
|
|
|
|
this.timeout(45000);
|
|
|
|
this.timeout(45000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.waitForExist('#searchInput')
|
|
|
|
await (await app.client.$('#searchInput')).setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
|
|
|
await app.client.$('#searchInput').setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
|
|
|
await (await app.client.$('#search')).click()
|
|
|
|
await app.client.click('#search')
|
|
|
|
|
|
|
|
await app.client.waitForExist('.torrentRow .downloadButton')
|
|
|
|
|
|
|
|
// Click download button (must open menu)
|
|
|
|
// Click download button (must open menu)
|
|
|
|
await app.client.click('.torrentRow .downloadButton')
|
|
|
|
await (await app.client.$('.torrentRow .downloadButton')).click()
|
|
|
|
await app.client.waitForExist('.torrentRow .downloadFullButton')
|
|
|
|
|
|
|
|
// Start downloading
|
|
|
|
// Start downloading
|
|
|
|
await app.client.click('.torrentRow .downloadFullButton')
|
|
|
|
await (await app.client.$('.torrentRow .downloadFullButton')).click()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("download started", async function() {
|
|
|
|
it("download started", async function() {
|
|
|
|
this.timeout(45000);
|
|
|
|
this.timeout(45000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.waitForExist('.torrentRow .deleteDownloadBeforeFinish')
|
|
|
|
await app.client.$('.torrentRow .deleteDownloadBeforeFinish')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("check download exists in download tab", async function() {
|
|
|
|
it("check download exists in download tab", async function() {
|
|
|
|
this.timeout(8000);
|
|
|
|
this.timeout(8000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.click('#downloadTab')
|
|
|
|
await (await app.client.$('#downloadTab')).click()
|
|
|
|
await app.client.waitForExist('.downloads-list .torrentRow .torrentName')
|
|
|
|
const value = await (await app.client.$('.downloads-list .torrentRow .torrentName')).getText()
|
|
|
|
const value = await app.client.$('.downloads-list .torrentRow .torrentName').getText()
|
|
|
|
|
|
|
|
assert.equal(value, 'Roblox_setup.exe')
|
|
|
|
assert.equal(value, 'Roblox_setup.exe')
|
|
|
|
console.log('download progress', await app.client.getText('.torrentRow .progressDownloading'));
|
|
|
|
console.log('download progress', await (await app.client.$('.torrentRow .progressDownloading')).getText());
|
|
|
|
// cancel in progress button must be exists
|
|
|
|
// cancel in progress button must be exists
|
|
|
|
assert(await app.client.isExisting('.torrentRow .deleteDownloadBeforeFinish'));
|
|
|
|
assert(await (await app.client.$('.torrentRow .deleteDownloadBeforeFinish')).isExisting());
|
|
|
|
assert(await app.client.isExisting('.torrentRow .pauseTorrent'));
|
|
|
|
assert(await (await app.client.$('.torrentRow .pauseTorrent')).isExisting());
|
|
|
|
// back to recent search
|
|
|
|
// back to recent search
|
|
|
|
await app.client.click('#open-recent-search')
|
|
|
|
await (await app.client.$('#open-recent-search')).click()
|
|
|
|
await app.client.waitForExist('.search-list')
|
|
|
|
await app.client.$('.search-list')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("wait until downloaded", async function() {
|
|
|
|
it("wait until downloaded", async function() {
|
|
|
|
this.timeout(90000);
|
|
|
|
this.timeout(90000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.waitForExist('.torrentRow .progressDownloading')
|
|
|
|
await app.client.$('.torrentRow .progressDownloading')
|
|
|
|
console.log('download progress', await app.client.getText('.torrentRow .progressDownloading'));
|
|
|
|
console.log('download progress', await (await app.client.$('.torrentRow .progressDownloading')).getText());
|
|
|
|
|
|
|
|
app.client.options.waitforTimeout = 60000
|
|
|
|
await app.client.waitUntil(async () => {
|
|
|
|
await app.client.waitUntil(async () => {
|
|
|
|
return (await app.client.getText('.torrentRow .progressDownloading')) === '100.0%'
|
|
|
|
return (await (await app.client.$('.torrentRow .progressDownloading')).getText()) === '100.0%'
|
|
|
|
}, 60000, 'expected that download will be finished', 200)
|
|
|
|
}, 60000, 'expected that download will be finished', 200)
|
|
|
|
|
|
|
|
app.client.options.waitforTimeout = 500
|
|
|
|
// There is some time before button will be replaced
|
|
|
|
// There is some time before button will be replaced
|
|
|
|
await asyncWait(800);
|
|
|
|
await asyncWait(800);
|
|
|
|
|
|
|
|
|
|
|
|
// Check Buttons After finish
|
|
|
|
// Check Buttons After finish
|
|
|
|
assert(!(await app.client.isExisting('.torrentRow .deleteDownloadBeforeFinish')));
|
|
|
|
assert(!(await (await app.client.$('.torrentRow .deleteDownloadBeforeFinish')).isExisting()));
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("check file after download", async function() {
|
|
|
|
it("check file after download", async function() {
|
|
|
@ -79,23 +77,22 @@ describe("download", function() {
|
|
|
|
it("delete download from manager (after finish)", async function() {
|
|
|
|
it("delete download from manager (after finish)", async function() {
|
|
|
|
this.timeout(8000);
|
|
|
|
this.timeout(8000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.waitForExist('.torrentRow .deleteDownloadAfterFinish')
|
|
|
|
assert(await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).isExisting());
|
|
|
|
assert(await app.client.isExisting('.torrentRow .deleteDownloadAfterFinish'));
|
|
|
|
assert.equal(await (await app.client.$('.search-list .torrentRow .progressDownloading')).getText(), '100.0%')
|
|
|
|
assert.equal(await app.client.getText('.search-list .torrentRow .progressDownloading'), '100.0%')
|
|
|
|
|
|
|
|
// Click cancel of download
|
|
|
|
// Click cancel of download
|
|
|
|
await app.client.click('.torrentRow .deleteDownloadAfterFinish')
|
|
|
|
await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).click()
|
|
|
|
assert(!(await app.client.isExisting('.torrentRow .deleteDownloadAfterFinish')));
|
|
|
|
assert(!(await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).isExisting()));
|
|
|
|
// Download deleted, but must be keeped in search
|
|
|
|
// Download deleted, but must be keeped in search
|
|
|
|
const value = await app.client.$('.search-list .torrentRow .torrentName').getText()
|
|
|
|
const value = await (await app.client.$('.search-list .torrentRow .torrentName')).getText()
|
|
|
|
assert.equal(value, 'Roblox_setup.exe')
|
|
|
|
assert.equal(value, 'Roblox_setup.exe')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("there must be no download on download tab", async function() {
|
|
|
|
it("there must be no download on download tab", async function() {
|
|
|
|
this.timeout(8000);
|
|
|
|
this.timeout(8000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.click('#downloadTab')
|
|
|
|
await (await app.client.$('#downloadTab')).click()
|
|
|
|
await app.client.waitForExist('.downloads-list')
|
|
|
|
await app.client.$('.downloads-list')
|
|
|
|
assert(!(await app.client.isExisting('.torrentRow')));
|
|
|
|
assert(!(await (await app.client.$('.torrentRow')).isExisting()));
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it("file must still exists after delete from manager", async function() {
|
|
|
|
it("file must still exists after delete from manager", async function() {
|
|
|
@ -107,22 +104,22 @@ describe("download", function() {
|
|
|
|
it("download file to folder", async function() {
|
|
|
|
it("download file to folder", async function() {
|
|
|
|
this.timeout(60000);
|
|
|
|
this.timeout(60000);
|
|
|
|
const { app } = this
|
|
|
|
const { app } = this
|
|
|
|
await app.client.waitForExist('#searchInput')
|
|
|
|
await (await app.client.$('#searchInput')).setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
|
|
|
await app.client.$('#searchInput').setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
|
|
|
await (await app.client.$('#search')).click()
|
|
|
|
await app.client.click('#search')
|
|
|
|
|
|
|
|
await app.client.waitForExist('.torrentRow .downloadButton')
|
|
|
|
|
|
|
|
// Click download button (must open menu)
|
|
|
|
// Click download button (must open menu)
|
|
|
|
await app.client.click('.torrentRow .downloadButton')
|
|
|
|
await (await app.client.$('.torrentRow .downloadButton')).click()
|
|
|
|
await app.client.waitForExist('.torrentRow .downloadDirectoryButton')
|
|
|
|
await app.client.$('.torrentRow .downloadDirectoryButton')
|
|
|
|
// Click download to folder and start download
|
|
|
|
// Click download to folder and start download
|
|
|
|
await app.client.execute((folder) => {
|
|
|
|
await app.client.execute((folder) => {
|
|
|
|
window.downloadFolderTest = folder
|
|
|
|
window.downloadFolderTest = folder
|
|
|
|
}, fileFolder)
|
|
|
|
}, fileFolder)
|
|
|
|
await app.client.click('.torrentRow .downloadDirectoryButton')
|
|
|
|
await (await app.client.$('.torrentRow .downloadDirectoryButton')).click()
|
|
|
|
// Downloading check
|
|
|
|
// Downloading check
|
|
|
|
|
|
|
|
app.client.options.waitforTimeout = 60000
|
|
|
|
await app.client.waitUntil(async () => {
|
|
|
|
await app.client.waitUntil(async () => {
|
|
|
|
return (await app.client.getText('.torrentRow .progressDownloading')) === '100.0%'
|
|
|
|
return (await (await app.client.$('.torrentRow .progressDownloading')).getText()) === '100.0%'
|
|
|
|
}, 60000, 'expected that download will be finished', 200)
|
|
|
|
}, 60000, 'expected that download will be finished', 200)
|
|
|
|
|
|
|
|
app.client.options.waitforTimeout = 500
|
|
|
|
// Check downloaded to directory
|
|
|
|
// Check downloaded to directory
|
|
|
|
assert(fs.existsSync(fileFolderTest));
|
|
|
|
assert(fs.existsSync(fileFolderTest));
|
|
|
|
assert.equal(await md5(fileFolderTest), '7df171da63e2013c9b17e1857615b192');
|
|
|
|
assert.equal(await md5(fileFolderTest), '7df171da63e2013c9b17e1857615b192');
|
|
|
|