fix(tests): fix tests on new api
This commit is contained in:
parent
e3c20a6fe2
commit
4b763c9377
@ -8,7 +8,7 @@ const startApplication = function() {
|
||||
args: ["."],
|
||||
chromeDriverArgs: ['remote-debugging-port=' + Math.floor(Math.random() * (9999 - 9000) + 9000)],
|
||||
startTimeout: 30000,
|
||||
waitTimeout: 30000,
|
||||
waitTimeout: 500,
|
||||
quitTimeout: 15000
|
||||
});
|
||||
return this.app.start();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { assert } from "chai";
|
||||
import { assert, expect } from "chai";
|
||||
const asyncWait = require('../src/background/asyncWait')
|
||||
const md5 = require('md5-file/promise')
|
||||
const config = require('../src/background/config')
|
||||
@ -21,52 +21,50 @@ describe("download", function() {
|
||||
it("click download", async function() {
|
||||
this.timeout(45000);
|
||||
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')
|
||||
await (await app.client.$('#searchInput')).setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
||||
await (await app.client.$('#search')).click()
|
||||
// Click download button (must open menu)
|
||||
await app.client.click('.torrentRow .downloadButton')
|
||||
await app.client.waitForExist('.torrentRow .downloadFullButton')
|
||||
await (await app.client.$('.torrentRow .downloadButton')).click()
|
||||
// Start downloading
|
||||
await app.client.click('.torrentRow .downloadFullButton')
|
||||
await (await app.client.$('.torrentRow .downloadFullButton')).click()
|
||||
})
|
||||
|
||||
it("download started", async function() {
|
||||
this.timeout(45000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('.torrentRow .deleteDownloadBeforeFinish')
|
||||
await app.client.$('.torrentRow .deleteDownloadBeforeFinish')
|
||||
})
|
||||
|
||||
it("check download exists in download tab", async function() {
|
||||
this.timeout(8000);
|
||||
const { app } = this
|
||||
await app.client.click('#downloadTab')
|
||||
await app.client.waitForExist('.downloads-list .torrentRow .torrentName')
|
||||
const value = await app.client.$('.downloads-list .torrentRow .torrentName').getText()
|
||||
await (await app.client.$('#downloadTab')).click()
|
||||
const value = await (await app.client.$('.downloads-list .torrentRow .torrentName')).getText()
|
||||
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
|
||||
assert(await app.client.isExisting('.torrentRow .deleteDownloadBeforeFinish'));
|
||||
assert(await app.client.isExisting('.torrentRow .pauseTorrent'));
|
||||
assert(await (await app.client.$('.torrentRow .deleteDownloadBeforeFinish')).isExisting());
|
||||
assert(await (await app.client.$('.torrentRow .pauseTorrent')).isExisting());
|
||||
// back to recent search
|
||||
await app.client.click('#open-recent-search')
|
||||
await app.client.waitForExist('.search-list')
|
||||
await (await app.client.$('#open-recent-search')).click()
|
||||
await app.client.$('.search-list')
|
||||
})
|
||||
|
||||
it("wait until downloaded", async function() {
|
||||
this.timeout(90000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('.torrentRow .progressDownloading')
|
||||
console.log('download progress', await app.client.getText('.torrentRow .progressDownloading'));
|
||||
await app.client.$('.torrentRow .progressDownloading')
|
||||
console.log('download progress', await (await app.client.$('.torrentRow .progressDownloading')).getText());
|
||||
app.client.options.waitforTimeout = 60000
|
||||
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)
|
||||
app.client.options.waitforTimeout = 500
|
||||
// There is some time before button will be replaced
|
||||
await asyncWait(800);
|
||||
|
||||
// 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() {
|
||||
@ -79,23 +77,22 @@ describe("download", function() {
|
||||
it("delete download from manager (after finish)", async function() {
|
||||
this.timeout(8000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('.torrentRow .deleteDownloadAfterFinish')
|
||||
assert(await app.client.isExisting('.torrentRow .deleteDownloadAfterFinish'));
|
||||
assert.equal(await app.client.getText('.search-list .torrentRow .progressDownloading'), '100.0%')
|
||||
assert(await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).isExisting());
|
||||
assert.equal(await (await app.client.$('.search-list .torrentRow .progressDownloading')).getText(), '100.0%')
|
||||
// Click cancel of download
|
||||
await app.client.click('.torrentRow .deleteDownloadAfterFinish')
|
||||
assert(!(await app.client.isExisting('.torrentRow .deleteDownloadAfterFinish')));
|
||||
await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).click()
|
||||
assert(!(await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).isExisting()));
|
||||
// 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')
|
||||
})
|
||||
|
||||
it("there must be no download on download tab", async function() {
|
||||
this.timeout(8000);
|
||||
const { app } = this
|
||||
await app.client.click('#downloadTab')
|
||||
await app.client.waitForExist('.downloads-list')
|
||||
assert(!(await app.client.isExisting('.torrentRow')));
|
||||
await (await app.client.$('#downloadTab')).click()
|
||||
await app.client.$('.downloads-list')
|
||||
assert(!(await (await app.client.$('.torrentRow')).isExisting()));
|
||||
})
|
||||
|
||||
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() {
|
||||
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')
|
||||
await (await app.client.$('#searchInput')).setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
||||
await (await app.client.$('#search')).click()
|
||||
// Click download button (must open menu)
|
||||
await app.client.click('.torrentRow .downloadButton')
|
||||
await app.client.waitForExist('.torrentRow .downloadDirectoryButton')
|
||||
await (await app.client.$('.torrentRow .downloadButton')).click()
|
||||
await app.client.$('.torrentRow .downloadDirectoryButton')
|
||||
// Click download to folder and start download
|
||||
await app.client.execute((folder) => {
|
||||
window.downloadFolderTest = folder
|
||||
}, fileFolder)
|
||||
await app.client.click('.torrentRow .downloadDirectoryButton')
|
||||
await (await app.client.$('.torrentRow .downloadDirectoryButton')).click()
|
||||
// Downloading check
|
||||
app.client.options.waitforTimeout = 60000
|
||||
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)
|
||||
app.client.options.waitforTimeout = 500
|
||||
// Check downloaded to directory
|
||||
assert(fs.existsSync(fileFolderTest));
|
||||
assert.equal(await md5(fileFolderTest), '7df171da63e2013c9b17e1857615b192');
|
||||
|
@ -9,7 +9,7 @@ describe("application", () => {
|
||||
it("check start", async function() {
|
||||
this.timeout(5000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('#index-window')
|
||||
await app.client.$('#index-window')
|
||||
// fix realtime config
|
||||
require('../src/background/config').reload(await app.electron.remote.app.getPath('userData'))
|
||||
});
|
||||
|
@ -7,37 +7,35 @@ describe("search", function() {
|
||||
it("dht seach", async function() {
|
||||
this.timeout(45000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('#searchInput')
|
||||
await app.client.$('#searchInput').setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
||||
await app.client.click('#search')
|
||||
await app.client.waitForExist('.torrentRow .torrentName')
|
||||
const value = await app.client.$('.torrentRow .torrentName').getText()
|
||||
await (await app.client.$('#searchInput')).setValue('1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
||||
await (await app.client.$('#search')).click()
|
||||
const value = await (await app.client.$('.torrentRow .torrentName')).getText()
|
||||
assert.equal(value, 'Roblox_setup.exe')
|
||||
})
|
||||
|
||||
it("sphinx search", async function() {
|
||||
const { app } = this
|
||||
await app.client.$('#searchInput').setValue('Roblox_setup')
|
||||
await app.client.click('#search')
|
||||
await app.client.waitForExist('.torrentRow .torrentName')
|
||||
await (await app.client.$('#searchInput')).setValue('Roblox_setup')
|
||||
await (await app.client.$('#search')).click()
|
||||
await app.client.$('.torrentRow .torrentName')
|
||||
const results = (await app.client.$$('.torrentRow .torrentName')).length
|
||||
assert(results >= 1, 'default search on Roblox must return Roblox_setup record')
|
||||
})
|
||||
|
||||
it("sphinx particial search", async function() {
|
||||
const { app } = this
|
||||
await app.client.$('#searchInput').setValue('Roblo')
|
||||
await app.client.click('#search')
|
||||
await app.client.waitForExist('.torrentRow .torrentName')
|
||||
await (await app.client.$('#searchInput')).setValue('Roblo')
|
||||
await (await app.client.$('#search')).click()
|
||||
await app.client.$('.torrentRow .torrentName')
|
||||
const results = (await app.client.$$('.torrentRow .torrentName')).length
|
||||
assert(results >= 1, 'particial word search must find string')
|
||||
})
|
||||
|
||||
it("magnet search", async function() {
|
||||
const { app } = this
|
||||
await app.client.$('#searchInput').setValue('magnet:?xt=urn:btih:1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
||||
await app.client.click('#search')
|
||||
await app.client.waitForExist('.torrentRow .torrentName')
|
||||
await (await app.client.$('#searchInput')).setValue('magnet:?xt=urn:btih:1413ba1915affdc3de7e1a81d6fdc32ef19395c9')
|
||||
await (await app.client.$('#search')).click()
|
||||
await app.client.$('.torrentRow .torrentName')
|
||||
const results = (await app.client.$$('.torrentRow .torrentName')).length
|
||||
assert(results >= 1, 'magnet search must return 1 or more record')
|
||||
})
|
||||
|
@ -23,6 +23,6 @@ describe("rutracker", () => {
|
||||
assert.equal(data.poster, 'http://i44.fastpic.ru/big/2012/1018/a2/4e8740f608387b32b74c5deea72d05a2.jpg')
|
||||
assert.equal(data.rutrackerThreadId, 4220109)
|
||||
assert(data.description.includes('выхода'))
|
||||
assert.equal(data.contentCategory, 'Главная » Рок-музыка » Зарубежный Metal » Death, Doom (lossy)')
|
||||
assert.equal(data.contentCategory, 'Рок-музыка » Зарубежный Metal » Death, Doom (lossy)')
|
||||
})
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user