diff --git a/src/app/search.js b/src/app/search.js index 5316c5e..f39c61b 100644 --- a/src/app/search.js +++ b/src/app/search.js @@ -287,6 +287,7 @@ class Search extends Component { floatingLabelText={__('What to search?')} fullWidth={true} ref='searchInput' + id='searchInput' defaultValue={this.searchValue} errorText={this.searchError} onKeyPress={(e) => { @@ -335,7 +336,7 @@ class Search extends Component { - { + { this.search() }} /> diff --git a/src/app/torrent.js b/src/app/torrent.js index a5cd8eb..0f63b9f 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -261,7 +261,8 @@ export default class Torrent extends Component { return (
- { const link = '/torrent/' + torrent.hash; @@ -284,7 +285,7 @@ export default class Torrent extends Component { if(node) node.onclick = () => { return false } }}> - {torrent.name} diff --git a/src/background/asyncWait.js b/src/background/asyncWait.js new file mode 100644 index 0000000..b2fa571 --- /dev/null +++ b/src/background/asyncWait.js @@ -0,0 +1 @@ +module.exports = (time) => new Promise((resolve) => setTimeout(resolve, time)) \ No newline at end of file diff --git a/tests/application.js b/tests/application.js index 62ab2eb..8ebb201 100644 --- a/tests/application.js +++ b/tests/application.js @@ -8,7 +8,7 @@ const startApplication = function() { args: ["."], startTimeout: 30000, waitTimeout: 30000, - quitTimeout: 10000 + quitTimeout: 15000 }); return this.app.start(); }; diff --git a/tests/seach.test.js b/tests/seach.test.js new file mode 100644 index 0000000..cae97f7 --- /dev/null +++ b/tests/seach.test.js @@ -0,0 +1,44 @@ +import { assert } from "chai"; +const asyncWait = require('../src/background/asyncWait') + +describe("search", function() { + this.timeout(30000); + + 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() + 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') + const results = (await app.client.$$('.torrentRow .torrentName')).length + assert(results >= 1) + }) + + 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') + const results = (await app.client.$$('.torrentRow .torrentName')).length + assert(results >= 1) + }) + + 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') + const results = (await app.client.$$('.torrentRow .torrentName')).length + assert(results == 1) + }) +});