test(downloading): add downloading tab & some buttons tests
This commit is contained in:
		| @ -43,7 +43,7 @@ export default class TopPage extends Page { | ||||
|   				<RaisedButton label={__('Back to main page')} primary={true} onClick={() => { | ||||
|   					window.router('/') | ||||
|   				}} /> | ||||
|   				<List style={{paddingBottom: '70px', minWidth: '60%'}} className='animated recent-torrents'> | ||||
|   				<List style={{paddingBottom: '70px', minWidth: '60%'}} className='animated recent-torrents downloads-list'> | ||||
|   					{ | ||||
|   						this.downloads.map((torrentDownload, index) => { | ||||
|   							const {torrentObject: torrent, ...download} = torrentDownload | ||||
|  | ||||
| @ -216,6 +216,7 @@ class Header extends React.Component { | ||||
| 							/> | ||||
| 							<RaisedButton | ||||
| 								label={__('Downloads')} | ||||
| 								id='downloadTab' | ||||
| 								onClick={() => { | ||||
| 									window.router('/downloads') | ||||
| 								}} | ||||
|  | ||||
| @ -32,7 +32,7 @@ export default class SearchPage extends Page { | ||||
|  | ||||
| 		return ( | ||||
| 			<div className='column center'> | ||||
| 				<div className='torrents-container'> | ||||
| 				<div className='torrents-container search-list'> | ||||
| 					<SearchResults  | ||||
| 						torrentsSearchResults={Search.instance().searchTorrents}  | ||||
| 						filesSearchResults={Search.instance().searchFiles} | ||||
|  | ||||
| @ -264,6 +264,7 @@ class Search extends Component { | ||||
|                         <div style={{width: 25, height: 25, margin: 2, marginRight: 8}}> | ||||
|                         	<Tooltip hint={__('display search results for current search request')}> | ||||
|                         		<Checkbox | ||||
| 									id='open-recent-search' | ||||
|                         			checked={false} | ||||
|                         			uncheckedIcon={<svg viewBox="0 0 459 459"> | ||||
|                         				<g> | ||||
|  | ||||
| @ -392,7 +392,7 @@ export default class Torrent extends Component { | ||||
|                               && | ||||
|                               <ToolTip hint={__('Pause torrent downloading')} right={true}> | ||||
|                               	<a href={`magnet:?xt=urn:btih:${torrent.hash}`}> | ||||
|                               		<svg style={{ | ||||
|                               		<svg className='pauseTorrent' style={{ | ||||
|                               			height: '24px', | ||||
|                               			marginRight: 16, | ||||
|                               			fill: this.state.downloadPaused ? '#42f47a' : 'black' | ||||
|  | ||||
| @ -7,6 +7,13 @@ const fs = require('fs') | ||||
| describe("download", function() { | ||||
| 	this.timeout(30000); | ||||
|  | ||||
| 	const fileTest = config.client.downloadPath + "/Roblox_setup.exe" | ||||
|  | ||||
| 	it("cleanup", function() { | ||||
| 		if(fs.existsSync(fileTest)) | ||||
| 			fs.unlinkSync(fileTest); | ||||
| 	}) | ||||
|  | ||||
| 	it("click download", async function() { | ||||
| 		this.timeout(45000); | ||||
| 		const { app } = this | ||||
| @ -21,13 +28,31 @@ describe("download", function() { | ||||
| 		await app.client.click('.torrentRow .downloadFullButton') | ||||
| 	}) | ||||
|  | ||||
| 	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() | ||||
| 		assert.equal(value, 'Roblox_setup.exe') | ||||
| 		// cancel in progress button must be exists | ||||
| 		assert(await app.client.isExisting('.torrentRow .deleteDownloadBeforeFinish')); | ||||
| 		assert(await app.client.isExisting('.torrentRow .pauseTorrent')); | ||||
| 		// back to recent search | ||||
| 		await app.client.click('#open-recent-search') | ||||
| 		await app.client.waitForExist('.search-list') | ||||
| 	}) | ||||
|  | ||||
| 	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) | ||||
| 		}, 60000, 'expected that download will be finished', 200) | ||||
| 		 | ||||
| 		// Check Buttons After finish | ||||
| 		assert(!(await app.client.isExisting('.torrentRow .deleteDownloadBeforeFinish'))); | ||||
| 	}) | ||||
|  | ||||
| 	it("check file after download", async function() { | ||||
| @ -38,16 +63,30 @@ describe("download", function() { | ||||
| 	}) | ||||
|  | ||||
| 	it("delete download from manager (after finish)", async function() { | ||||
| 		this.timeout(10000); | ||||
| 		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%') | ||||
| 		// Click cancel of download | ||||
| 		await app.client.click('.torrentRow .deleteDownloadAfterFinish') | ||||
| 		assert(!(await app.client.isExisting('.torrentRow .deleteDownloadAfterFinish'))); | ||||
| 		// Download deleted, but must be keeped in search | ||||
| 		const value = 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'))); | ||||
| 	}) | ||||
|  | ||||
| 	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'); | ||||
| 		assert(fs.existsSync(fileTest)); | ||||
| 		assert.equal(await md5(fileTest), '7df171da63e2013c9b17e1857615b192'); | ||||
| 	}) | ||||
| }); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user