ELECTRON-357 (#321)

- Skipping npm rebuild every time and only running it once.
- Changed the time-out to 60000ms
- Moved the require to global
- Added done fail in all the catch functions
- Removed unwanted require
This commit is contained in:
Keerthi Niranjan
2018-03-13 15:50:32 +05:30
committed by Vishwas Shashidhar
parent 191ca0c05e
commit 55e75cf5e5
15 changed files with 223 additions and 260 deletions

View File

@@ -19,8 +19,8 @@
"prebuild": "npm run rebuild && npm run browserify-preload", "prebuild": "npm run rebuild && npm run browserify-preload",
"browserify-preload": "browserify -o js/preload/_preloadMain.js -x electron --insert-global-vars=__filename,__dirname js/preload/preloadMain.js --exclude electron-spellchecker", "browserify-preload": "browserify -o js/preload/_preloadMain.js -x electron --insert-global-vars=__filename,__dirname js/preload/preloadMain.js --exclude electron-spellchecker",
"rebuild": "electron-rebuild -f", "rebuild": "electron-rebuild -f",
"test": "npm run lint && jest --verbose --testPathPattern test && npm run rebuild", "test": "npm run lint && npm rebuild --build-from-source && jest --verbose --testPathPattern test && npm run rebuild",
"spectron-test": "jest --config tests/spectron/jest_spectron.json --runInBand && npm run rebuild", "spectron-test": "npm rebuild --build-from-source && jest --config tests/spectron/jest_spectron.json --runInBand && npm run rebuild",
"lint": "eslint --ext .js js/", "lint": "eslint --ext .js js/",
"rename-exe": "cd dist/win-unpacked && ren Symphony.exe Symphony-Electron.exe" "rename-exe": "cd dist/win-unpacked && ren Symphony.exe Symphony-Electron.exe"
}, },

View File

@@ -1,4 +1,3 @@
const childProcess = require('child_process');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const { isWindowsOS } = require('../js/utils/misc.js'); const { isWindowsOS } = require('../js/utils/misc.js');
@@ -37,32 +36,29 @@ describe('Tests for Search', function() {
let tempBatchPath; let tempBatchPath;
let currentDate = new Date().getTime(); let currentDate = new Date().getTime();
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
beforeAll(function (done) { beforeAll(function (done) {
childProcess.exec(`npm rebuild --target=${process.version} --build-from-source`, function(err) { userId = 12345678910112;
key = 'jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd=';
userId = 12345678910112; executionPath = path.join(__dirname, 'library');
key = 'jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd='; if (isWindowsOS) {
executionPath = path.join(__dirname, '..', 'library');
}
userConfigDir = path.join(__dirname, '..');
executionPath = path.join(__dirname, 'library'); searchConfig = require('../js/search/searchConfig.js');
if (isWindowsOS) { const { Search } = require('../js/search/search.js');
executionPath = path.join(__dirname, '..', 'library'); SearchApi = new Search(userId, key);
}
userConfigDir = path.join(__dirname, '..');
searchConfig = require('../js/search/searchConfig.js'); realTimeIndexPath = path.join(userConfigDir, 'data', 'temp_realtime_index');
const { Search } = require('../js/search/search.js'); tempBatchPath = path.join(userConfigDir, 'data', 'temp_batch_indexes');
SearchApi = new Search(userId, key); dataFolderPath = path.join(userConfigDir, 'data');
if (fs.existsSync(dataFolderPath)) {
realTimeIndexPath = path.join(userConfigDir, 'data', 'temp_realtime_index'); deleteIndexFolders(dataFolderPath)
tempBatchPath = path.join(userConfigDir, 'data', 'temp_batch_indexes'); }
dataFolderPath = path.join(userConfigDir, 'data'); done();
if (fs.existsSync(dataFolderPath)) {
deleteIndexFolders(dataFolderPath)
}
done();
});
}); });
afterAll(function (done) { afterAll(function (done) {
@@ -527,4 +523,4 @@ describe('Tests for Search', function() {
}); });
}); });
}); });
}); });

View File

@@ -29,7 +29,7 @@ function mockedGetPath(type) {
describe('Tests for Search Utils', function() { describe('Tests for Search Utils', function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
beforeAll(function (done) { beforeAll(function (done) {
executionPath = path.join(__dirname, 'library'); executionPath = path.join(__dirname, 'library');
@@ -167,4 +167,4 @@ describe('Tests for Search Utils', function() {
}); });
}); });
}); });

