Integration test: add existing torrent
This commit is contained in:
@@ -15,17 +15,15 @@ test('app runs', function (t) {
|
||||
const app = setup.createApp()
|
||||
setup.waitForLoad(app, t)
|
||||
.then(() => setup.wait())
|
||||
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-basic'))
|
||||
.then(() => setup.screenshotCreateOrCompare(app, t, 'app-basic'))
|
||||
.then(() => setup.endTest(app, t),
|
||||
(err) => setup.endTest(app, t, err || 'error'))
|
||||
})
|
||||
|
||||
console.log('Testing the torrent list (home page)...')
|
||||
setup.wipeTestDataDir()
|
||||
require('./test-torrent-list')
|
||||
// require('./test-torrent-list')
|
||||
require('./test-add-torrent')
|
||||
|
||||
// TODO:
|
||||
// require('./test-add-torrent')
|
||||
// require('./test-create-torrent')
|
||||
// require('./test-prefs')
|
||||
// require('./test-video')
|
||||
|
||||
9
test/mocks.js
Normal file
9
test/mocks.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const path = require('path')
|
||||
const electron = require('electron')
|
||||
|
||||
const MOCK_OPEN_TORRENTS = [path.join(__dirname, 'resources', '1.torrent')]
|
||||
|
||||
console.log('Mocking electron native integrations...')
|
||||
electron.dialog.showOpenDialog = function (win, opts, cb) {
|
||||
cb(MOCK_OPEN_TORRENTS)
|
||||
}
|
||||
BIN
test/resources/1.torrent
Normal file
BIN
test/resources/1.torrent
Normal file
Binary file not shown.
BIN
test/resources/m3.jpg
Normal file
BIN
test/resources/m3.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 MiB |
BIN
test/screenshots/darwin/add-torrent-existing-1.png
Normal file
BIN
test/screenshots/darwin/add-torrent-existing-1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
BIN
test/screenshots/darwin/add-torrent-existing-2.png
Normal file
BIN
test/screenshots/darwin/add-torrent-existing-2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@@ -24,7 +24,7 @@ function createApp (t) {
|
||||
return new Application({
|
||||
path: path.join(__dirname, '..', 'node_modules', '.bin',
|
||||
'electron' + (process.platform === 'win32' ? '.cmd' : '')),
|
||||
args: [path.join(__dirname, '..')],
|
||||
args: ['-r', path.join(__dirname, 'mocks.js'), path.join(__dirname, '..')],
|
||||
env: {NODE_ENV: 'test'}
|
||||
})
|
||||
}
|
||||
|
||||
35
test/test-add-torrent.js
Normal file
35
test/test-add-torrent.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const test = require('tape')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const setup = require('./setup')
|
||||
|
||||
test('add-torrent', function (t) {
|
||||
setup.wipeTestDataDir()
|
||||
|
||||
t.timeoutAfter(100e3)
|
||||
const app = setup.createApp()
|
||||
setup.waitForLoad(app, t)
|
||||
.then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny'))
|
||||
// Add an existing torrent. The corresponding file is not present. Should be at 0%
|
||||
.then(() => app.client.click('.icon.add'))
|
||||
// The call to dialog.openFiles() is mocked. See mocks.js
|
||||
.then(() => app.client.waitUntilTextExists('m3.jpg'))
|
||||
.then(() => setup.screenshotCreateOrCompare(app, t, 'add-torrent-existing-1'))
|
||||
// Delete the torrent.
|
||||
.then(() => app.client.moveToObject('.torrent'))
|
||||
.then(() => setup.wait())
|
||||
.then(() => app.client.click('.icon.delete'))
|
||||
.then(() => app.client.waitUntilTextExists('REMOVE'))
|
||||
.then(() => app.client.click('.control.ok'))
|
||||
.then(() => setup.wait())
|
||||
// Add the same existing torrent, this time with the file present. Should be at 100%
|
||||
.then(() => fs.copySync(
|
||||
path.join(__dirname, 'resources', 'm3.jpg'),
|
||||
path.join(setup.TEST_DOWNLOAD_DIR, 'm3.jpg')))
|
||||
.then(() => app.client.click('.icon.add'))
|
||||
.then(() => app.client.waitUntilTextExists('m3.jpg'))
|
||||
.then(() => setup.wait())
|
||||
.then(() => setup.screenshotCreateOrCompare(app, t, 'add-torrent-existing-2'))
|
||||
.then(() => setup.endTest(app, t),
|
||||
(err) => setup.endTest(app, t, err || 'error'))
|
||||
})
|
||||
Reference in New Issue
Block a user