diff --git a/test/index.js b/test/index.js index 65856dd7..cf9850c6 100644 --- a/test/index.js +++ b/test/index.js @@ -8,7 +8,6 @@ test('app runs', function (t) { setup.resetTestDataDir() const app = setup.createApp() setup.waitForLoad(app, t) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'app-basic')) .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) diff --git a/test/screenshots/darwin/create-torrent-100-percent.png b/test/screenshots/darwin/create-torrent-100-percent.png index 26087fc8..38d309de 100644 Binary files a/test/screenshots/darwin/create-torrent-100-percent.png and b/test/screenshots/darwin/create-torrent-100-percent.png differ diff --git a/test/setup.js b/test/setup.js index e2063ef9..037fd338 100644 --- a/test/setup.js +++ b/test/setup.js @@ -75,7 +75,9 @@ function screenshotCreateOrCompare (app, t, name) { const ssPath = path.join(ssDir, name + '.png') fs.ensureFileSync(ssPath) const ssBuf = fs.readFileSync(ssPath) - return app.browserWindow.capturePage().then(function (buffer) { + return wait().then(function () { + return app.browserWindow.capturePage() + }).then(function (buffer) { if (ssBuf.length === 0) { console.log('Saving screenshot ' + ssPath) fs.writeFileSync(ssPath, buffer) diff --git a/test/test-add-torrent.js b/test/test-add-torrent.js index c6ae03c4..4450d9dc 100644 --- a/test/test-add-torrent.js +++ b/test/test-add-torrent.js @@ -28,7 +28,6 @@ test('add-torrent', function (t) { .then(() => app.electron.ipcRenderer.send('openTorrentFile')) .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')) .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) @@ -55,6 +54,7 @@ test('create-torrent', function (t) { // Click OK to create the torrent .then(() => app.client.click('.control.create-torrent')) .then(() => app.client.waitUntilTextExists('.torrent-list', 'tmp.jpg')) + .then(() => app.client.moveToObject('.torrent')) .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 561c6ed3..a3c43cea 100644 --- a/test/test-audio.js +++ b/test/test-audio.js @@ -17,7 +17,7 @@ test('audio-streaming', function (t) { .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) .then(() => setup.wait()) - .then(() => app.client.waitUntilTextExists('.player', 'Artist')) + .then(() => app.client.waitUntilTextExists('.player', 'Beastie Boys')) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired')) // Click next .then(() => app.client.click('.skip-next')) @@ -25,7 +25,6 @@ test('audio-streaming', function (t) { .then(() => app.client.moveToObject('.letterbox')) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-2')) // Play from end of song, let it advance on its own .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)')) @@ -34,15 +33,12 @@ test('audio-streaming', function (t) { .then(() => app.client.waitUntilTextExists('.player', 'Zap Mama'), 15e3) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-3')) // Fullscreen .then(() => app.client.click('.fullscreen')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-fullscreen')) // Back to normal audio view. Give the player controls have had time to disappear. .then(() => app.webContents.executeJavaScript('dispatch("escapeBack")')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-4')) // Back. Return to torrent list .then(() => app.client.click('.back')) @@ -53,7 +49,6 @@ test('audio-streaming', function (t) { .then(() => setup.wait()) .then(() => app.webContents.executeJavaScript('dispatch("playPause")')) .then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-5')) .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) diff --git a/test/test-torrent-list.js b/test/test-torrent-list.js index 7d85eca6..18236853 100644 --- a/test/test-torrent-list.js +++ b/test/test-torrent-list.js @@ -14,7 +14,6 @@ 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()) @@ -33,7 +32,6 @@ test('torrent-list: start, stop, and delete torrents', function (t) { .then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny')) // Mouse over the first torrent .then(() => app.client.moveToObject('.torrent')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover')) // Click download on the first torrent, start downloading .then(() => app.client.click('.icon.download')) @@ -41,23 +39,18 @@ test('torrent-list: start, stop, and delete torrents', function (t) { .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download')) // Click download on the first torrent again, stop downloading .then(() => app.client.click('.icon.download')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover-download')) // Click delete on the first torrent .then(() => app.client.click('.icon.delete')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-delete-prompt')) // Click cancel on the resulting confirmation dialog. Should be same as before. .then(() => app.client.click('.control.cancel')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover')) // Click delete on the first torrent again .then(() => app.client.click('.icon.delete')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-delete-prompt')) // This time, click OK to confirm. .then(() => app.client.click('.control.ok')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-deleted')) .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) @@ -71,20 +64,16 @@ test('torrent-list: expand torrent, unselect file', function (t) { .then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny')) // Mouse over the torrent .then(() => app.client.moveToObject('#torrent-cosmos')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-hover')) // Click on the torrent, expand .then(() => app.client.click('#torrent-cosmos')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-expand')) // Deselect the first file .then(() => app.client.click('#torrent-cosmos .icon.deselect-file')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-expand-deselect')) // Start the torrent .then(() => app.client.click('#torrent-cosmos .icon.download')) .then(() => app.client.waitUntilTextExists('.torrent-list', 'peers')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-expand-start')) // Make sure that it creates all files EXCEPT the deslected one .then(() => setup.compareDownloadFolder(t, 'CosmosLaundromatFirstCycle', [ @@ -104,11 +93,9 @@ test('torrent-list: expand torrent, unselect file', function (t) { // Spectron doesn't have proper support for menu clicks yet... .then(() => app.webContents.executeJavaScript( 'dispatch("confirmDeleteTorrent", "6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5", true)')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-delete-data')) // Click confirm .then(() => app.client.click('.control.ok')) - .then(() => setup.wait()) .then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-deleted')) // Make sure that all the files are gone .then(() => setup.compareDownloadFolder(t, 'CosmosLaundromatFirstCycle', null)) diff --git a/test/test-video.js b/test/test-video.js index 47bc6d23..b2b6a322 100644 --- a/test/test-video.js +++ b/test/test-video.js @@ -28,7 +28,6 @@ test('video-streaming', function (t) { .then(() => app.client.click('.icon.delete')) .then(() => setup.wait()) .then(() => app.client.click('.control.ok')) - .then(() => setup.wait()) // Take another screenshot to verify that the window resized correctly .then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-return')) .then(() => setup.endTest(app, t),