From 3a286ae9789a148409de969b9c8d0931c58afb31 Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 20 Sep 2016 11:30:28 -0700 Subject: [PATCH] Integration test: wait for next song --- test/test-add-torrent.js | 12 ++++++------ test/test-audio.js | 11 ++++++----- test/test-torrent-list.js | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/test/test-add-torrent.js b/test/test-add-torrent.js index 8352ed96..c6ae03c4 100644 --- a/test/test-add-torrent.js +++ b/test/test-add-torrent.js @@ -13,20 +13,20 @@ test('add-torrent', function (t) { // Add an existing torrent. The corresponding file is not present. Should be at 0% .then(() => app.electron.ipcRenderer.send('openTorrentFile')) // The call to dialog.openFiles() is mocked. See mocks.js - .then(() => app.client.waitUntilTextExists('m3.jpg')) + .then(() => app.client.waitUntilTextExists('.torrent-list', 'm3.jpg')) .then(() => setup.screenshotCreateOrCompare(app, t, 'add-torrent-0-percent')) // 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.waitUntilTextExists('.modal', 'REMOVE')) .then(() => app.client.click('.control.ok')) // Add the same existing torrent, this time with the file present. Should be at 100% .then(() => setup.copy( path.join(__dirname, 'resources', 'm3.jpg'), path.join(config.TEST_DIR_DOWNLOAD, 'm3.jpg'))) .then(() => app.electron.ipcRenderer.send('openTorrentFile')) - .then(() => app.client.waitUntilTextExists('m3.jpg')) + .then(() => app.client.waitUntilTextExists('.torrent-list', 'm3.jpg')) .then(() => app.client.moveToObject('.torrent')) .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'add-torrent-100-percent')) @@ -46,15 +46,15 @@ test('create-torrent', function (t) { .then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny')) // Click the + button, open a non-torrent file to seed .then(() => app.client.click('.icon.add')) - .then(() => app.client.waitUntilTextExists('Create')) + .then(() => app.client.waitUntilTextExists('.create-torrent', 'Create')) .then(() => setup.screenshotCreateOrCompare(app, t, 'create-torrent-simple')) // Click to show advanced settings .then(() => app.client.click('.show-more .control')) - .then(() => app.client.waitUntilTextExists('Comment')) + .then(() => app.client.waitUntilTextExists('.create-torrent', 'Comment')) .then(() => setup.screenshotCreateOrCompare(app, t, 'create-torrent-advanced')) // Click OK to create the torrent .then(() => app.client.click('.control.create-torrent')) - .then(() => app.client.waitUntilTextExists('tmp.jpg')) + .then(() => app.client.waitUntilTextExists('.torrent-list', 'tmp.jpg')) .then(() => setup.screenshotCreateOrCompare(app, t, 'create-torrent-100-percent')) // Click "Save Torrent File As..." on the new torrent .then(() => app.webContents.executeJavaScript( diff --git a/test/test-audio.js b/test/test-audio.js index a7a0f2a2..561c6ed3 100644 --- a/test/test-audio.js +++ b/test/test-audio.js @@ -12,16 +12,16 @@ test('audio-streaming', function (t) { .then(() => app.client.moveToObject('#torrent-wired')) .then(() => setup.wait()) .then(() => app.client.click('#torrent-wired .icon.play')) - .then(() => app.client.waitUntilTextExists('The Wired CD')) + .then(() => app.client.waitUntilTextExists('.player', 'The Wired CD')) // 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('Artist')) + .then(() => app.client.waitUntilTextExists('.player', 'Artist')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired')) // Click next .then(() => app.client.click('.skip-next')) - .then(() => app.client.waitUntilTextExists('The Wired CD')) + .then(() => app.client.waitUntilTextExists('.player', 'David Byrne')) .then(() => app.client.moveToObject('.letterbox')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) @@ -30,7 +30,8 @@ test('audio-streaming', function (t) { // Play from end of song, let it advance on its own .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) - .then(() => setup.wait(5e3)) // Let it play a few seconds, past the end of the song + // 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.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => setup.wait()) @@ -45,7 +46,7 @@ test('audio-streaming', function (t) { .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-4')) // Back. Return to torrent list .then(() => app.client.click('.back')) - .then(() => app.client.waitUntilTextExists('Big Buck Bunny')) + .then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-list')) // Forward. Should play again where we left off (should not stay paused) .then(() => app.client.click('.forward')) diff --git a/test/test-torrent-list.js b/test/test-torrent-list.js index c9b946fe..7d85eca6 100644 --- a/test/test-torrent-list.js +++ b/test/test-torrent-list.js @@ -14,6 +14,7 @@ test('torrent-list: show download path missing', function (t) { .then((text) => console.log('Title ' + text)) .then(() => app.client.waitUntilTextExists('.torrent-list', 'Download path missing')) .then((err) => t.notOk(err)) + .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-download-path-missing')) .then(() => app.client.click('a')) .then(() => setup.wait())