View File

@@ -1,19 +1,14 @@
const electron = require('./__mocks__/electron'); const electron = require('./__mocks__/electron');
const childProcess = require('child_process'); const activityDetection = require('../js/activityDetection');
let activityDetection;
describe('Tests for Activity Detection', function() { describe('Tests for Activity Detection', function() {
const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
beforeAll(function(done) { beforeAll(function(done) {
childProcess.exec(`npm rebuild --target=${process.version} --build-from-source`, function(err) { activityDetection.setActivityWindow(900000, electron.ipcRenderer);
activityDetection = require('../js/activityDetection'); done();
activityDetection.setActivityWindow(900000, electron.ipcRenderer);
done();
});
}); });
beforeEach(function() { beforeEach(function() {
@@ -64,4 +59,4 @@ describe('Tests for Activity Detection', function() {
}); });
}); });

View File

@@ -1,10 +1,8 @@
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const {isMac} = require('../../js/utils/misc.js'); const {isMac} = require('../../js/utils/misc.js');
const childProcess = require('child_process'); const robot = require('robotjs');
const constants = require('./spectronConstants');
let app = new Application({}); let app = new Application({});
let robot;
let configPath; let configPath;
let mIsAlwaysOnTop; let mIsAlwaysOnTop;
@@ -14,23 +12,16 @@ describe('Tests for Always on top', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
childProcess.exec(`npm rebuild robotjs --target=${process.version} --build-from-source`, function () { return app.startApplication().then((startedApp) => {
robot = require('robotjs'); app = startedApp;
return app.startApplication().then((startedApp) => { getConfigPath().then((config) => {
app = startedApp; configPath = config;
getConfigPath().then((config) => {
configPath = config;
done();
}).catch((err) => {
console.error(`Unable to get user config path error: ${err}`);
expect(err).toBeNull();
done();
});
}).catch((err) => {
console.error(`Unable to start application error: ${err}`);
expect(err).toBeNull();
done(); done();
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}); });
@@ -57,8 +48,7 @@ describe('Tests for Always on top', () => {
done(); done();
}).catch((err) => { }).catch((err) => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in afterAll with error: ${err}`));
done();
}); });
} }
}); });
@@ -70,23 +60,25 @@ describe('Tests for Always on top', () => {
done(); done();
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should check window count', () => { it('should check window count', (done) => {
return app.client.getWindowCount().then((count) => { return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in getWindowCount with error: ${err}`));
}); });
}); });
it('should check browser window visibility', () => { it('should check browser window visibility', (done) => {
return app.browserWindow.isVisible().then((isVisible) => { return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in isVisible with error: ${err}`));
}); });
}); });
@@ -116,25 +108,28 @@ describe('Tests for Always on top', () => {
}); });
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in setAlwaysOnTop with error: ${err}`));
}); });
} else { } else {
done(); done();
} }
}); });
it('should check is always on top', () => { it('should check is always on top', (done) => {
return Application.readConfig(configPath).then((userData) => { return Application.readConfig(configPath).then((userData) => {
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => { return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
mIsAlwaysOnTop = isAlwaysOnTop; mIsAlwaysOnTop = isAlwaysOnTop;
if (userData.alwaysOnTop) { if (userData.alwaysOnTop) {
expect(isAlwaysOnTop).toBeTruthy(); expect(isAlwaysOnTop).toBeTruthy();
done();
} else { } else {
expect(isAlwaysOnTop).toBeFalsy(); expect(isAlwaysOnTop).toBeFalsy();
done();
} }
done();
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in readConfig with error: ${err}`));
}); });
}); });
@@ -169,23 +164,25 @@ describe('Tests for Always on top', () => {
done(); done();
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in getBounds with error: ${err}`));
}); });
} }
}); });
it('should check is always on top to be true', () => { it('should check is always on top to be true', (done) => {
if (!mIsAlwaysOnTop) { if (!mIsAlwaysOnTop) {
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => { return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
expect(isAlwaysOnTop).toBeTruthy(); expect(isAlwaysOnTop).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in isAlwaysOnTop with error: ${err}`));
}); });
} else { } else {
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => { return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
expect(isAlwaysOnTop).toBeFalsy(); expect(isAlwaysOnTop).toBeFalsy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`alwaysOnTop failed in isAlwaysOnTop with error: ${err}`));
}); });
} }
}); });

View File

@@ -13,9 +13,7 @@ describe('Tests for Bring to front', () => {
app = startedApp; app = startedApp;
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`Unable to start application error: ${err}`); done.fail(new Error(`Unable to start application error: ${err}`));
expect(err).toBeNull();
done();
}); });
}); });
@@ -36,51 +34,55 @@ describe('Tests for Bring to front', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should minimize the app', () => { it('should minimize the app', (done) => {
return app.browserWindow.minimize().then(() => { return app.browserWindow.minimize().then(() => {
return app.browserWindow.isMinimized().then((isMinimized) => { return app.browserWindow.isMinimized().then((isMinimized) => {
expect(isMinimized).toBeTruthy(); expect(isMinimized).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in isMinimized with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in minimize with error: ${err}`));
}); });
}); });
it('should not be focused', () => { it('should not be focused', (done) => {
return app.browserWindow.isFocused().then((isFocused) => { return app.browserWindow.isFocused().then((isFocused) => {
expect(isFocused).toBeFalsy(); expect(isFocused).toBeFalsy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in isFocused with error: ${err}`));
}); });
}); });
it('should maximize browser window', () => { it('should maximize browser window', (done) => {
return app.browserWindow.restore().then(() => { return app.browserWindow.restore().then(() => {
return app.browserWindow.isMinimized().then((isMinimized) => { return app.browserWindow.isMinimized().then((isMinimized) => {
expect(isMinimized).toBeFalsy(); expect(isMinimized).toBeFalsy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in isMinimized with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in restore with error: ${err}`));
}); });
}); });
it('should be focused', () => { it('should be focused', (done) => {
return app.browserWindow.isFocused().then((isFocused) => { return app.browserWindow.isFocused().then((isFocused) => {
expect(isFocused).toBeTruthy(); expect(isFocused).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`bringToFront failed in isFocused with error: ${err}`));
}); });
}); });
}); });

