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);
|
await this.app.client.waitForVisible(ui.MINIMIZE_BTN, 10000).click(ui.MINIMIZE_BTN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ class WebActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getElementByXPath(xpath) {
|
async getElementByXPath(xpath) {
|
||||||
|
await this.app.client.waitForVisible(xpath, constants.TIMEOUT_WAIT_ELEMENT);
|
||||||
var elem = this.app.client.element(xpath);
|
var elem = this.app.client.element(xpath);
|
||||||
if (elem.isVisible()) {
|
if (elem.isVisible()) {
|
||||||
return elem;
|
return elem;
|
||||||
@@ -123,7 +124,7 @@ class WebActions {
|
|||||||
show = true;
|
show = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (show){
|
if (show) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ class WebActions {
|
|||||||
noShow = false;
|
noShow = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (noShow === false){
|
if (noShow === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +159,7 @@ class WebActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getElementByXPath(xpath) {
|
async getElementByXPath(xpath) {
|
||||||
var elem = this.app.client.element(xpath);
|
let elem = this.app.client.element(xpath);
|
||||||
if (elem.isVisible()) {
|
if (elem.isVisible()) {
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
@@ -166,17 +167,14 @@ class WebActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async inputText(el, data) {
|
async inputText(el, data) {
|
||||||
var obj = await this.getElementByXPath(el);
|
let obj = await this.getElementByXPath(el);
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
await this.app.client.setValue(el, data);
|
await this.app.client.setValue(el, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickAndWaitElementVisible(xpath,elementToVisible,timeOut=5000)
|
async clickAndWaitElementVisible(xpath, elementToVisible, timeOut = 5000) {
|
||||||
{
|
await this.app.client.click(xpath);
|
||||||
await this.app.client.click(xpath).then(async()=>
|
await this.app.client.waitForVisible(elementToVisible, timeOut);
|
||||||
{
|
|
||||||
await this.app.client.waitForVisible(elementToVisible,timeOut);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickIfElementVisible(xpath, timeOut = 5000) {
|
async clickIfElementVisible(xpath, timeOut = 5000) {
|
||||||
@@ -187,16 +185,19 @@ class WebActions {
|
|||||||
async login(user) {
|
async login(user) {
|
||||||
await this.inputText(ui.SIGN_IN_EMAIL, user.username);
|
await this.inputText(ui.SIGN_IN_EMAIL, user.username);
|
||||||
await this.inputText(ui.SIGN_IN_PASSWORD, user.password);
|
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()
|
async persistToastIM() {
|
||||||
{
|
|
||||||
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION, 5000);
|
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION, 5000);
|
||||||
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB,10000);
|
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB, 10000);
|
||||||
await this.clickAndWaitElementVisible(ui.PERSIS_NOTIFICATION_INPUT_IM,ui.PERSIS_NOTIFICATION_INPUT_IM, 5000);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = WebActions;
|
module.exports = WebActions;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class WindowsActions {
|
|||||||
|
|
||||||
async clickOutsideWindow() {
|
async clickOutsideWindow() {
|
||||||
await this.setPosition(0, 0);
|
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.moveMouse(currentSize[0] + 20, currentSize[1] + 20);
|
||||||
await robot.mouseClick();
|
await robot.mouseClick();
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ class WindowsActions {
|
|||||||
async verifyLogExported() {
|
async verifyLogExported() {
|
||||||
let expected = false;
|
let expected = false;
|
||||||
let path = await Utils.getFolderPath('Downloads');
|
let path = await Utils.getFolderPath('Downloads');
|
||||||
var listFiles = Utils.getFiles(path);
|
let listFiles = Utils.getFiles(path);
|
||||||
listFiles.forEach(function (fileName) {
|
listFiles.forEach(function (fileName) {
|
||||||
if (fileName.indexOf(constants.LOG_FILENAME_PREFIX) > -1) {
|
if (fileName.indexOf(constants.LOG_FILENAME_PREFIX) > -1) {
|
||||||
expected = true;
|
expected = true;
|
||||||
@@ -82,7 +82,7 @@ class WindowsActions {
|
|||||||
|
|
||||||
async deleteAllLogFiles() {
|
async deleteAllLogFiles() {
|
||||||
let path = await Utils.getFolderPath('Downloads');
|
let path = await Utils.getFolderPath('Downloads');
|
||||||
var listFiles = Utils.getFiles(path);
|
let listFiles = Utils.getFiles(path);
|
||||||
await listFiles.forEach(function (fileName) {
|
await listFiles.forEach(function (fileName) {
|
||||||
if (fileName.indexOf(constants.LOG_FILENAME_PREFIX) > -1) {
|
if (fileName.indexOf(constants.LOG_FILENAME_PREFIX) > -1) {
|
||||||
fs.unlinkSync(path.concat("\\", fileName));
|
fs.unlinkSync(path.concat("\\", fileName));
|
||||||
@@ -137,7 +137,7 @@ class WindowsActions {
|
|||||||
return await element;
|
return await element;
|
||||||
}
|
}
|
||||||
else if (element.items !== undefined) {
|
else if (element.items !== undefined) {
|
||||||
var result;
|
let result;
|
||||||
for (var i = 0; result == null && i < element.items.length; i++) {
|
for (var i = 0; result == null && i < element.items.length; i++) {
|
||||||
result = await this.menuSearch(element.items[i], namevalue);
|
result = await this.menuSearch(element.items[i], namevalue);
|
||||||
result;
|
result;
|
||||||
@@ -175,7 +175,7 @@ class WindowsActions {
|
|||||||
await this.app.browserWindow.isMinimized().then(async function (minimized) {
|
await this.app.browserWindow.isMinimized().then(async function (minimized) {
|
||||||
await expect(minimized).toBeTruthy();
|
await expect(minimized).toBeTruthy();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log("error:"+err.name);
|
console.log("error:" + err.name);
|
||||||
});;
|
});;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,17 +213,16 @@ class WindowsActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async openMenu(arrMenu) {
|
async openMenu(arrMenu) {
|
||||||
var arrStep = [];
|
let arrStep = [];
|
||||||
for (var i = 0; i < arrMenu.length; i++) {
|
for (var i = 0; i < arrMenu.length; i++) {
|
||||||
var item = await this.menuSearch(constants.MENU.root, arrMenu[i]);
|
var item = await this.menuSearch(constants.MENU.root, arrMenu[i]);
|
||||||
await arrStep.push(item);
|
await arrStep.push(item);
|
||||||
}
|
}
|
||||||
await this.actionForMenus(arrStep);
|
await this.actionForMenus(arrStep);
|
||||||
return arrStep;
|
return arrStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
async reload()
|
async reload() {
|
||||||
{
|
|
||||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
await robot.setMouseDelay(100);
|
await robot.setMouseDelay(100);
|
||||||
let x = bounds.x + 95;
|
let x = bounds.x + 95;
|
||||||
@@ -235,53 +234,48 @@ class WindowsActions {
|
|||||||
await robot.keyTap('right');
|
await robot.keyTap('right');
|
||||||
await robot.keyTap('down');
|
await robot.keyTap('down');
|
||||||
await robot.keyTap('enter');
|
await robot.keyTap('enter');
|
||||||
}).catch((err1) => {
|
}).catch((err1) => {
|
||||||
console.log("Message:"+err1);
|
console.log("Message:" + err1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickNotification()
|
async clickNotification() {
|
||||||
{
|
|
||||||
let screen = await this.app.electron.screen.getAllDisplays();
|
let screen = await this.app.electron.screen.getAllDisplays();
|
||||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
await robot.setMouseDelay(50);
|
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;
|
let y = screen[0].bounds.height - 100;
|
||||||
await robot.moveMouseSmooth(x, y);
|
await robot.moveMouseSmooth(x, y);
|
||||||
await robot.moveMouse(x, y);
|
await robot.moveMouse(x, y);
|
||||||
await robot.mouseClick();
|
await robot.mouseClick();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async mouseMoveNotification()
|
async mouseMoveNotification() {
|
||||||
{
|
|
||||||
let screen = await this.app.electron.screen.getAllDisplays();
|
let screen = await this.app.electron.screen.getAllDisplays();
|
||||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
await robot.setMouseDelay(50);
|
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;
|
let y = screen[0].bounds.height - 100;
|
||||||
await robot.moveMouseSmooth(x, y);
|
await robot.moveMouseSmooth(x, y);
|
||||||
await robot.moveMouse(x, y);
|
await robot.moveMouse(x, y);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async mouseMoveCenter()
|
async mouseMoveCenter() {
|
||||||
{
|
|
||||||
let screen = await this.app.electron.screen.getAllDisplays();
|
let screen = await this.app.electron.screen.getAllDisplays();
|
||||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
await robot.setMouseDelay(50);
|
await robot.setMouseDelay(50);
|
||||||
let x = screen[0].bounds.width-500;
|
let x = screen[0].bounds.width - 500;
|
||||||
let y = screen[0].bounds.height - 100;
|
let y = screen[0].bounds.height - 100;
|
||||||
await robot.moveMouseSmooth(x, y);
|
await robot.moveMouseSmooth(x, y);
|
||||||
await robot.moveMouse(x, y);
|
await robot.moveMouse(x, y);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async veriryPersistToastNotification(message)
|
async veriryPersistToastNotification(message) {
|
||||||
{
|
let i = 0;
|
||||||
var i =0;
|
while (i < 6) {
|
||||||
while(i < 6)
|
|
||||||
{
|
|
||||||
await Utils.sleep(1);
|
await Utils.sleep(1);
|
||||||
await i++;
|
await i++;
|
||||||
}
|
}
|
||||||
@@ -290,13 +284,11 @@ class WindowsActions {
|
|||||||
await this.mouseMoveCenter();
|
await this.mouseMoveCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
async verifyNotPersistToastNotification(message)
|
async verifyNotPersistToastNotification(message) {
|
||||||
{
|
let i = 0;
|
||||||
var i = 0;
|
let count = 0;
|
||||||
let count =0;
|
|
||||||
|
|
||||||
while(i < 11)
|
while (i < 11) {
|
||||||
{
|
|
||||||
await Utils.sleep(1);
|
await Utils.sleep(1);
|
||||||
await i++;
|
await i++;
|
||||||
}
|
}
|
||||||
@@ -304,12 +296,10 @@ class WindowsActions {
|
|||||||
await this.mouseMoveCenter();
|
await this.mouseMoveCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
async verifyNotCloseToastWhenMouseOver(message)
|
async verifyNotCloseToastWhenMouseOver(message) {
|
||||||
{
|
|
||||||
await this.mouseMoveNotification();
|
await this.mouseMoveNotification();
|
||||||
var i =0;
|
let i = 0;
|
||||||
while(i < 8)
|
while (i < 8) {
|
||||||
{
|
|
||||||
await Utils.sleep(1);
|
await Utils.sleep(1);
|
||||||
await i++;
|
await i++;
|
||||||
}
|
}
|
||||||
@@ -317,6 +307,36 @@ class WindowsActions {
|
|||||||
await this.mouseMoveCenter();
|
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