mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
[AVT-1095] - [Spectron][MAC] Show 1 in tray icon when unread message = 1 (#458)
- Support new test on MAC - Support Badge Count test on MAC - Use let instead of var
This commit is contained in:
committed by
Vishwas Shashidhar
parent
d92a123f32
commit
a0968d1752
69
tests/spectron/badgeCount.spectron.js
Normal file
69
tests/spectron/badgeCount.spectron.js
Normal file
@@ -0,0 +1,69 @@
|
||||
const Application = require('./spectronSetup');
|
||||
const WebDriver = require('./spectronWebDriver');
|
||||
const { isMac } = require('../../js/utils/misc.js');
|
||||
const Utils = require('./spectronUtils');
|
||||
let app = new Application({
|
||||
startTimeout: Application.getTimeOut(),
|
||||
waitTimeout: Application.getTimeOut()
|
||||
});
|
||||
let webdriver = new WebDriver({ browser: 'chrome' });
|
||||
const WindowsAction = require('./spectronWindowsActions');
|
||||
const WebActions = require('./spectronWebActions');
|
||||
const specconst = require('./spectronConstants.js');
|
||||
|
||||
let webActions, windowAction;
|
||||
|
||||
describe('Test for Badge Count on MAC', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
beforeAll(async (done) => {
|
||||
try {
|
||||
app = await new Application({}).startApplication({ testedHost: specconst.TESTED_HOST, alwaysOnTop: true });
|
||||
windowAction = await new WindowsAction(app);
|
||||
webActions = await new WebActions(app);
|
||||
done();
|
||||
} catch (err) {
|
||||
done.fail(new Error(`Unable to start application error: ${err}`));
|
||||
};
|
||||
});
|
||||
afterAll(async (done) => {
|
||||
try {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
await app.stop();
|
||||
await webdriver.quit();
|
||||
done();
|
||||
}
|
||||
} catch (err) {
|
||||
done.fail(new Error(`Failed at post-condition: ${err}`));
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Show 1 in tray icon when unread message = 1
|
||||
* TC-ID: 2906586
|
||||
* Cover scenarios in AVT-1095
|
||||
*/
|
||||
it('Show 1 in tray icon when unread message = 1', async (done) => {
|
||||
try {
|
||||
if (isMac) {
|
||||
let message = await Utils.randomString();
|
||||
await webdriver.startDriver();
|
||||
await webdriver.login(specconst.USER_A);
|
||||
await webdriver.createIM(specconst.USER_B.username);
|
||||
await webActions.login(specconst.USER_B);
|
||||
await webActions.clickLeftNavItem(specconst.USER_A.name);
|
||||
await webActions.openAlertsSettings();
|
||||
let currentBadgeCount = await windowAction.getBadgeCount();
|
||||
await webdriver.sendMessage(message);
|
||||
await windowAction.verifyCurrentBadgeCount(currentBadgeCount + 1);
|
||||
done();
|
||||
}
|
||||
else {
|
||||
done();
|
||||
}
|
||||
} catch (err) {
|
||||
done.fail(new Error(`Show 1 in tray icon with error: ${err}`));
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
@@ -18,7 +18,7 @@ class WebActions {
|
||||
})
|
||||
}
|
||||
|
||||
async clickMinimizeButton(){
|
||||
async clickMinimizeButton() {
|
||||
await this.app.client.waitForVisible(ui.MINIMIZE_BTN, 10000).click(ui.MINIMIZE_BTN);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ class WebActions {
|
||||
}
|
||||
|
||||
async getElementByXPath(xpath) {
|
||||
await this.app.client.waitForVisible(xpath, constants.TIMEOUT_WAIT_ELEMENT);
|
||||
var elem = this.app.client.element(xpath);
|
||||
if (elem.isVisible()) {
|
||||
return elem;
|
||||
@@ -110,7 +111,7 @@ class WebActions {
|
||||
async openAlertsSettings() {
|
||||
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION);
|
||||
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB);
|
||||
}
|
||||
}
|
||||
|
||||
async verifyToastNotificationShow(message) {
|
||||
let show = false;
|
||||
@@ -118,12 +119,12 @@ class WebActions {
|
||||
var winCount = await this.app.client.getWindowCount();
|
||||
if (winCount > 1) {
|
||||
for (let j = 1; j < winCount; j++) {
|
||||
await this.app.client.windowByIndex(j);
|
||||
await this.app.client.windowByIndex(j);
|
||||
if (await this.app.client.getText(ui.TOAST_MESSAGE_CONTENT) === message) {
|
||||
show = true;
|
||||
}
|
||||
}
|
||||
if (show){
|
||||
if (show) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +140,7 @@ class WebActions {
|
||||
var winCount = await this.app.client.getWindowCount();
|
||||
if (winCount > 1) {
|
||||
for (let j = 1; j < winCount; j++) {
|
||||
await this.app.client.windowByIndex(j);
|
||||
await this.app.client.windowByIndex(j);
|
||||
if (await this.app.client.getText(ui.TOAST_MESSAGE_CONTENT) !== message) {
|
||||
noShow = true;
|
||||
}
|
||||
@@ -147,7 +148,7 @@ class WebActions {
|
||||
noShow = false;
|
||||
}
|
||||
}
|
||||
if (noShow === false){
|
||||
if (noShow === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -158,27 +159,24 @@ class WebActions {
|
||||
}
|
||||
|
||||
async getElementByXPath(xpath) {
|
||||
var elem = this.app.client.element(xpath);
|
||||
let elem = this.app.client.element(xpath);
|
||||
if (elem.isVisible()) {
|
||||
return elem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
async inputText(el, data) {
|
||||
var obj = await this.getElementByXPath(el);
|
||||
let obj = await this.getElementByXPath(el);
|
||||
if (obj != null)
|
||||
await this.app.client.setValue(el, data);
|
||||
}
|
||||
|
||||
async clickAndWaitElementVisible(xpath,elementToVisible,timeOut=5000)
|
||||
{
|
||||
await this.app.client.click(xpath).then(async()=>
|
||||
{
|
||||
await this.app.client.waitForVisible(elementToVisible,timeOut);
|
||||
});
|
||||
async clickAndWaitElementVisible(xpath, elementToVisible, timeOut = 5000) {
|
||||
await this.app.client.click(xpath);
|
||||
await this.app.client.waitForVisible(elementToVisible, timeOut);
|
||||
}
|
||||
|
||||
|
||||
async clickIfElementVisible(xpath, timeOut = 5000) {
|
||||
await this.app.client.waitForVisible(xpath, timeOut)
|
||||
.click(xpath)
|
||||
@@ -187,15 +185,18 @@ class WebActions {
|
||||
async login(user) {
|
||||
await this.inputText(ui.SIGN_IN_EMAIL, user.username);
|
||||
await this.inputText(ui.SIGN_IN_PASSWORD, user.password);
|
||||
await this.clickAndWaitElementVisible(ui.SIGN_IN_BUTTON,ui.SETTTING_BUTTON,60000);
|
||||
await this.clickAndWaitElementVisible(ui.SIGN_IN_BUTTON, ui.SETTTING_BUTTON, 60000);
|
||||
}
|
||||
|
||||
async persistToastIM()
|
||||
{
|
||||
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION, 5000);
|
||||
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB,10000);
|
||||
await this.clickAndWaitElementVisible(ui.PERSIS_NOTIFICATION_INPUT_IM,ui.PERSIS_NOTIFICATION_INPUT_IM, 5000);
|
||||
|
||||
async persistToastIM() {
|
||||
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION, 5000);
|
||||
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB, 10000);
|
||||
await this.clickAndWaitElementVisible(ui.PERSIS_NOTIFICATION_INPUT_IM, ui.PERSIS_NOTIFICATION_INPUT_IM, 5000);
|
||||
|
||||
}
|
||||
async clickLeftNavItem(name) {
|
||||
let xpath = await ui.LEFT_NAV_SINGLE_ITEM.replace("$$", name);
|
||||
await this.clickAndWaitElementVisible(xpath,ui.HEADER_MODULE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ class WindowsActions {
|
||||
})
|
||||
}
|
||||
|
||||
async showWindow() {
|
||||
async showWindow() {
|
||||
await this.app.browserWindow.restore();
|
||||
await this.app.browserWindow.setAlwaysOnTop(true);
|
||||
}
|
||||
|
||||
async clickOutsideWindow() {
|
||||
await this.setPosition(0, 0);
|
||||
var currentSize = await this.getCurrentSize();
|
||||
let currentSize = await this.getCurrentSize();
|
||||
await robot.moveMouse(currentSize[0] + 20, currentSize[1] + 20);
|
||||
await robot.mouseClick();
|
||||
}
|
||||
@@ -66,12 +66,12 @@ class WindowsActions {
|
||||
await this.app.browserWindow.isAlwaysOnTop().then(function (isAlwaysOnTop) {
|
||||
expect(isAlwaysOnTop).toBeTruthy();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async verifyLogExported() {
|
||||
let expected = false;
|
||||
let path = await Utils.getFolderPath('Downloads');
|
||||
var listFiles = Utils.getFiles(path);
|
||||
let listFiles = Utils.getFiles(path);
|
||||
listFiles.forEach(function (fileName) {
|
||||
if (fileName.indexOf(constants.LOG_FILENAME_PREFIX) > -1) {
|
||||
expected = true;
|
||||
@@ -82,7 +82,7 @@ class WindowsActions {
|
||||
|
||||
async deleteAllLogFiles() {
|
||||
let path = await Utils.getFolderPath('Downloads');
|
||||
var listFiles = Utils.getFiles(path);
|
||||
let listFiles = Utils.getFiles(path);
|
||||
await listFiles.forEach(function (fileName) {
|
||||
if (fileName.indexOf(constants.LOG_FILENAME_PREFIX) > -1) {
|
||||
fs.unlinkSync(path.concat("\\", fileName));
|
||||
@@ -130,14 +130,14 @@ class WindowsActions {
|
||||
}
|
||||
await robot.keyTap('enter');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async menuSearch(element, namevalue) {
|
||||
if (element.name == namevalue) {
|
||||
if (element.name == namevalue) {
|
||||
return await element;
|
||||
}
|
||||
else if (element.items !== undefined) {
|
||||
var result;
|
||||
let result;
|
||||
for (var i = 0; result == null && i < element.items.length; i++) {
|
||||
result = await this.menuSearch(element.items[i], namevalue);
|
||||
result;
|
||||
@@ -175,7 +175,7 @@ class WindowsActions {
|
||||
await this.app.browserWindow.isMinimized().then(async function (minimized) {
|
||||
await expect(minimized).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
console.log("error:"+err.name);
|
||||
console.log("error:" + err.name);
|
||||
});;
|
||||
}
|
||||
|
||||
@@ -207,23 +207,22 @@ class WindowsActions {
|
||||
await robot.keyToggle('r', 'up', ['control']);
|
||||
}
|
||||
|
||||
async focusWindow() {
|
||||
async focusWindow() {
|
||||
this.app.browserWindow.focus();
|
||||
this.app.browserWindow.setAlwaysOnTop(true);
|
||||
}
|
||||
}
|
||||
|
||||
async openMenu(arrMenu) {
|
||||
var arrStep = [];
|
||||
let arrStep = [];
|
||||
for (var i = 0; i < arrMenu.length; i++) {
|
||||
var item = await this.menuSearch(constants.MENU.root, arrMenu[i]);
|
||||
await arrStep.push(item);
|
||||
}
|
||||
await arrStep.push(item);
|
||||
}
|
||||
await this.actionForMenus(arrStep);
|
||||
return arrStep;
|
||||
}
|
||||
}
|
||||
|
||||
async reload()
|
||||
{
|
||||
async reload() {
|
||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||
await robot.setMouseDelay(100);
|
||||
let x = bounds.x + 95;
|
||||
@@ -232,91 +231,112 @@ class WindowsActions {
|
||||
await robot.moveMouse(x, y);
|
||||
await robot.mouseClick('right');
|
||||
await robot.setKeyboardDelay(2000);
|
||||
await robot.keyTap('right');
|
||||
await robot.keyTap('down');
|
||||
await robot.keyTap('enter');
|
||||
}).catch((err1) => {
|
||||
console.log("Message:"+err1);
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
await robot.keyTap('right');
|
||||
await robot.keyTap('down');
|
||||
await robot.keyTap('enter');
|
||||
}).catch((err1) => {
|
||||
console.log("Message:" + err1);
|
||||
});
|
||||
}
|
||||
|
||||
async mouseMoveNotification()
|
||||
{
|
||||
let screen = await this.app.electron.screen.getAllDisplays();
|
||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||
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 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.moveMouse(x, y);
|
||||
await robot.mouseClick();
|
||||
});
|
||||
}
|
||||
|
||||
async mouseMoveCenter()
|
||||
{
|
||||
let screen = await this.app.electron.screen.getAllDisplays();
|
||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||
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-500;
|
||||
let y = screen[0].bounds.height - 100;
|
||||
await robot.moveMouseSmooth(x, y);
|
||||
await robot.moveMouse(x, y);
|
||||
});
|
||||
}
|
||||
|
||||
async veriryPersistToastNotification(message)
|
||||
{
|
||||
var i =0;
|
||||
while(i < 6)
|
||||
{
|
||||
await Utils.sleep(1);
|
||||
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 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;
|
||||
await robot.moveMouseSmooth(x, y);
|
||||
await robot.moveMouse(x, y);
|
||||
});
|
||||
}
|
||||
|
||||
async veriryPersistToastNotification(message) {
|
||||
let i = 0;
|
||||
while (i < 6) {
|
||||
await Utils.sleep(1);
|
||||
await i++;
|
||||
}
|
||||
await this.webAction.verifyToastNotificationShow(message);
|
||||
await this.clickNotification();
|
||||
await this.clickNotification();
|
||||
await this.mouseMoveCenter();
|
||||
}
|
||||
|
||||
async verifyNotPersistToastNotification(message)
|
||||
{
|
||||
var i = 0;
|
||||
let count =0;
|
||||
|
||||
while(i < 11)
|
||||
{
|
||||
await Utils.sleep(1);
|
||||
async verifyNotPersistToastNotification(message) {
|
||||
let i = 0;
|
||||
let count = 0;
|
||||
|
||||
while (i < 11) {
|
||||
await Utils.sleep(1);
|
||||
await i++;
|
||||
}
|
||||
await this.webAction.verifyNoToastNotificationShow(message);
|
||||
await this.mouseMoveCenter();
|
||||
}
|
||||
}
|
||||
|
||||
async verifyNotCloseToastWhenMouseOver(message)
|
||||
{
|
||||
async verifyNotCloseToastWhenMouseOver(message) {
|
||||
await this.mouseMoveNotification();
|
||||
var i =0;
|
||||
while(i < 8)
|
||||
{
|
||||
await Utils.sleep(1);
|
||||
let i = 0;
|
||||
while (i < 8) {
|
||||
await Utils.sleep(1);
|
||||
await i++;
|
||||
}
|
||||
await this.webAction.verifyToastNotificationShow(message);
|
||||
await this.mouseMoveCenter();
|
||||
}
|
||||
}
|
||||
|
||||
async getBadgeCount() {
|
||||
let count = await this.app.electron.remote.app.getBadgeCount();
|
||||
return count;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = WindowsActions;
|
||||
module.exports = WindowsActions;
|
||||
|
||||
Reference in New Issue
Block a user