mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron 380: add share logs support (#333)
- add capabilities to generate log files - change the location of share logs menu item - add spectron tests - add menu item text for windows - fix issue reported on windows archiving other files - fix failing spectron tests - pin archiver dependency version
This commit is contained in:
committed by
GitHub
parent
1d1b90d2ae
commit
2e25c97bec
@@ -138,9 +138,9 @@ describe('Tests for Always on top', () => {
|
||||
robot.setMouseDelay(200);
|
||||
robot.moveMouse(190, 0);
|
||||
robot.mouseClick();
|
||||
// Key tap 9 times as "Always on Top" is in the
|
||||
// 9th position under view menu item
|
||||
for (let i = 0; i < 9; i++) {
|
||||
// Key tap 8 times as "Always on Top" is in the
|
||||
// 8th position under view menu item
|
||||
for (let i = 0; i < 8; i++) {
|
||||
robot.keyTap('down');
|
||||
}
|
||||
robot.keyTap('enter');
|
||||
|
||||
@@ -105,9 +105,9 @@ describe('Tests for Full screen', () => {
|
||||
robot.mouseClick();
|
||||
robot.setKeyboardDelay(100);
|
||||
|
||||
// Key tap 7 times as "Enter Full Screen" is in the
|
||||
// 7th position under view menu item
|
||||
for (let i = 0; i < 7; i++) {
|
||||
// Key tap 6 times as "Enter Full Screen" is in the
|
||||
// 6th position under view menu item
|
||||
for (let i = 0; i < 6; i++) {
|
||||
robot.keyTap('down');
|
||||
}
|
||||
robot.keyTap('enter');
|
||||
|
||||
@@ -119,9 +119,9 @@ describe('Tests for Minimize on Close', () => {
|
||||
robot.mouseClick();
|
||||
robot.setKeyboardDelay(100);
|
||||
|
||||
// Key tap 10 times as "Minimize on Close" is in the
|
||||
// 10th position under view menu item
|
||||
for (let i = 0; i < 10; i++) {
|
||||
// Key tap 9 times as "Minimize on Close" is in the
|
||||
// 9th position under view menu item
|
||||
for (let i = 0; i < 9; i++) {
|
||||
robot.keyTap('down');
|
||||
}
|
||||
robot.keyTap('enter');
|
||||
|
||||
149
tests/spectron/share-logs.spectron.js
Normal file
149
tests/spectron/share-logs.spectron.js
Normal file
@@ -0,0 +1,149 @@
|
||||
const Application = require('./spectronSetup');
|
||||
const { isMac } = require('../../js/utils/misc');
|
||||
const robot = require('robotjs');
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
|
||||
let downloadsPath;
|
||||
|
||||
let app = new Application({});
|
||||
|
||||
describe('Tests for Generating & Sharing Logs', () => {
|
||||
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
|
||||
beforeAll((done) => {
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
getDownloadsPath().then((path) => {
|
||||
downloadsPath = path;
|
||||
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}`));
|
||||
});
|
||||
});
|
||||
|
||||
function getDownloadsPath() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
app.client.addCommand('getDownloadsPath', function () {
|
||||
return this.execute(function () {
|
||||
return require('electron').remote.app.getPath('downloads');
|
||||
})
|
||||
});
|
||||
app.client.getDownloadsPath().then((downloadsPath) => {
|
||||
resolve(downloadsPath.value)
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
afterAll((done) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
app.client.getWindowCount().then((count) => {
|
||||
if (count > 0) {
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should launch the app', (done) => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(new Error(`share-logs failed in getWindowCount with error: ${err}`));
|
||||
});
|
||||
}).catch((err) => {
|
||||
done.fail(new Error(`share-logs failed in waitUntilWindowLoaded with error: ${err}`));
|
||||
});
|
||||
});
|
||||
|
||||
it('should check window count', (done) => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(new Error(`share-logs failed in waitUntilWindowLoaded with error: ${err}`));
|
||||
});
|
||||
});
|
||||
|
||||
it('should check browser window visibility', (done) => {
|
||||
return app.browserWindow.isVisible().then((isVisible) => {
|
||||
expect(isVisible).toBeTruthy();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done.fail(new Error(`share-logs failed in isVisible with error: ${err}`));
|
||||
});
|
||||
});
|
||||
|
||||
it('should bring the app to top', () => {
|
||||
app.browserWindow.focus();
|
||||
return app.browserWindow.setAlwaysOnTop(true).then(() => {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isOnTop) => {
|
||||
expect(isOnTop).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate logs', (done) => {
|
||||
robot.setKeyboardDelay(500);
|
||||
if (isMac) {
|
||||
|
||||
const x = 305;
|
||||
const y = 8;
|
||||
robot.moveMouseSmooth(x, y);
|
||||
robot.mouseClick();
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('right');
|
||||
robot.keyTap('enter');
|
||||
|
||||
console.log(downloadsPath);
|
||||
|
||||
glob(downloadsPath + '/logs_symphony*.zip', function (err, files) {
|
||||
|
||||
if (err || files.length < 1) {
|
||||
return done.fail(new Error(`log was not generated / file doesn't exist`));
|
||||
}
|
||||
|
||||
let i = files.length;
|
||||
|
||||
files.forEach(function (file) {
|
||||
|
||||
fs.unlink(file, function (err) {
|
||||
|
||||
i--;
|
||||
|
||||
if (err) {
|
||||
console.log('unable to delete file -> ' + file);
|
||||
}
|
||||
|
||||
if (i <=0 ) {
|
||||
return done();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user