Integration test: address PR comments

This commit is contained in:
DC
2016-09-17 18:14:31 -07:00
parent 711d274398
commit 6541291e0d
6 changed files with 16 additions and 12 deletions

View File

@@ -56,8 +56,10 @@ const VERSION_PREFIX = '-WD' + VERSION_STR + '-'
/** /**
* Generate an ephemeral peer ID each time. * Generate an ephemeral peer ID each time.
* TODO: once there are around 2^24 = ~8 million WebTorrent Desktops online at the same time, * Once there are around 2^24 = ~8 million WebTorrent Desktops online at the same time,
* ID collisions will start happening. Birthday paradox. Can we use more than six bytes? * ID collisions will start happening. Birthday paradox.
* This is fine, though. Bad peers can already clone someone else's peer ID.
* The network is robust to occasional collisions.
*/ */
const PEER_ID = Buffer.from(VERSION_PREFIX + crypto.randomBytes(6).toString('hex')) const PEER_ID = Buffer.from(VERSION_PREFIX + crypto.randomBytes(6).toString('hex'))
@@ -166,7 +168,7 @@ function addTorrentEvents (torrent) {
function torrentReady () { function torrentReady () {
const info = getTorrentInfo(torrent) const info = getTorrentInfo(torrent)
ipc.send('wt-ready', torrent.key, info) ipc.send('wt-ready', torrent.key, info)
ipc.send('wt-ready-' + torrent.infoHash, torrent.key, info) // TODO: hack ipc.send('wt-ready-' + torrent.infoHash, torrent.key, info)
updateTorrentProgress() updateTorrentProgress()
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 KiB

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 480 KiB

View File

@@ -165,6 +165,6 @@ function compareTorrentFiles (t, pathActual, pathExpected) {
function extractImportantFields (parsedTorrent) { function extractImportantFields (parsedTorrent) {
const { infoHash, name, announce, urlList, comment } = parsedTorrent const { infoHash, name, announce, urlList, comment } = parsedTorrent
const priv = parsedTorrent.private const priv = parsedTorrent.private // private is a reserved word in JS
return { infoHash, name, announce, urlList, comment, 'private': priv } return { infoHash, name, announce, urlList, comment, 'private': priv }
} }

View File

@@ -4,7 +4,7 @@ const setup = require('./setup')
test('audio-streaming', function (t) { test('audio-streaming', function (t) {
setup.resetTestDataDir() setup.resetTestDataDir()
t.timeoutAfter(40e3) t.timeoutAfter(60e3)
const app = setup.createApp() const app = setup.createApp()
setup.waitForLoad(app, t, {online: true}) setup.waitForLoad(app, t, {online: true})
.then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny')) .then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny'))
@@ -12,15 +12,17 @@ test('audio-streaming', function (t) {
.then(() => app.client.moveToObject('#torrent-wired')) .then(() => app.client.moveToObject('#torrent-wired'))
.then(() => setup.wait()) .then(() => setup.wait())
.then(() => app.client.click('#torrent-wired .icon.play')) .then(() => app.client.click('#torrent-wired .icon.play'))
.then(() => setup.wait(5e3)) .then(() => app.client.waitUntilTextExists('The Wired CD'))
// Pause. Skip to two seconds in. Wait another two seconds for it to load. // Pause. Skip to two seconds in. Wait another two seconds for it to load.
.then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)'))
.then(() => setup.wait()) .then(() => setup.wait())
.then(() => app.client.waitUntilTextExists('Artist'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired'))
// Click next // Click next
.then(() => app.client.click('.skip-next')) .then(() => app.client.click('.skip-next'))
.then(() => setup.wait()) .then(() => app.client.waitUntilTextExists('The Wired CD'))
.then(() => app.client.moveToObject('.letterbox'))
.then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)'))
.then(() => setup.wait()) .then(() => setup.wait())
@@ -28,7 +30,7 @@ test('audio-streaming', function (t) {
// Play from end of song, let it advance on its own // Play from end of song, let it advance on its own
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)'))
.then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
.then(() => setup.wait(5e3)) .then(() => setup.wait(5e3)) // Let it play a few seconds, past the end of the song
.then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)'))
.then(() => setup.wait()) .then(() => setup.wait())
@@ -39,11 +41,11 @@ test('audio-streaming', function (t) {
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-fullscreen')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-fullscreen'))
// Back to normal audio view. Give the player controls have had time to disappear. // Back to normal audio view. Give the player controls have had time to disappear.
.then(() => app.webContents.executeJavaScript('dispatch("escapeBack")')) .then(() => app.webContents.executeJavaScript('dispatch("escapeBack")'))
.then(() => setup.wait(5e3)) .then(() => setup.wait())
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-4')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-4'))
// Back. Return to torrent list // Back. Return to torrent list
.then(() => app.client.click('.back')) .then(() => app.client.click('.back'))
.then(() => setup.wait()) .then(() => app.client.waitUntilTextExists('Big Buck Bunny'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-list')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-list'))
// Forward. Should play again where we left off (should not stay paused) // Forward. Should play again where we left off (should not stay paused)
.then(() => app.client.click('.forward')) .then(() => app.client.click('.forward'))

View File

@@ -3,7 +3,7 @@ const fs = require('fs-extra')
const setup = require('./setup') const setup = require('./setup')
const config = require('./config') const config = require('./config')
test.skip('torrent-list: show download path missing', function (t) { test('torrent-list: show download path missing', function (t) {
setup.resetTestDataDir() setup.resetTestDataDir()
fs.removeSync(config.TEST_DIR_DOWNLOAD) fs.removeSync(config.TEST_DIR_DOWNLOAD)
@@ -36,7 +36,7 @@ test('torrent-list: start, stop, and delete torrents', function (t) {
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover')) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover'))
// Click download on the first torrent, start downloading // Click download on the first torrent, start downloading
.then(() => app.client.click('.icon.download')) .then(() => app.client.click('.icon.download'))
.then(() => app.client.waitUntilTextExists('.torrent-list', '0%')) .then(() => app.client.waitUntilTextExists('.torrent-list', '276MB'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download')) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download'))
// Click download on the first torrent again, stop downloading // Click download on the first torrent again, stop downloading
.then(() => app.client.click('.icon.download')) .then(() => app.client.click('.icon.download'))