View File

@@ -1,6 +1,5 @@
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const path = require('path'); const path = require('path');
const constants = require('./spectronConstants');
let app = new Application({}); let app = new Application({});
@@ -14,9 +13,7 @@ describe('Tests for clipboard', () => {
app = startedApp; app = startedApp;
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`Unable to start application error: ${err}`); done.fail(new Error(`Unable to start application error: ${err}`));
expect(err).toBeNull();
done();
}); });
}); });
@@ -37,10 +34,10 @@ describe('Tests for clipboard', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeFalsy(); done.fail(new Error(`clipboard failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeFalsy(); done.fail(new Error(`clipboard failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
@@ -75,4 +72,4 @@ describe('Tests for clipboard', () => {
}); });
}); });
}); });
}); });

View File

@@ -1,21 +1,18 @@
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const constants = require('./spectronConstants');
let app = new Application({}); let app = new Application({});
describe('Tests for Close', () => { describe('Tests for Close', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
return app.startApplication().then((startedApp) => { return app.startApplication().then((startedApp) => {
app = startedApp; app = startedApp;
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`Unable to start application error: ${err}`); done.fail(new Error(`Unable to start application error: ${err}`));
expect(err).toBeNull();
done();
}); });
}); });
@@ -38,26 +35,28 @@ describe('Tests for Close', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`close failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`close failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should check window count', () => { it('should check window count', (done) => {
return app.client.getWindowCount().then((count) => { return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`close failed in getWindowCount with error: ${err}`));
}); });
}); });
it('should check browser window visibility', () => { it('should check browser window visibility', (done) => {
return app.browserWindow.isVisible().then((isVisible) => { return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`close failed in isVisible with error: ${err}`));
}); });
}); });
@@ -69,4 +68,4 @@ describe('Tests for Close', () => {
expect(app.isRunning()).toBe(false); expect(app.isRunning()).toBe(false);
}); });
}); });

View File

