test(downloading): add downloading test
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@ -12507,6 +12507,12 @@
|
||||
"integrity": "sha1-3oGf282E3M2PrlnGrreWFbnSZqw=",
|
||||
"dev": true
|
||||
},
|
||||
"md5-file": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/md5-file/-/md5-file-4.0.0.tgz",
|
||||
"integrity": "sha512-UC0qFwyAjn4YdPpKaDNw6gNxRf7Mcx7jC1UGCY4boCzgvU2Aoc1mOGzTtrjjLKhM5ivsnhoKpQVxKPp+1j1qwg==",
|
||||
"dev": true
|
||||
},
|
||||
"md5.js": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz",
|
||||
|
@ -168,6 +168,7 @@
|
||||
"express": "^4.16.3",
|
||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"md5-file": "^4.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"socket.io": "^2.1.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
|
@ -40,7 +40,7 @@ export default class ContextMenu extends Component {
|
||||
zIndex: 3
|
||||
}, !this.props.rightAlign ? { left: -30 } : { right: -30 })}>
|
||||
{
|
||||
this.props.menu && this.props.menu.map((menu, index) => <ListItem key={index} style={{fontSize: '0.9em'}} primaryText={menu.name} leftIcon={menu.icon} onClick={(e) => {
|
||||
this.props.menu && this.props.menu.map((menu, index) => <ListItem key={index} className={menu.className} style={{fontSize: '0.9em'}} primaryText={menu.name} leftIcon={menu.icon} onClick={(e) => {
|
||||
menu.click()
|
||||
this.setState({toggle: !this.state.toggle})
|
||||
e.preventDefault()
|
||||
|
@ -16,7 +16,9 @@ export default (props) => {
|
||||
if(props.onAdded)
|
||||
props.onAdded(added)
|
||||
})
|
||||
}, icon: <svg style={{
|
||||
},
|
||||
className: 'downloadFullButton',
|
||||
icon: <svg style={{
|
||||
fill: 'black'
|
||||
}} viewBox="0 0 56 56">
|
||||
<g>
|
||||
|
@ -371,7 +371,7 @@ export default class Torrent extends Component {
|
||||
mode="determinate"
|
||||
value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100}
|
||||
/>
|
||||
<div className='pad0-75' style={{marginLeft: 20}} style={{color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && (this.state.downloadProgress.progress * 100).toFixed(1)}%</div>
|
||||
<div className='pad0-75 progressDownloading' style={{marginLeft: 20}} style={{color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && (this.state.downloadProgress.progress * 100).toFixed(1)}%</div>
|
||||
{
|
||||
this.state.downloadProgress.progress !== 1
|
||||
&&
|
||||
@ -463,7 +463,7 @@ export default class Torrent extends Component {
|
||||
this.setState({startingDownloading: true})
|
||||
}}>
|
||||
<ToolTip hint={__('Download using built-in client')} right={true}>
|
||||
<a href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||
<a className='downloadButton' href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||
<svg style={{
|
||||
height: '24px',
|
||||
marginRight: 12,
|
||||
@ -515,7 +515,7 @@ export default class Torrent extends Component {
|
||||
this.state.downloaded
|
||||
?
|
||||
<ToolTip hint={__('Delete download (files saved)')} right={true}>
|
||||
<a href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||
<a className='deleteDownload deleteDownloadAfterFinish' href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||
<svg style={{
|
||||
height: '24px',
|
||||
fill: '#00C853',
|
||||
@ -532,7 +532,7 @@ export default class Torrent extends Component {
|
||||
this.state.downloading
|
||||
&&
|
||||
<ToolTip hint={__('Delete download (files saved)')} right={true}>
|
||||
<a href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||
<a className='deleteDownload deleteDownloadBeforeFinish' href={`magnet:?xt=urn:btih:${torrent.hash}`}>
|
||||
<svg style={{
|
||||
height: '24px',
|
||||
marginRight: 12,
|
||||
|
53
tests/download.test.js
Normal file
53
tests/download.test.js
Normal file
@ -0,0 +1,53 @@
|
||||
import { assert } from "chai";
|
||||
const asyncWait = require('../src/background/asyncWait')
|
||||
const md5 = require('md5-file/promise')
|
||||
const config = require('../src/background/config')
|
||||
const fs = require('fs')
|
||||
|
||||
describe("download", function() {
|
||||
this.timeout(30000);
|
||||
|
||||
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')
|
||||
// Click download button (must open menu)
|
||||
await app.client.click('.torrentRow .downloadButton')
|
||||
await app.client.waitForExist('.torrentRow .downloadFullButton')
|
||||
// Start downloading
|
||||
await app.client.click('.torrentRow .downloadFullButton')
|
||||
})
|
||||
|
||||
it("wait until downloaded", async function() {
|
||||
this.timeout(90000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('.torrentRow .progressDownloading')
|
||||
await app.client.waitUntil(async () => {
|
||||
return (await app.client.getText('.torrentRow .progressDownloading')) === '100.0%'
|
||||
}, 60000, 'expected that download will be finished', 200)
|
||||
})
|
||||
|
||||
it("check file after download", async function() {
|
||||
this.timeout(10000);
|
||||
const file = config.client.downloadPath + "/Roblox_setup.exe"
|
||||
assert(fs.existsSync(file));
|
||||
assert.equal(await md5(file), '7df171da63e2013c9b17e1857615b192');
|
||||
})
|
||||
|
||||
it("delete download from manager (after finish)", async function() {
|
||||
this.timeout(10000);
|
||||
const { app } = this
|
||||
await app.client.waitForExist('.torrentRow .deleteDownloadAfterFinish')
|
||||
await app.client.click('.torrentRow .deleteDownloadAfterFinish')
|
||||
})
|
||||
|
||||
it("file must still exists after delete from manager", async function() {
|
||||
this.timeout(10000);
|
||||
const file = config.client.downloadPath + "/Roblox_setup.exe"
|
||||
assert(fs.existsSync(file));
|
||||
assert.equal(await md5(file), '7df171da63e2013c9b17e1857615b192');
|
||||
})
|
||||
});
|
Reference in New Issue
Block a user