feat(tests): search test

This commit is contained in:
Alexey Kasyanchuk 2018-08-09 05:02:11 +03:00
parent ce618f4408
commit ae7b6fe793
5 changed files with 51 additions and 4 deletions

View File

@ -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 {
</Tooltip>
</div>
<RaisedButton style={{marginLeft: '10px'}} label={__('Search')} primary={true} onClick={() =>{
<RaisedButton style={{marginLeft: '10px'}} id='search' label={__('Search')} primary={true} onClick={() =>{
this.search()
}} />
</div>

View File

@ -261,7 +261,8 @@ export default class Torrent extends Component {
return (
<div>
<ListItem
<ListItem
className='torrentRow'
innerDivStyle={{paddingRight: 84}}
onClick={(e) => {
const link = '/torrent/' + torrent.hash;
@ -284,7 +285,7 @@ export default class Torrent extends Component {
if(node)
node.onclick = () => { return false }
}}>
<span className='break-word' style={{
<span className='break-word torrentName' style={{
color: torrent.contentCategory != 'xxx' ? (torrent.peer ? '#5643db' : 'black') : (torrent.peer ? '#9083e2' : 'grey')
}}>
{torrent.name}

View File

@ -0,0 +1 @@
module.exports = (time) => new Promise((resolve) => setTimeout(resolve, time))

View File

@ -8,7 +8,7 @@ const startApplication = function() {
args: ["."],
startTimeout: 30000,
waitTimeout: 30000,
quitTimeout: 10000
quitTimeout: 15000
});
return this.app.start();
};

44
tests/seach.test.js Normal file
View File

@ -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)
})
});