diff --git a/lib/negative-test.js b/lib/negative-test.js index e11a1a8..e66eb5c 100644 --- a/lib/negative-test.js +++ b/lib/negative-test.js @@ -75,6 +75,8 @@ module.exports = { ipcMain.on('test-capture', () => simulateMenuClick(['View', 'Capture'])); ipcMain.on('test-clear', () => simulateMenuClick(['View', 'Clear'])); ipcMain.on('test-dark-mode', () => simulateMenuClick(['View', 'Dark Mode'])); + ipcMain.on('test-translucence', () => simulateMenuClick(['View', 'Translucence'])); + ipcMain.on('test-inversion', () => simulateMenuClick(['View', 'Inversion'])); ipcMain.on('test-actual-size', () => simulateMenuClick(['View', 'Actual Size'])); ipcMain.on('test-zoom-in', () => simulateMenuClick(['View', 'Zoom In'])); ipcMain.on('test-zoom-out', () => simulateMenuClick(['View', 'Zoom Out'])); diff --git a/test/tests/menu/view/inversion.js b/test/tests/menu/view/inversion.js new file mode 100644 index 0000000..9a020df --- /dev/null +++ b/test/tests/menu/view/inversion.js @@ -0,0 +1,70 @@ +'use strict'; + +const { Application } = require('spectron'); +const { assert } = require('chai'); + +const config = require('../../../config.json'); +const { + APP_PATH, + WAIT_UNTIL_TIMEOUT +} = config; + +describe('View > Inversion', function () { + const app = new Application({ + path: APP_PATH, + env: { + ELECTRON_ENABLE_LOGGING: true, + ELECTRON_ENABLE_STACK_DUMPING: true, + NEGATIVE_IGNORE_SETTINGS: true, + NEGATIVE_SKIP_RESET_DIALOG: true, + NEGATIVE_VERBOSE: true, + NODE_ENV: 'development' + } + }); + + this.timeout(60000); + + beforeEach(() => { + return app.start(); + }); + + afterEach(() => { + if (app && app.isRunning()) { + return app.stop(); + } + }); + + it('Should toggle inversion', () => { + return app.client.waitUntilWindowLoaded() + .then(() => { + return app.client.selectorExecute('//body', (elements) => { + return elements[0].classList.contains('inversion-off'); + }); + }) + .then((hasTranslucenceOffClass) => assert.isFalse(hasTranslucenceOffClass, 'The body element should not have the .inversion-off class when on startup.')) + .then(() => app.electron.ipcRenderer.send('test-inversion')) + .then(() => { + return app.client.waitUntil(() => { + return app.client.selectorExecute('//body', (elements) => { + return elements[0].classList.contains('inversion-off'); + }); + }, WAIT_UNTIL_TIMEOUT); + }) + .then((hasTranslucenceOffClass) => assert.isTrue(hasTranslucenceOffClass, 'The body element should have the .inversion-off class when Inversion is off.')) + .catch((err) => { + return app.client.getMainProcessLogs() + .then((logs) => { + console.log('*** MAIN PROCESS LOGS ***'); + logs.forEach((log) => console.log(log)); + + return app.client.getRenderProcessLogs(); + }) + .then((logs) => { + console.log('*** RENDER PROCESS LOGS ***'); + logs.forEach((log) => console.log(log)); + + throw err; + }); + }); + }); +}); diff --git a/test/tests/menu/view/translucence.js b/test/tests/menu/view/translucence.js new file mode 100644 index 0000000..e04c2c0 --- /dev/null +++ b/test/tests/menu/view/translucence.js @@ -0,0 +1,70 @@ +'use strict'; + +const { Application } = require('spectron'); +const { assert } = require('chai'); + +const config = require('../../../config.json'); +const { + APP_PATH, + WAIT_UNTIL_TIMEOUT +} = config; + +describe('View > Translucence', function () { + const app = new Application({ + path: APP_PATH, + env: { + ELECTRON_ENABLE_LOGGING: true, + ELECTRON_ENABLE_STACK_DUMPING: true, + NEGATIVE_IGNORE_SETTINGS: true, + NEGATIVE_SKIP_RESET_DIALOG: true, + NEGATIVE_VERBOSE: true, + NODE_ENV: 'development' + } + }); + + this.timeout(60000); + + beforeEach(() => { + return app.start(); + }); + + afterEach(() => { + if (app && app.isRunning()) { + return app.stop(); + } + }); + + it('Should toggle translucence', () => { + return app.client.waitUntilWindowLoaded() + .then(() => { + return app.client.selectorExecute('//body', (elements) => { + return elements[0].classList.contains('translucence-off'); + }); + }) + .then((hasTranslucenceOffClass) => assert.isFalse(hasTranslucenceOffClass, 'The body element should not have the .translucence-off class when on startup.')) + .then(() => app.electron.ipcRenderer.send('test-translucence')) + .then(() => { + return app.client.waitUntil(() => { + return app.client.selectorExecute('//body', (elements) => { + return elements[0].classList.contains('translucence-off'); + }); + }, WAIT_UNTIL_TIMEOUT); + }) + .then((hasTranslucenceOffClass) => assert.isTrue(hasTranslucenceOffClass, 'The body element should have the .translucence-off class when Translucence is off.')) + .catch((err) => { + return app.client.getMainProcessLogs() + .then((logs) => { + console.log('*** MAIN PROCESS LOGS ***'); + logs.forEach((log) => console.log(log)); + + return app.client.getRenderProcessLogs(); + }) + .then((logs) => { + console.log('*** RENDER PROCESS LOGS ***'); + logs.forEach((log) => console.log(log)); + + throw err; + }); + }); + }); +});