diff --git a/src/renderer/pages/torrent-list-page.js b/src/renderer/pages/torrent-list-page.js index 102f9fb2..82933702 100644 --- a/src/renderer/pages/torrent-list-page.js +++ b/src/renderer/pages/torrent-list-page.js @@ -14,7 +14,7 @@ module.exports = class TorrentList extends React.Component { if (state.downloadPathStatus === 'missing') { contents.push(
-

Download path missing: {state.saved.prefs.downloadPath}

+

Download path missing: {state.saved.prefs.downloadPath}

Check that all drives are connected?

Alternatively, choose a new download path in Preferences diff --git a/test/index.js b/test/index.js index c8a4a361..e4ae8af3 100644 --- a/test/index.js +++ b/test/index.js @@ -32,10 +32,12 @@ test('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.screenshotCreateOrCompare(app, t, 'torrent-list-download-path-missing')) .then(() => app.client.click('a')) .then(() => setup.wait()) .then(() => app.browserWindow.getTitle()) - .then((windowTitle) => t.equal(windowTitle, 'Preferences')) + .then((windowTitle) => t.equal(windowTitle, 'Preferences', 'window title')) + .then(() => setup.screenshotCreateOrCompare(app, t, 'prefs-basic')) .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) }) diff --git a/test/screenshots/darwin/prefs-basic.png b/test/screenshots/darwin/prefs-basic.png new file mode 100644 index 00000000..cf8d4e79 Binary files /dev/null and b/test/screenshots/darwin/prefs-basic.png differ diff --git a/test/screenshots/darwin/torrent-list-download-path-missing.png b/test/screenshots/darwin/torrent-list-download-path-missing.png new file mode 100644 index 00000000..dc01b9d8 Binary files /dev/null and b/test/screenshots/darwin/torrent-list-download-path-missing.png differ diff --git a/test/setup.js b/test/setup.js index 31e5e9b2..e3da57f6 100644 --- a/test/setup.js +++ b/test/setup.js @@ -28,16 +28,19 @@ function createApp (t) { // Starts the app, waits for it to load, returns a promise function waitForLoad (app, t) { return app.start().then(function () { + // Switch to the main window. Index 0 is apparently the hidden webtorrent window... return app.client.windowByIndex(1) }).then(function () { return app.client.waitUntilWindowLoaded() }).then(function () { return app.webContents.getTitle() }).then(function (title) { - t.equal(title, 'WebTorrent Desktop', 'app title') + // Note the window title is WebTorrent (BETA), this is the HTML + t.equal(title, 'WebTorrent Desktop', 'html title') }) } +// Returns a promise that resolves after 'ms' milliseconds. Default: 500 function wait (ms) { if (ms === undefined) ms = 500 // Default: wait long enough for the UI to update return new Promise(function (resolve, reject) { @@ -45,24 +48,26 @@ function wait (ms) { }) } +// Quit the app, end the test, either in success (!err) or failure (err) function endTest (app, t, err) { return app.stop().then(function () { t.end(err) }) } +// Takes a screenshot of the app +// If we already have a reference under test/screenshots, assert that they're the same +// Otherwise, create the reference screenshot: test/screenshots/<platform>/<name>.png function screenshotCreateOrCompare (app, t, name) { const ssPath = path.join(__dirname, 'screenshots', process.platform, name + '.png') - console.log('Capturing ' + ssPath) fs.ensureFileSync(ssPath) const ssBuf = fs.readFileSync(ssPath) return app.browserWindow.capturePage().then(function (buffer) { if (ssBuf.length === 0) { console.log('Saving screenshot ' + ssPath) fs.writeFileSync(ssPath, buffer) - } else if (Buffer.compare(buffer, ssBuf) !== 0) { - return Promise.reject('Screenshot didn\'t match: ' + ssPath) } else { + t.ok(Buffer.compare(buffer, ssBuf) === 0, 'screenshot ' + name) return Promise.resolve() } })