mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-20 11:48:30 -06:00
Merge pull request #154 from KiranNiranjan/spectron-refactor
Refactored spectron tests
This commit is contained in:
commit
7e506910f0
@ -15,8 +15,9 @@
|
||||
"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",
|
||||
"rebuild": "electron-rebuild -f",
|
||||
"test": "npm run lint && jest --verbose --testPathPattern test",
|
||||
"test": "npm run lint && npm run copy-config && jest --verbose --testPathPattern test --runInBand",
|
||||
"lint": "eslint --ext .js js/",
|
||||
"copy-config": "ncp 'config' 'node_modules/electron/dist/Electron.app/Contents/config'",
|
||||
"rename-exe": "cd dist/win-unpacked && ren Symphony.exe Symphony-Electron.exe"
|
||||
},
|
||||
"jest": {
|
||||
@ -79,6 +80,7 @@
|
||||
"eslint-plugin-jsx-a11y": "^4.0.0",
|
||||
"eslint-plugin-react": "^6.10.0",
|
||||
"jest": "^19.0.2",
|
||||
"ncp": "^2.0.0",
|
||||
"spectron": "^3.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,56 +1,79 @@
|
||||
const Application = require('./spectronSetup');
|
||||
const path = require('path');
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
let app = new Application({});
|
||||
|
||||
describe('Tests for Always on top', () => {
|
||||
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
|
||||
let app;
|
||||
|
||||
beforeAll(() => {
|
||||
app = new Application({});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
return app.stop();
|
||||
}
|
||||
});
|
||||
|
||||
it('should launch the app', () => {
|
||||
beforeAll((done) => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
return app.client.waitUntilWindowLoaded().then(async () => {
|
||||
const count = await app.client.getWindowCount();
|
||||
expect(count === 1).toBeTruthy();
|
||||
})
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check window count', async () => {
|
||||
const count = await app.client.getWindowCount();
|
||||
expect(count === 1).toBeTruthy();
|
||||
afterAll((done) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should check browser window visibility', async () => {
|
||||
const isVisible = await app.browserWindow.isVisible();
|
||||
expect(isVisible).toBeTruthy();
|
||||
it('should launch the app', (done) => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check window count', () => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check browser window visibility', () => {
|
||||
return app.browserWindow.isVisible().then((isVisible) => {
|
||||
expect(isVisible).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check is always on top', async () => {
|
||||
const isAlwaysOnTop = await app.browserWindow.isAlwaysOnTop();
|
||||
expect(isAlwaysOnTop).toBeFalsy();
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
expect(isAlwaysOnTop).toBeFalsy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should change the always on top property', () => {
|
||||
return app.browserWindow.setAlwaysOnTop(true);
|
||||
});
|
||||
|
||||
it('should check is always on top to be true', async () => {
|
||||
const isAlwaysOnTop = await app.browserWindow.isAlwaysOnTop();
|
||||
expect(isAlwaysOnTop).toBeTruthy();
|
||||
it('should check is always on top to be true', () => {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
expect(isAlwaysOnTop).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -1,56 +1,82 @@
|
||||
const Application = require('./spectronSetup');
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
let app = new Application({});
|
||||
|
||||
describe('Tests for Bring to front', () => {
|
||||
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
|
||||
let app;
|
||||
|
||||
beforeAll(() => {
|
||||
app = new Application({});
|
||||
beforeAll((done) => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterAll((done) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
return app.stop();
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should launch the app', () => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
return app.client.waitUntilWindowLoaded().then(async () => {
|
||||
const count = await app.client.getWindowCount();
|
||||
it('should launch the app', (done) => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
})
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should minimize the app', () => {
|
||||
return app.browserWindow.minimize().then(async () => {
|
||||
const isMinimized = await app.browserWindow.isMinimized();
|
||||
expect(isMinimized).toBeTruthy();
|
||||
})
|
||||
return app.browserWindow.minimize().then(() => {
|
||||
return app.browserWindow.isMinimized().then((isMinimized) => {
|
||||
expect(isMinimized).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be focused', () => {
|
||||
return app.browserWindow.isFocused().then((isFocused) => {
|
||||
expect(isFocused).toBeFalsy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should maximize browser window', () => {
|
||||
return app.browserWindow.restore().then(async () => {
|
||||
const isMinimized = await app.browserWindow.isMinimized();
|
||||
expect(isMinimized).toBeFalsy();
|
||||
return app.browserWindow.isMinimized().then((isMinimized) => {
|
||||
expect(isMinimized).toBeFalsy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be focused', () => {
|
||||
return app.browserWindow.isFocused().then((isFocused) => {
|
||||
expect(isFocused).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,36 +1,46 @@
|
||||
const Application = require('./spectronSetup');
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
const path = require('path');
|
||||
let app = new Application({});
|
||||
|
||||
describe('Tests for clipboard', () => {
|
||||
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
|
||||
let app;
|
||||
|
||||
beforeAll(() => {
|
||||
app = new Application({});
|
||||
beforeAll((done) => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterAll((done) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
return app.stop();
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should launch the app', () => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
return app.client.waitUntilWindowLoaded().then(async () => {
|
||||
const count = await app.client.getWindowCount();
|
||||
it('should launch the app', (done) => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
})
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeFalsy();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check window count', () => {
|
||||
return app.client.url('file:///' + path.join(__dirname, '..', 'demo/index.html'))
|
||||
return app.client.url('file:///' + path.join(__dirname, '..', 'demo/index.html'));
|
||||
});
|
||||
|
||||
it('should set the username field', () => {
|
||||
@ -45,16 +55,16 @@ describe('Tests for clipboard', () => {
|
||||
it('should verify electron clipboard', () => {
|
||||
return app.client
|
||||
.getValue('#tag').then((value) => {
|
||||
app.electron.clipboard.writeText(value)
|
||||
.electron.clipboard.readText().then(function (clipboardText) {
|
||||
expect(clipboardText === 'Test').toBeTruthy();
|
||||
});
|
||||
return app.electron.clipboard.writeText(value)
|
||||
.electron.clipboard.readText().then((clipboardText) => {
|
||||
expect(clipboardText === 'Test').toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should verify electron clipboard copy', () => {
|
||||
return app.electron.clipboard.writeText('Testing copy')
|
||||
.electron.clipboard.readText().then(function (clipboardText) {
|
||||
.electron.clipboard.readText().then((clipboardText) => {
|
||||
return app.client.setValue('#tag', clipboardText).getValue('#tag').then((value) => {
|
||||
expect(value === 'Testing copy').toBeTruthy();
|
||||
});
|
||||
|
@ -1,31 +1,43 @@
|
||||
const Application = require('./spectronSetup');
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
const path = require('path');
|
||||
let app = new Application({});
|
||||
|
||||
describe('Tests for Notification position', () => {
|
||||
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
|
||||
let app;
|
||||
|
||||
beforeAll(() => {
|
||||
app = new Application({});
|
||||
beforeAll((done) => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterAll((done) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
return app.stop();
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should launch the app', () => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
return app.client.waitUntilWindowLoaded().then(async () => {
|
||||
const count = await app.client.getWindowCount();
|
||||
it('should launch the app', (done) => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
})
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@ -39,10 +51,15 @@ describe('Tests for Notification position', () => {
|
||||
return app.client.url(filePath);
|
||||
});
|
||||
|
||||
it('should load demo html', async () => {
|
||||
return app.client.waitUntilWindowLoaded().then(async () => {
|
||||
const title = await app.client.getTitle();
|
||||
expect(title === '').toBeTruthy();
|
||||
it('should load demo html', () => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
return app.client.getTitle().then((title) => {
|
||||
expect(title === '').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@ -57,16 +74,24 @@ describe('Tests for Notification position', () => {
|
||||
.windowByIndex(1)
|
||||
});
|
||||
|
||||
it('should check notification position', async () => {
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
expect(bounds.x === 0).toBeTruthy();
|
||||
expect(bounds.y > 0).toBeTruthy();
|
||||
it('should check notification position', () => {
|
||||
return app.browserWindow.getBounds().then((bounds) => {
|
||||
expect(bounds.x === 0).toBeTruthy();
|
||||
expect(bounds.y > 0).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should change the window', () => {
|
||||
return app.client.windowByIndex(0).then(async () => {
|
||||
const title = await app.browserWindow.getTitle();
|
||||
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
|
||||
return app.client.windowByIndex(0).then(() => {
|
||||
return app.browserWindow.getTitle().then((title) => {
|
||||
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@ -78,24 +103,36 @@ describe('Tests for Notification position', () => {
|
||||
.click('#ok-button')
|
||||
.windowByIndex(0)
|
||||
.click('#notf')
|
||||
.windowByIndex(1).then(async () => {
|
||||
const title = await app.browserWindow.getTitle();
|
||||
expect(title === 'Electron').toBeTruthy();
|
||||
.windowByIndex(1).then(() => {
|
||||
return app.browserWindow.getTitle().then((title) => {
|
||||
expect(title === 'Electron').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check notification position and equal to lower-right', async () => {
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
expect(bounds.x > 0).toBeTruthy();
|
||||
expect(bounds.y > 0).toBeTruthy();
|
||||
it('should check notification position and equal to lower-right', () => {
|
||||
return app.browserWindow.getBounds().then((bounds) => {
|
||||
expect(bounds.x > 0).toBeTruthy();
|
||||
expect(bounds.y > 0).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should change the window', () => {
|
||||
return app.client
|
||||
.windowByIndex(0).then(async () => {
|
||||
const title = await app.browserWindow.getTitle();
|
||||
return app.client.windowByIndex(0).then(() => {
|
||||
return app.browserWindow.getTitle().then((title) => {
|
||||
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should change notification position to upper-right', () => {
|
||||
@ -106,24 +143,36 @@ describe('Tests for Notification position', () => {
|
||||
.click('#ok-button')
|
||||
.windowByIndex(0)
|
||||
.click('#notf')
|
||||
.windowByIndex(1).then(async () => {
|
||||
const title = await app.browserWindow.getTitle();
|
||||
expect(title === 'Electron').toBeTruthy();
|
||||
.windowByIndex(1).then(() => {
|
||||
return app.browserWindow.getTitle().then((title) => {
|
||||
expect(title === 'Electron').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check notification position and equal to upper-right', async () => {
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
expect(bounds.x > 0).toBeTruthy();
|
||||
expect(bounds.y > 0).toBeTruthy();
|
||||
it('should check notification position and equal to upper-right', () => {
|
||||
return app.browserWindow.getBounds().then((bounds) => {
|
||||
expect(bounds.x > 0).toBeTruthy();
|
||||
expect(bounds.y > 0).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should change the window to main', () => {
|
||||
return app.client
|
||||
.windowByIndex(0).then(async () => {
|
||||
const title = await app.browserWindow.getTitle();
|
||||
return app.client.windowByIndex(0).then(() => {
|
||||
return app.browserWindow.getTitle().then((title) => {
|
||||
expect(title === 'Symphony | Secure Seamless Communication').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should open notification and close', () => {
|
||||
@ -132,11 +181,17 @@ describe('Tests for Notification position', () => {
|
||||
.click('#notf')
|
||||
.getWindowCount().then((count) => {
|
||||
expect(count === 3).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
})
|
||||
.windowByIndex(1).then(() => {
|
||||
return app.browserWindow.getTitle().then((title) => {
|
||||
expect(title === 'Electron').toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -7,28 +7,34 @@ class App {
|
||||
|
||||
this.options = options;
|
||||
|
||||
if (!this.options.path){
|
||||
if (!this.options.path) {
|
||||
this.options.path = App.getAppPath();
|
||||
this.options.args = [path.join(__dirname, '..', 'js/main.js')];
|
||||
this.options.args = [path.join(__dirname, '..', '..', 'js/main.js')];
|
||||
}
|
||||
|
||||
this.app = new Application(this.options);
|
||||
}
|
||||
|
||||
startApplication() {
|
||||
return this.app.start().then(() => {
|
||||
return this.app
|
||||
return this.app.start().then((app) => {
|
||||
return app;
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
static getAppPath() {
|
||||
let electronPath = path.join(__dirname, '..', 'node_modules', '.bin', 'electron');
|
||||
let electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', 'electron');
|
||||
if (process.platform === 'win32') {
|
||||
electronPath += '.cmd';
|
||||
}
|
||||
return electronPath
|
||||
}
|
||||
|
||||
static getTimeOut() {
|
||||
return 90000
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = App;
|
Loading…
Reference in New Issue
Block a user