Fix to run all test on jenkins (#467)

* Fix issue

* fix run all test and is not hang on jenkin

* fix space

* remove npm run rebuild
This commit is contained in:
tranducanh
2018-08-16 13:24:46 +07:00
committed by Vishwas Shashidhar
parent 42335eb446
commit 66d1a9f8e7
10 changed files with 371 additions and 379 deletions

View File

@@ -13,7 +13,7 @@
"rebuild": "electron-rebuild -f",
"dev": "npm run prebuild && cross-env ELECTRON_DEV=true electron .",
"test": "npm run lint && npm rebuild --build-from-source && cross-env ELECTRON_QA=true jest --config tests/jest_unit.json --runInBand && npm run rebuild",
"spectron-test": "npm run lint && npm rebuild --build-from-source robotjs && cross-env ELECTRON_QA=true jest --config tests/spectron/jest_spectron.json --runInBand && npm run rebuild",
"spectron-test": "npm run lint && npm rebuild --build-from-source robotjs && cross-env ELECTRON_QA=true jest --config tests/spectron/jest_spectron.json --runInBand --detectOpenHandles",
"demo-win": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///demo/index.html",
"demo-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/index.html",
"unpacked-mac": "npm run prebuild && npm run test && build --mac --dir",
@@ -103,8 +103,8 @@
"eslint-plugin-jsx-a11y": "6.0.3",
"eslint-plugin-react": "7.10.0",
"glob": "7.1.2",
"jest": "19.0.2",
"jest-html-reporter": "2.4.1",
"jest": "23.5.0",
"jest-html-reporter": "2.4.2",
"ncp": "2.0.0",
"robotjs": "0.5.1",
"selenium-webdriver": "3.6.0",

View File

@@ -1,5 +1,7 @@
{
"testMatch": ["**/*.spectron.js"],
"verbose": true,
"testResultsProcessor": "./node_modules/jest-html-reporter"
}
"testMatch": [
"**/*.spectron.js"
],
"testResultsProcessor": "../../node_modules/jest-html-reporter"
}

View File