@@ -1,35 +1,26 @@
const childProcess = require('child_process');
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const { isMac } = require('../../js/utils/misc'); const { isMac } = require('../../js/utils/misc');
const constants = require('./spectronConstants'); const robot = require('robotjs');
let robot;
let configPath; let configPath;
let app = new Application({}); let app = new Application({});
describe('Tests for Full screen', () => { describe('Tests for Full screen', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
childProcess.exec(`npm rebuild robotjs --target=${process.version} --build-from-source`, function () { return app.startApplication().then((startedApp) => {
robot = require('robotjs'); app = startedApp;
return app.startApplication().then((startedApp) => { getConfigPath().then((config) => {
app = startedApp; configPath = config;
getConfigPath().then((config) => {
configPath = config;
done();
}).catch((err) => {
console.error(`Unable to get user config path error: ${err}`);
expect(err).toBeNull();
done();
});
}).catch((err) => {
console.error(`Unable to start application error: ${err}`);
expect(err).toBeNull();
done(); done();
}).catch((err) => {
done.fail(new Error(`full-screen failed in getConfigPath with error: ${err}`));
}); });
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}); });
@@ -73,26 +64,28 @@ describe('Tests for Full screen', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`full-screen failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`full-screen failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should check window count', () => { it('should check window count', (done) => {
return app.client.getWindowCount().then((count) => { return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`full-screen failed in getWindowCount with error: ${err}`));
}); });
}); });
it('should check browser window visibility', () => { it('should check browser window visibility', (done) => {
return app.browserWindow.isVisible().then((isVisible) => { return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`full-screen failed in getWindowCount with error: ${err}`));
}); });
}); });
@@ -105,7 +98,7 @@ describe('Tests for Full screen', () => {
}); });
}); });
it('should set the app full screen and check whether it is in full screen', () => { it('should set the app full screen and check whether it is in full screen', (done) => {
if (isMac) { if (isMac) {
robot.setMouseDelay(100); robot.setMouseDelay(100);
robot.moveMouseSmooth(205, 10); robot.moveMouseSmooth(205, 10);
@@ -121,8 +114,9 @@ describe('Tests for Full screen', () => {
return app.browserWindow.isFullScreen().then((fullscreen) => { return app.browserWindow.isFullScreen().then((fullscreen) => {
expect(fullscreen).toBeTruthy(); expect(fullscreen).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`full-screen failed in isFullScreen with error: ${err}`));
}) })
} else { } else {
return app.browserWindow.getBounds().then((bounds) => { return app.browserWindow.getBounds().then((bounds) => {
@@ -136,10 +130,11 @@ describe('Tests for Full screen', () => {
return app.browserWindow.isFullScreen().then((fullscreen) => { return app.browserWindow.isFullScreen().then((fullscreen) => {
expect(fullscreen).toBeTruthy(); expect(fullscreen).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`full-screen failed in isFullScreen with error: ${err}`));
}) })
}); });
} }
}); });
}); });

View File

@@ -1,6 +1,7 @@
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const path = require('path'); const path = require('path');
const { buildNumber } = require('../../package'); const { buildNumber } = require('../../package');
const electronVersion = require('../../package').devDependencies.electron;
const bluebird = require('bluebird'); const bluebird = require('bluebird');
let app = new Application({}); let app = new Application({});
@@ -15,9 +16,7 @@ describe('Tests for getVersionInfo API', () => {
app = startedApp; app = startedApp;
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`Unable to start application error: ${err}`); done.fail(new Error(`Unable to start application error: ${err}`));
expect(err).toBeNull();
done();
}); });
}); });
@@ -38,10 +37,10 @@ describe('Tests for getVersionInfo API', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`getVersionInfo failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`getVersionInfo failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
@@ -63,9 +62,9 @@ describe('Tests for getVersionInfo API', () => {
}).then((values) => { }).then((values) => {
expect(values[ 0 ]).toBe('1.0.0'); expect(values[ 0 ]).toBe('1.0.0');
expect(values[ 1 ]).toBe('Electron'); expect(values[ 1 ]).toBe('Electron');
expect(values[ 2 ]).toBe('1.8.3'); expect(values[ 2 ]).toBe(electronVersion);
expect(values[ 3 ]).toBe(buildNumber); expect(values[ 3 ]).toBe(buildNumber);
done(); done();
}); });
}); });
}); });

View File

