diff --git a/test/screenshots/darwin/create-torrent-advanced.png b/test/screenshots/darwin/create-torrent-advanced.png index f8055bc0..fffeb6c3 100644 Binary files a/test/screenshots/darwin/create-torrent-advanced.png and b/test/screenshots/darwin/create-torrent-advanced.png differ diff --git a/test/setup.js b/test/setup.js index f88f8c5b..4f042cce 100644 --- a/test/setup.js +++ b/test/setup.js @@ -11,6 +11,7 @@ module.exports = { screenshotCreateOrCompare, compareDownloadFolder, compareFiles, + compareTorrentFile, compareTorrentFiles, waitForLoad, wait, @@ -185,6 +186,13 @@ function compareTorrentFiles (t, pathActual, pathExpected) { t.deepEqual(fieldsActual, fieldsExpected, 'torrent contents: ' + pathActual) } +// Makes sure two torrents have the same infohash and flags +function compareTorrentFile (t, pathActual, fieldsExpected) { + const bufActual = fs.readFileSync(pathActual) + const fieldsActual = extractImportantFields(parseTorrent(bufActual)) + t.deepEqual(fieldsActual, fieldsExpected, 'torrent contents: ' + pathActual) +} + function extractImportantFields (parsedTorrent) { const { infoHash, name, announce, urlList, comment } = parsedTorrent const priv = parsedTorrent.private // private is a reserved word in JS diff --git a/test/test-add-torrent.js b/test/test-add-torrent.js index 2fb2e8d1..69a6869f 100644 --- a/test/test-add-torrent.js +++ b/test/test-add-torrent.js @@ -36,6 +36,24 @@ test('add-torrent', function (t) { test('create-torrent', function (t) { setup.resetTestDataDir() + const expectedTorrent = { + announce: [ + 'udp://exodus.desync.com:6969', + 'udp://tracker.coppersurfer.tk:6969', + 'udp://tracker.internetwarriors.net:1337', + 'udp://tracker.leechers-paradise.org:6969', + 'udp://tracker.openbittorrent.com:80', + 'wss://tracker.btorrent.xyz', + 'wss://tracker.fastcast.nz', + 'wss://tracker.openwebtorrent.com' + ], + comment: undefined, + infoHash: '4b087858a32e31a0d313b5f9e0a2e13c08c5403f', + name: 'tmp.jpg', + private: false, + urlList: [] + } + // Set up the files to seed setup.copy(path.join(__dirname, 'resources', 'm3.jpg'), config.SEED_FILES[0]) @@ -61,9 +79,9 @@ test('create-torrent', function (t) { 'dispatch("saveTorrentFileAs", 6)')) .then(() => setup.wait()) // Mock saves to /Desktop/saved.torrent - .then(() => setup.compareTorrentFiles(t, + .then(() => setup.compareTorrentFile(t, config.SAVED_TORRENT_FILE, - path.join(__dirname, 'resources', 'expected-single-file.torrent'))) + expectedTorrent)) .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) }) diff --git a/test/test-audio.js b/test/test-audio.js index 84f8d668..ab002ee9 100644 --- a/test/test-audio.js +++ b/test/test-audio.js @@ -16,12 +16,13 @@ test('audio-streaming', function (t) { // 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("skipTo", 2)')) - .then(() => setup.wait()) - .then(() => app.client.waitUntilTextExists('.player', 'Beastie Boys')) + .then(() => app.client.waitUntilTextExists('.player', 'Beastie Boys', 10e3)) + .then(() => setup.wait(5e3)) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired')) // Click next .then(() => app.client.click('.skip-next')) .then(() => app.client.waitUntilTextExists('.player', 'David Byrne')) + .then(() => setup.wait(5e3)) .then(() => app.client.moveToObject('.letterbox')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) @@ -30,7 +31,8 @@ test('audio-streaming', function (t) { .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) // Play past the end of the song, then pause after the start of the next song by Zap Mama - .then(() => app.client.waitUntilTextExists('.player', 'Zap Mama', 15e3)) + .then(() => app.client.waitUntilTextExists('.player', 'Zap Mama'), 15e3) + .then(() => setup.wait(5e3)) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-3'))