@@ -1,31 +1,29 @@
const Application = require('./spectronSetup');
const { isMac } = require('../../js/utils/misc');
const WindowsAction = require('./spectronWindowsActions');
const WebAction = require('./spectronWebActions');
var app = new Application({
startTimeout: Application.getTimeOut(),
waitTimeout: Application.getTimeOut()
});
let wActions;
let webActions;
const { isMac, isWindowsOS } = require('../../js/utils/misc');
const WindowsActions = require('./spectronWindowsActions');
const WebActions = require('./spectronWebActions');
const Utils = require('./spectronUtils');
let mainApp = new Application({});
let app, wActions, config;
!isMac ?describe('Add Test To Verify Minimize on Close', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
!isMac? describe('Add Test To Verify Minimize on Close', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll(async (done) => {
await app.startApplication().then(async(startedApp) => {
app.app = await startedApp;
wActions = await new WindowsAction(app.app);
webActions = await new WebAction(app.app);
}).then((async() =>{
await getConfigPath(app.app).then((config) => {
app.pathApp = config;
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
});
done();
}));
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
beforeAll(async (done) => {
try {
app = await mainApp.startApplication({ alwaysOnTop: false });
await Utils.sleep(2);
wActions = await new WindowsActions(app);
webActions = await new WebActions(app);
config = await getConfigPath(app);
await wActions.focusWindow();
await done();
} catch (err) {
done.fail(new Error(`Unable to start application error: ${err}`));
};
});
function getConfigPath(app) {
@@ -43,112 +41,103 @@ let webActions;
});
}
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();
afterAll(async (done) => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
try {
if (app && app.isRunning()) {
done();
wActions.closeChrome();
}
} catch (error) {
done.fail(new Error(`After all: ${error}`));
}
});
/**
* Verify Minimize on Close option once the application is installed
* TC-ID: 3084609
* Cover scenarios in AVT-939
*/
it('Verify Minimize on Close option once the application is installed', async(done) => {
await Application.readConfig(app.pathApp).then(async (userConfig) => {
//When app un-ticked on Minimize On Close Menu Item
//Select 1 times to perform for ticking Menu
await wActions.openMenu(["Window","Minimize on Close"]);
if (userConfig.minimizeOnClose != false) {
//When app ticked on Minimize On Close Menu Item
//Select 2 times to perform for ticking Menu
await wActions.openMenu(["Window","Minimize on Close"]);
}
await wActions.openMenu(["Window","Close"]);
await wActions.verifyMinimizeWindows();
done();
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in readConfig with error: ${err}`));
})
* Cover scenarios in AVT-939
*/
it('Verify Minimize on Close option once the application is installed', async (done) => {
if (isWindowsOS) {
try {
let userConfig = await Application.readConfig(config);
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose != false) {
await wActions.openMenu(["Window", "Minimize on Close"]);
}
await wActions.openMenu(["Window", "Close"]);
await wActions.verifyMinimizeWindows();
await done();
} catch (err) {
done.fail(new Error(`Verify Minimize on Close option once the application is installed: ${err}`));
};
}
else {
await done();
}
});
/**
* Close window when 'Minimize on Close' is ON
* TC-ID: 2911252
/**
* Close window when 'Minimize on Close' is ON
* TC-ID: 2911252
* Cover scenarios in AVT-937
*/
it('Close window when "Minimize on Close" is ON', async (done) => {
Application.readConfig(app.pathApp).then(async (userConfig) => {
//When app un-ticked on Minimize On Close Menu Item
//Select 1 times to perform for ticking Menu
if (isWindowsOS) {
try {
let userConfig = await Application.readConfig(config);
await wActions.focusWindow();
await wActions.openMenu(["Window","Minimize on Close"]);
if (userConfig.minimizeOnClose != false) {
await wActions.openMenu(["Window","Minimize on Close"]);
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose != false) {
await wActions.openMenu(["Window", "Minimize on Close"]);
}
//When app ticked on Minimize On Close Menu Item
//Select 2 times to perform for ticking Menu
await wActions.openMenu(["Window","Close"])
await wActions.openMenu(["Window", "Close"])
await wActions.verifyMinimizeWindows();
await wActions.focusWindow();
await wActions.bringToFront("");
await Utils.sleep(2);
await wActions.pressCtrlW();
await wActions.verifyMinimizeWindows();
await wActions.focusWindow();
await wActions.openMenu(["Window","Close"])
await wActions.verifyMinimizeWindows();
done();
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in readConfig with error: ${err}`));
})
await wActions.verifyMinimizeWindows();
await done()
} catch (err) {
done.fail(new Error(`Close window when "Minimize on Close" is ON: ${err}`));
};
}
else {
await done();
}
});
/**
* Verify by deselecting Minimize on Close option once the application is launched
* TC-ID: 3084612
* Cover scenarios in AVT-938
*/
/**
* Verify by deselecting Minimize on Close option once the application is launched
* TC-ID: 3084612
* Cover scenarios in AVT-938
*/
it('Verify by deselecting Minimize on Close option once the application is launched', async (done) => {
await Application.readConfig(app.pathApp).then(async (userConfig) => {
if (isWindowsOS) {
try {
let userConfig = await Application.readConfig(config);
await wActions.focusWindow();
await wActions.openMenu(["Window","Minimize on Close"]).then(async ()=>
{
if (userConfig.minimizeOnClose == false) {
//When app does not tick on Minimize On Close Menu Item
//Select 2 times to perform for un-ticking Menu
await wActions.openMenu(["Window","Minimize on Close"]);
}
await wActions.openMenu(["Window","Close"])
await wActions.verifyMinimizeWindows();
done();
});
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in readConfig with error: ${err}`));
})
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose == false) {
await wActions.openMenu(["Window", "Minimize on Close"]);
}
await wActions.openMenu(["Window", "Close"])
await Utils.sleep(5);
let status = await wActions.isElectronProcessRunning() ;
await console.log(status);
await expect(status === false).toBeTruthy();
await done();
} catch (err) {
done.fail(new Error(`Verify by deselecting Minimize on Close option once the application is launched: ${err}`));
};
}
else {
await done();
}
});
}) : describe.skip();

View File

@@ -1,27 +1,27 @@
const Application = require('./spectronSetup');
const { isMac } = require('../../js/utils/misc');
const robot = require('robotjs');
const WindowsActions = require('./spectronWindowsActions');
const Utils = require('./spectronUtils');
let configPath,wActions,app;
let mainApp = new Application({});
let configPath;
let app = new Application({});
describe('Tests for Minimize on Close', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
!isMac? describe('Tests for Minimize on Close', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
beforeAll((done) => {
return app.startApplication().then((startedApp) => {
app = startedApp;
getConfigPath().then((config) => {
configPath = config;
done();
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
});
}).catch((err) => {
beforeAll(async (done) => {
try {
app = await mainApp.startApplication({ alwaysOnTop: false });
await Utils.sleep(2);
wActions = await new WindowsActions(app);
configPath = await getConfigPath();
await wActions.focusWindow();
await done();
} catch (err) {
done.fail(new Error(`Unable to start application error: ${err}`));
});
};
});
function getConfigPath() {
@@ -39,22 +39,16 @@ describe('Tests for Minimize on Close', () => {
});
}
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();
afterAll(async (done) => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
try {
if (app && app.isRunning()) {
done();
wActions.closeChrome();
}
} catch (error) {
done.fail(new Error(`After all: ${error}`));
}
});
@@ -98,91 +92,23 @@ describe('Tests for Minimize on Close', () => {
});
});
it('should check whether the app is minimized', (done) => {
Application.readConfig(configPath).then((userConfig) => {
if (isMac) {
if (userConfig.minimizeOnClose) {
robot.setKeyboardDelay(100);
robot.keyToggle('w', 'down', ['command']);
robot.keyToggle('w', 'up');
robot.keyToggle('command', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
});
} else {
robot.setMouseDelay(100);
robot.moveMouseSmooth(200, 10);
robot.mouseClick();
robot.setKeyboardDelay(100);
// Key tap 8 times as "Minimize on Close" is in the
// 8th position under view menu item
for (let i = 0; i < 8; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');
robot.keyToggle('w', 'down', ['command']);
robot.keyToggle('w', 'up');
robot.keyToggle('command', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
});
}
} else {
if (!userConfig.minimizeOnClose) {
app.browserWindow.getBounds().then((bounds) => {
robot.setMouseDelay(100);
let x = bounds.x + 95;
let y = bounds.y + 35;
robot.moveMouse(x, y);
robot.mouseClick();
// Key tap 5 times as "Minimize on Close" is in the
// 5th position under Window menu item
for (let i = 0; i < 5; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');
robot.keyToggle('w', 'down', ['control']);
robot.keyToggle('w', 'up');
robot.keyToggle('control', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
});
});
} else {
app.browserWindow.getBounds().then((bounds) => {
robot.setMouseDelay(100);
let x = bounds.x + 200;
let y = bounds.y + 200;
robot.moveMouseSmooth(x, y);
robot.mouseClick();
robot.keyToggle('w', 'down', ['control']);
robot.keyToggle('w', 'up');
robot.keyToggle('control', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
});
});
}
it('should check whether the app is minimized', async(done) => {
try {
let userConfig = await Application.readConfig(configPath);
await wActions.focusWindow();
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose == false) {
await wActions.openMenu(["Window", "Minimize on Close"]);
}
}).catch((err) => {
done.fail(new Error(`minimize-on-close failed in readConfig with error: ${err}`));
})
await wActions.openMenu(["Window", "Close"])
await Utils.sleep(5);
let status = await wActions.isElectronProcessRunning() ;
await console.log(status);
await expect(status === false).toBeTruthy();
await done();
} catch (err) {
done.fail(new Error(`should check whether the app is minimized: ${err}`));
};
});
});
}) : describe.skip();

View File

@@ -3,19 +3,20 @@ const { isMac } = require('../../js/utils/misc');
const robot = require('robotjs');
const fs = require('fs');
const glob = require('glob');
const WindowsActions = require('./spectronWindowsActions');
let downloadsPath;
let downloadsPath, wActions;
let app = new Application({});
describe('Tests for Generating & Sharing Logs', () => {
!isMac? 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;
wActions = new WindowsActions(app);
getDownloadsPath().then((path) => {
downloadsPath = path;
done();
@@ -26,7 +27,7 @@ describe('Tests for Generating & Sharing Logs', () => {
done.fail(new Error(`Unable to start application error: ${err}`));
});
});
function getDownloadsPath() {
return new Promise(function (resolve, reject) {
app.client.addCommand('getDownloadsPath', function () {
@@ -41,7 +42,7 @@ describe('Tests for Generating & Sharing Logs', () => {
});
});
}
afterAll((done) => {
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
@@ -60,7 +61,7 @@ describe('Tests for Generating & Sharing Logs', () => {
done();
}
});
it('should launch the app', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getWindowCount().then((count) => {
@@ -73,7 +74,7 @@ describe('Tests for Generating & Sharing Logs', () => {
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();
@@ -82,7 +83,7 @@ describe('Tests for Generating & Sharing Logs', () => {
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();
@@ -91,7 +92,7 @@ describe('Tests for Generating & Sharing Logs', () => {
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(() => {
@@ -100,51 +101,36 @@ describe('Tests for Generating & Sharing Logs', () => {
});
});
});
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('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();
}
});
wActions.openMenu(["Window", "Minimize"]);
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();
}
});
});
}
});
});
});
}) : describe.skip();

View File

@@ -24,7 +24,7 @@ class App {
if (isWindowsOS) {
App.copyConfigPath(constants.ELECTRON_GLOBAL_CONFIG_PATH_WIN);
App.copyLibraries(constants.SEARCH_LIBRARY_PATH_WIN);
//App.copyLibraries(constants.SEARCH_LIBRARY_PATH_WIN);
}
this.app = new Application(this.options);
@@ -66,7 +66,7 @@ class App {
}
static getTimeOut() {
return 90000;
return 120000;
}
static readConfig(configPath) {

View File

@@ -2,6 +2,7 @@ const childProcess = require('child_process');
const path = require('path');
const fs = require('fs');
class Utils {
static async openAppInMaximize(appPath) {
await childProcess.exec('start /MAX ' + appPath);
@@ -39,6 +40,14 @@ class Utils {
}
return randomstring;
}
static execPromise(command) {
return new Promise(function(resolve, reject) {
childProcess.exec(command, (error, stdout, stderr) => {
resolve(stdout.trim());
});
});
}
}
module.exports = Utils;

View File

@@ -2,7 +2,9 @@ const robot = require('robotjs');
const constants = require('./spectronConstants.js');
const Utils = require('./spectronUtils.js');
const fs = require('fs');
const WebActions = require('./spectronWebActions.js')
const WebActions = require('./spectronWebActions.js');
const { isMac, isWindowsOS } = require('../../js/utils/misc');
const ui = require('./spectronInterfaces.js');
class WindowsActions {
constructor(app) {
@@ -17,6 +19,29 @@ class WindowsActions {
await this.app.browserWindow.setSize(width, height);
}
async closeWindows() {
try {
if (this.app) {
let isRunning = await this.app.isRunning();
await this.app.stop();
}
}
catch (error) {
console.log(error);
}
}
async isElectronProcessRunning() {
let ret = false;
if (isWindowsOS) {
let result = await Utils.execPromise("tasklist | find /i \"electron.exe\"");
if (result && result.indexOf('electron.exe') > -1) {
ret = true;
}
}
return ret;
}
async resizeWindows(width, height) {
await this.app.browserWindow.getBounds().then((bounds) => {
let x = bounds.x + (bounds.width - width);
@@ -139,14 +164,6 @@ class WindowsActions {
})
}
async verifyMinimizeWindows() {
await this.app.browserWindow.isMinimized().then(async function (minimized) {
await expect(minimized).toBeTruthy();
}).catch((err) => {
console.log(err.name);
});;
}
async isMinimizedWindows() {
let rminimized = -1;
@@ -182,6 +199,21 @@ class WindowsActions {
});
}
async menuSearch(element, namevalue) {
if (element.name == namevalue) {
return await element;
}
else if (element.items !== undefined) {
var result;
for (var i = 0; result == null && i < element.items.length; i++) {
result = await this.menuSearch(element.items[i], namevalue);
result;
}
return await result;
}
return await null;
}
async quitApp() {
let webAction = await new WebActions(this.app);
await this.app.browserWindow.getBounds().then(async (bounds) => {
@@ -210,11 +242,8 @@ class WindowsActions {
}
async verifyMinimizeWindows() {
await this.app.browserWindow.isMinimized().then(async function (minimized) {
await expect(minimized).toBeTruthy();
}).catch((err) => {
console.log("error:" + err.name);
});;
let isMinimized = await this.app.browserWindow.isMinimized();
await expect(isMinimized).toBeTruthy();
}
async isMinimizedWindows() {
@@ -246,7 +275,21 @@ class WindowsActions {
async focusWindow() {
this.app.browserWindow.focus();
this.app.browserWindow.setAlwaysOnTop(true);
}
async setAlwaysOnTop(value) {
this.app.browserWindow.setAlwaysOnTop(value);
}
async openMenu(arrMenu) {
var arrStep = [];
for (var i = 0; i < arrMenu.length; i++) {
var item = await this.menuSearch(constants.MENU.root, arrMenu[i]);
await arrStep.push(item);
}
await this.actionForMenus(arrStep);
return arrStep;
}
async reload() {
@@ -266,48 +309,43 @@ class WindowsActions {
});
}
async clickNotification() {
let screen = await this.app.electron.screen.getAllDisplays();
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(50);
let x = screen[0].bounds.width - 50;
let y = screen[0].bounds.height - 100;
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
await robot.mouseClick();
});
async clickNotification(x,y) {
await robot.setMouseDelay(100);
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
await robot.mouseClick();
}
async mouseMoveNotification() {
let screen = await this.app.electron.screen.getAllDisplays();
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(50);
let x = screen[0].bounds.width - 50;
let y = screen[0].bounds.height - 100;
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
});
async mouseMoveNotification(x,y) {
await robot.setMouseDelay(50);
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
}
async mouseMoveCenter() {
let screen = await this.app.electron.screen.getAllDisplays();
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(50);
let x = screen[0].bounds.width - 500;
let y = screen[0].bounds.height - 100;
let x = screen[0].bounds.width/2;
let y = screen[0].bounds.height/2;
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
});
}
async veriryPersistToastNotification(message) {
let i = 0;
while (i < 6) {
var i = 0;
while (i < 7) {
await Utils.sleep(1);
await i++;
}
let currentPosition = await this.getToastNotificationPosition(message);
let curentSize = await this.getToastNotificationSize(message);
await this.webAction.verifyToastNotificationShow(message);
await this.clickNotification();
let x = await (currentPosition[0] + curentSize[0]/2);
let y = await (currentPosition[1] + curentSize[1]/2);
await this.clickNotification(x,y);
await this.mouseMoveCenter();
}
@@ -324,44 +362,27 @@ class WindowsActions {
}
async verifyNotCloseToastWhenMouseOver(message) {
await this.mouseMoveNotification();
let i = 0;
while (i < 8) {
var i = 0;
while (i < 6) {
await Utils.sleep(1);
await i++;
}
let currentPosition = await this.getToastNotificationPosition(message);
let curentSize = await this.getToastNotificationSize(message);
let x = await (currentPosition[0] + curentSize[0]/2);
let y = await (currentPosition[1] + curentSize[1]/2);
await this.mouseMoveNotification(x,y);
await this.webAction.verifyToastNotificationShow(message);
await this.mouseMoveCenter();
}
async getBadgeCount() {
let count = await this.app.electron.remote.app.getBadgeCount();
return count;
async windowByIndex(index) {
await this.app.client.windowByIndex(index);
}
async resetBadgeCount() {
await this.app.electron.remote.app.setBadgeCount(0);
}
async getBadgeCount() {
let count = await this.app.electron.remote.app.getBadgeCount();
return count;
}
async verifyCurrentBadgeCount(number) {
let expected = false;
let i = 0;
let count = await this.getBadgeCount();
while (i < 5) {
if (count == number) {
expected = true;
break;
}
await Utils.sleep(1);
count = await this.getBadgeCount();
await i++;
}
await expect(expected).toBeTruthy();
async getWindowCount() {
return await this.app.client.getWindowCount();
}
async getWindowIndexFromTitle(windowTitle) {
@@ -390,20 +411,81 @@ class WindowsActions {
return 0;
}
async windowByIndex(index) {
await this.app.client.windowByIndex(index);
}
async getWindowCount() {
return await this.app.client.getWindowCount();
}
async bringToFront(windowTitle) {
let index = await this.getWindowIndexFromTitle(windowTitle);
await this.windowByIndex(index);
await this.app.browserWindow.minimize();
await this.app.browserWindow.restore();
}
async closeChrome()
{
Utils.killProcess("chromedriver.exe");
}
async getToastNotificationIndex(message) {
for (let i = 0; i < 10; i++) {
let winCount = await this.app.client.getWindowCount();
if (winCount > 1) {
for (let j = 1; j < winCount; j++) {
await this.app.client.windowByIndex(j);
if (await this.app.client.getText(ui.TOAST_MESSAGE_CONTENT) === message) {
return j;
}
}
}
await Utils.sleep(1);
}
return 0;
}
async getToastNotificationPosition(message) {
let index = await this.getToastNotificationIndex(message);
await this.windowByIndex(index);
let currentPosition = await this.getCurrentPosition();
await this.windowByIndex(0);
return currentPosition;
}
async getToastNotificationSize(message) {
let index = await this.getToastNotificationIndex(message);
await this.windowByIndex(index);
let currentSize = await this.getCurrentSize();
await this.windowByIndex(0);
return currentSize;
}
async verifyToastNotificationPosition(message, expectedPosition) {
let screen = await this.app.electron.screen.getPrimaryDisplay();
let screenWidth = screen.size.width;
let screenHeight = screen.size.height;
let currentPosition = await this.getToastNotificationPosition(message);
let curentSize = await this.getToastNotificationSize(message);
switch (expectedPosition) {
case "lower-right":
expect(currentPosition[0] + curentSize[0]).toEqual(screenWidth);
expect(screenHeight - (currentPosition[1] + curentSize[1])).toBeLessThan(100);
break;
case "upper-right":
expect(currentPosition[0] + curentSize[0]).toEqual(screenWidth);
expect(currentPosition[1]).toEqual(0);
break;
case "upper-left":
expect(currentPosition[0]).toEqual(0);
expect(currentPosition[1]).toEqual(0);
break;
case "lower-left":
expect(currentPosition[0]).toEqual(0);
expect(screenHeight - (currentPosition[1] + curentSize[1])).toBeLessThan(100);
break;
}
await this.windowByIndex(0);
return 0;
}
async getWindowCount() {
return await this.app.client.getWindowCount();
}
async verifyWindowFocus(windowTitle) {
let index = await this.getWindowIndexFromTitle(windowTitle);

View File

@@ -8,11 +8,14 @@ const ui = require('./spectronInterfaces.js');
const Utils = require('./spectronUtils');
let app, webDriver, webActions, windowsActions;
app = new Application({
startTimeout: Application.getTimeOut(),
waitTimeout: Application.getTimeOut()
});
describe('Tests for Toast Notification ', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = constants.TIMEOUT_PAGE_LOAD;
beforeAll(async (done) => {
try {

View File

@@ -2,10 +2,7 @@ const Application = require('./spectronSetup');
const WebDriver = require('./spectronWebDriver');
const { isMac } = require('../../js/utils/misc.js');
const Utils = require('./spectronUtils');
var app = new Application({
startTimeout: Application.getTimeOut(),
waitTimeout: Application.getTimeOut()
});
var app = new Application({});
var webdriver = new WebDriver({ browser: 'chrome' });
const WindowsAction = require('./spectronWindowsActions');
const WebActions = require('./spectronWebActions');
@@ -14,9 +11,7 @@ const specconst = require('./spectronConstants.js');
let webActions, windowAction;
!isMac ? describe('Verify toast notification when Persist Notification is ON', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = specconst.TIMEOUT_TEST_SUITE;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000;
beforeAll(async(done) => {
try
{