@@ -1,35 +1,26 @@
const childProcess = require('child_process');
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const { isMac } = require('../../js/utils/misc'); const { isMac } = require('../../js/utils/misc');
const constants = require('./spectronConstants'); const robot = require('robotjs');
let robot;
let configPath; let configPath;
let app = new Application({}); let app = new Application({});
describe('Tests for Minimize on Close', () => { describe('Tests for Minimize on Close', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
childProcess.exec(`npm rebuild robotjs --target=${process.version} --build-from-source`, function () { return app.startApplication().then((startedApp) => {
robot = require('robotjs'); app = startedApp;
return app.startApplication().then((startedApp) => { getConfigPath().then((config) => {
app = startedApp; configPath = config;
getConfigPath().then((config) => {
configPath = config;
done();
}).catch((err) => {
console.error(`Unable to get user config path error: ${err}`);
expect(err).toBeNull();
done();
});
}).catch((err) => {
console.error(`Unable to start application error: ${err}`);
expect(err).toBeNull();
done(); done();
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}); });
@@ -73,26 +64,28 @@ describe('Tests for Minimize on Close', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should check window count', () => { it('should check window count', (done) => {
return app.client.getWindowCount().then((count) => { return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in getWindowCount with error: ${err}`));
}); });
}); });
it('should check browser window visibility', () => { it('should check browser window visibility', (done) => {
return app.browserWindow.isVisible().then((isVisible) => { return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in isVisible with error: ${err}`));
}); });
}); });
@@ -117,8 +110,7 @@ describe('Tests for Minimize on Close', () => {
expect(minimized).toBeTruthy(); expect(minimized).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
done();
}); });
} else { } else {
@@ -141,8 +133,7 @@ describe('Tests for Minimize on Close', () => {
expect(minimized).toBeTruthy(); expect(minimized).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
done();
}); });
} }
} else { } else {
@@ -167,8 +158,7 @@ describe('Tests for Minimize on Close', () => {
expect(minimized).toBeTruthy(); expect(minimized).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
done();
}); });
}); });
} else { } else {
@@ -185,16 +175,14 @@ describe('Tests for Minimize on Close', () => {
expect(minimized).toBeTruthy(); expect(minimized).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
done();
}); });
}); });
} }
} }
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`minimize-on-close failed in readConfig with error: ${err}`));
done();
}) })
}); });
}); });

View File

@@ -1,7 +1,6 @@
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const path = require('path'); const path = require('path');
const { isMac } = require('../../js/utils/misc'); const { isMac } = require('../../js/utils/misc');
const constants = require('./spectronConstants');
let app = new Application({}); let app = new Application({});
@@ -15,9 +14,7 @@ describe('Tests for Notification position', () => {
app = startedApp; app = startedApp;
done(); done();
}).catch((err) => { }).catch((err) => {
console.error(`Unable to start application error: ${err}`); done.fail(new Error(`Unable to start application error: ${err}`));
expect(err).toBeNull();
done();
}); });
}); });
@@ -38,10 +35,10 @@ describe('Tests for Notification position', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
@@ -49,15 +46,16 @@ describe('Tests for Notification position', () => {
return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html')); return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html'));
}); });
it('should load demo html', () => { it('should load demo html', (done) => {
return app.client.waitUntilWindowLoaded().then(() => { return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getTitle().then((title) => { return app.client.getTitle().then((title) => {
expect(title === '').toBeTruthy(); expect(title === '').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
@@ -72,32 +70,35 @@ describe('Tests for Notification position', () => {
.windowByIndex(1) .windowByIndex(1)
}); });
it('should check notification position', () => { it('should check notification position', (done) => {
return app.browserWindow.getBounds().then((bounds) => { return app.browserWindow.getBounds().then((bounds) => {
expect(bounds.x === 0).toBeTruthy(); expect(bounds.x === 0).toBeTruthy();
if (isMac) { if (isMac) {
expect(bounds.y > 0).toBeTruthy(); expect(bounds.y > 0).toBeTruthy();
done();
} else { } else {
expect(bounds.y === 0).toBeTruthy(); expect(bounds.y === 0).toBeTruthy();
done();
} }
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getBounds with error: ${err}`));
}); });
}); });
it('should change the window', () => { it('should change the window', (done) => {
return app.client.windowByIndex(0).then(() => { return app.client.windowByIndex(0).then(() => {
return app.browserWindow.getTitle().then((title) => { return app.browserWindow.getTitle().then((title) => {
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy(); expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in windowByIndex with error: ${err}`));
}); });
}); });
it('should change notification position to lower-right', () => { it('should change notification position to lower-right', (done) => {
return app.client return app.client
.click('#open-config-win') .click('#open-config-win')
.windowByIndex(2) .windowByIndex(2)
@@ -108,36 +109,39 @@ describe('Tests for Notification position', () => {
.windowByIndex(1).then(() => { .windowByIndex(1).then(() => {
return app.browserWindow.getTitle().then((title) => { return app.browserWindow.getTitle().then((title) => {
expect(title === 'Electron').toBeTruthy(); expect(title === 'Electron').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in windowByIndex with error: ${err}`));
}); });
}); });
it('should check notification position and equal to lower-right', () => { it('should check notification position and equal to lower-right', (done) => {
return app.browserWindow.getBounds().then((bounds) => { return app.browserWindow.getBounds().then((bounds) => {
expect(bounds.x > 0).toBeTruthy(); expect(bounds.x > 0).toBeTruthy();
expect(bounds.y > 0).toBeTruthy(); expect(bounds.y > 0).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getBounds with error: ${err}`));
}); });
}); });
it('should change the window', () => { it('should change the window', (done) => {
return app.client.windowByIndex(0).then(() => { return app.client.windowByIndex(0).then(() => {
return app.browserWindow.getTitle().then((title) => { return app.browserWindow.getTitle().then((title) => {
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy(); expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in windowByIndex with error: ${err}`));
}); });
}); });
it('should change notification position to upper-right', () => { it('should change notification position to upper-right', (done) => {
return app.client return app.client
.click('#open-config-win') .click('#open-config-win')
.windowByIndex(2) .windowByIndex(2)
@@ -148,57 +152,63 @@ describe('Tests for Notification position', () => {
.windowByIndex(1).then(() => { .windowByIndex(1).then(() => {
return app.browserWindow.getTitle().then((title) => { return app.browserWindow.getTitle().then((title) => {
expect(title === 'Electron').toBeTruthy(); expect(title === 'Electron').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in windowByIndex with error: ${err}`));
}); });
}); });
it('should check notification position and equal to upper-right', () => { it('should check notification position and equal to upper-right', (done) => {
return app.browserWindow.getBounds().then((bounds) => { return app.browserWindow.getBounds().then((bounds) => {
expect(bounds.x > 0).toBeTruthy(); expect(bounds.x > 0).toBeTruthy();
if (isMac) { if (isMac) {
expect(bounds.y > 0).toBeTruthy(); expect(bounds.y > 0).toBeTruthy();
done();
} else { } else {
expect(bounds.y === 0).toBeTruthy(); expect(bounds.y === 0).toBeTruthy();
done();
} }
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getBounds with error: ${err}`));
}); });
}); });
it('should change the window to main', () => { it('should change the window to main', (done) => {
return app.client.windowByIndex(0).then(() => { return app.client.windowByIndex(0).then(() => {
return app.browserWindow.getTitle().then((title) => { return app.browserWindow.getTitle().then((title) => {
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy(); expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in windowByIndex with error: ${err}`));
}); });
}); });
it('should open notification and close', () => { it('should open notification and close', (done) => {
return app.client return app.client
.windowByIndex(0) .windowByIndex(0)
.click('#notf') .click('#notf')
.getWindowCount().then((count) => { .getWindowCount().then((count) => {
expect(count === 3).toBeTruthy(); expect(count === 3).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getWindowCount with error: ${err}`));
}) })
.windowByIndex(1).then(() => { .windowByIndex(1).then(() => {
return app.browserWindow.getTitle().then((title) => { return app.browserWindow.getTitle().then((title) => {
expect(title === 'Electron').toBeTruthy(); expect(title === 'Electron').toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`notificationPosition failed in windowByIndex with error: ${err}`));
}); });
}); });
}); });

View File

@@ -113,4 +113,4 @@ class App {
} }
module.exports = App; module.exports = App;

View File

@@ -1,11 +1,8 @@
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const path = require('path'); const path = require('path');
const {isMac} = require('../../js/utils/misc.js'); const {isMac} = require('../../js/utils/misc.js');
const childProcess = require('child_process'); const robot = require('robotjs');
const constants = require('./spectronConstants');
let app = new Application({}); let app = new Application({});
let robot;
describe('Tests for spellChecker', () => { describe('Tests for spellChecker', () => {
@@ -13,16 +10,11 @@ describe('Tests for spellChecker', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
childProcess.exec(`npm rebuild robotjs --target=${process.version} --build-from-source`, () => { app.startApplication().then((startedApp) => {
robot = require('robotjs'); app = startedApp;
app.startApplication().then((startedApp) => { done();
app = startedApp; }).catch((err) => {
done(); done.fail(new Error(`Unable to start application error: ${err}`));
}).catch((err) => {
console.error(`Unable to start application error: ${err}`);
expect(err).toBeNull();
done();
});
}); });
}); });
@@ -43,12 +35,10 @@ describe('Tests for spellChecker', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeFalsy(); done.fail(new Error(`spellChecker failed in getWindowCount with error: ${err}`));
done();
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeFalsy(); done.fail(new Error(`spellChecker failed in waitUntilWindowLoaded with error: ${err}`));
done();
}); });
}); });
@@ -122,4 +112,4 @@ describe('Tests for spellChecker', () => {
}); });
}); });
}); });

View File

@@ -1,9 +1,7 @@
const childProcess = require('child_process');
const Application = require('./spectronSetup'); const Application = require('./spectronSetup');
const { isMac } = require('../../js/utils/misc'); const { isMac } = require('../../js/utils/misc');
const constants = require('./spectronConstants'); const robot = require('robotjs');
let robot;
let configPath; let configPath;
let app = new Application({}); let app = new Application({});
@@ -11,26 +9,19 @@ let app = new Application({});
describe('Tests for Zoom in and Zoom out', () => { describe('Tests for Zoom in and Zoom out', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
childProcess.exec(`npm rebuild robotjs --target=${process.version} --build-from-source`, function () { return app.startApplication().then((startedApp) => {
robot = require('robotjs'); app = startedApp;
return app.startApplication().then((startedApp) => { getConfigPath().then((config) => {
app = startedApp; configPath = config;
getConfigPath().then((config) => {
configPath = config;
done();
}).catch((err) => {
console.error(`Unable to get user config path error: ${err}`);
expect(err).toBeNull();
done();
});
}).catch((err) => {
console.error(`Unable to start application error: ${err}`);
expect(err).toBeNull();
done(); done();
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
}); });
}); });
@@ -74,26 +65,28 @@ describe('Tests for Zoom in and Zoom out', () => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done(); done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`zoom-in-zoom-out failed in getWindowCount with error: ${err}`));
}); });
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`zoom-in-zoom-out failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should check window count', () => { it('should check window count', (done) => {
return app.client.getWindowCount().then((count) => { return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy(); expect(count === 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`zoom-in-zoom-out failed in waitUntilWindowLoaded with error: ${err}`));
}); });
}); });
it('should check browser window visibility', () => { it('should check browser window visibility', (done) => {
return app.browserWindow.isVisible().then((isVisible) => { return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy(); expect(isVisible).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`zoom-in-zoom-out failed in isVisible with error: ${err}`));
}); });
}); });
@@ -106,7 +99,7 @@ describe('Tests for Zoom in and Zoom out', () => {
}); });
}); });
it('should zoom in the app and check whether it is zoomed in', () => { it('should zoom in the app and check whether it is zoomed in', (done) => {
robot.setKeyboardDelay(500); robot.setKeyboardDelay(500);
if (isMac) { if (isMac) {
@@ -122,8 +115,9 @@ describe('Tests for Zoom in and Zoom out', () => {
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => { return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor > 1).toBeTruthy(); expect(zoomFactor > 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`zoom-in-zoom-out failed in getZoomFactor with error: ${err}`));
}) })
} else { } else {
return app.browserWindow.getBounds().then((bounds) => { return app.browserWindow.getBounds().then((bounds) => {
@@ -146,8 +140,9 @@ describe('Tests for Zoom in and Zoom out', () => {
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => { return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor > 1).toBeTruthy(); expect(zoomFactor > 1).toBeTruthy();
done();
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); done.fail(new Error(`zoom-in-zoom-out failed in getBounds with error: ${err}`));
}) })
}); });
} }
@@ -200,4 +195,4 @@ describe('Tests for Zoom in and Zoom out', () => {
}); });
} }
}); });
}); });