mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
AVT-1024 Add test "Pop-up alert play depends on setting" (#454)
This commit is contained in:
committed by
Vishwas Shashidhar
parent
79c952ac04
commit
6746fb294c
@@ -88,6 +88,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bluebird": "3.5.1",
|
"bluebird": "3.5.1",
|
||||||
"browserify": "16.2.2",
|
"browserify": "16.2.2",
|
||||||
|
"chromedriver": "2.40.0",
|
||||||
"cross-env": "5.2.0",
|
"cross-env": "5.2.0",
|
||||||
"electron": "2.0.6",
|
"electron": "2.0.6",
|
||||||
"electron-builder": "20.16.4",
|
"electron-builder": "20.16.4",
|
||||||
@@ -105,7 +106,9 @@
|
|||||||
"jest-html-reporter": "2.4.1",
|
"jest-html-reporter": "2.4.1",
|
||||||
"ncp": "2.0.0",
|
"ncp": "2.0.0",
|
||||||
"robotjs": "0.5.1",
|
"robotjs": "0.5.1",
|
||||||
"spectron": "3.8.0"
|
"selenium-webdriver": "3.6.0",
|
||||||
|
"spectron": "3.8.0",
|
||||||
|
"wdio-selenium-standalone-service": "0.0.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@paulcbetts/system-idle-time": "1.0.4",
|
"@paulcbetts/system-idle-time": "1.0.4",
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ let webActions;
|
|||||||
// Size and position of previos session keep after resizing and dragging
|
// Size and position of previos session keep after resizing and dragging
|
||||||
await windowActions.setPosition(defaultPosition[0], 20);
|
await windowActions.setPosition(defaultPosition[0], 20);
|
||||||
await windowActions.setSize(defaultSize[0] - 100, defaultSize[0] - 100);
|
await windowActions.setSize(defaultSize[0] - 100, defaultSize[0] - 100);
|
||||||
await Utils.sleep(1000); // Sleep 1s after resizing
|
await Utils.sleep(1); // Sleep 1s after resizing
|
||||||
var previousPosition = await windowActions.getCurrentPosition();
|
var previousPosition = await windowActions.getCurrentPosition();
|
||||||
var previousSize = await windowActions.getCurrentSize();
|
var previousSize = await windowActions.getCurrentSize();
|
||||||
await app.stop();
|
await app.stop();
|
||||||
@@ -60,7 +60,7 @@ let webActions;
|
|||||||
|
|
||||||
// Size and position of previous session keep after maximizing
|
// Size and position of previous session keep after maximizing
|
||||||
await webActions.maximizeWindows();
|
await webActions.maximizeWindows();
|
||||||
await Utils.sleep(1000); // Sleep 1s after resizing
|
await Utils.sleep(1); // Sleep 1s after resizing
|
||||||
previousSize = await windowActions.getCurrentSize();
|
previousSize = await windowActions.getCurrentSize();
|
||||||
await app.stop();
|
await app.stop();
|
||||||
app = await new Application({}).startApplication({defaultSize: false, defaultPosition: false});
|
app = await new Application({}).startApplication({defaultSize: false, defaultPosition: false});
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ module.exports = {
|
|||||||
|
|
||||||
SEARCH_LIBRARY_PATH_MAC: "node_modules/electron/dist/Electron.app/Contents/library",
|
SEARCH_LIBRARY_PATH_MAC: "node_modules/electron/dist/Electron.app/Contents/library",
|
||||||
SEARCH_LIBRARY_PATH_WIN: "node_modules/electron/dist/library",
|
SEARCH_LIBRARY_PATH_WIN: "node_modules/electron/dist/library",
|
||||||
TESTED_HOST: "https://cip4-qa.symphony.com/",
|
|
||||||
|
|
||||||
MENU: {
|
MENU: {
|
||||||
"root": {
|
"root": {
|
||||||
@@ -20,5 +19,13 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
LOG_FILENAME_PREFIX: "logs_symphony_"
|
LOG_FILENAME_PREFIX: "logs_symphony_",
|
||||||
|
USER_A: process.env.USER_A,
|
||||||
|
USER_B: process.env.USER_B,
|
||||||
|
USER_C: process.env.USER_C,
|
||||||
|
SIGN_IN_PASSWORD: process.env.PASSWORD,
|
||||||
|
TESTED_HOST: process.env.TESTED_HOST,
|
||||||
|
TYPE_ROOM: {private:"PRIVATE",public:"PUBLIC"},
|
||||||
|
TIMEOUT_PAGE_LOAD: 120000,
|
||||||
|
TIMEOUT_WAIT_ELEMENT: 10000
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,42 @@ module.exports= {
|
|||||||
MINIMIZE_BTN: "#title-bar-minimize-button",
|
MINIMIZE_BTN: "#title-bar-minimize-button",
|
||||||
CLOSE_BUTTON: "button#title-bar-close-button",
|
CLOSE_BUTTON: "button#title-bar-close-button",
|
||||||
MAIN_MENU_ITEM: "#hamburger-menu-button",
|
MAIN_MENU_ITEM: "#hamburger-menu-button",
|
||||||
|
SYM_LOGO: "#logo",
|
||||||
|
|
||||||
SYM_LOGO: "#logo"
|
//Sign In
|
||||||
|
SIGN_IN_BUTTON: "//button[@name='signin-submit']",
|
||||||
|
SIGN_IN_EMAIL: "//input[@name='signin-email']",
|
||||||
|
SIGN_IN_PASSWORD: "//input[@name='signin-password']",
|
||||||
|
NAV_PROFILE: "//div[@id='nav-profile']",
|
||||||
|
PLUS_BTN: "//div[@class='nav-profile__plus-btn-icon']",
|
||||||
|
IM_TAB: "//div[contains(@class,'modal-box modal-box--nfs')]//li[contains(text(),'Direct Chat')]",
|
||||||
|
CHATROOM_TAB: "//div[contains(@class, 'modal-box modal-box--nfs')]//li[contains(text(),'Chat Room')]",
|
||||||
|
CREATE_IM: "//form[@class='create-im']",
|
||||||
|
CREATE_BUTTON: "//button[text()='Create']",
|
||||||
|
ADD_PARTICIPANT_TEXT: "//div[@id='react-modal']//input[contains(@class,'react-autosuggest__input')]",
|
||||||
|
USERS_SUGGESTION_LIST: "//li[@id='react-autowhatever-1-section-0-item-0']",
|
||||||
|
CHATROOM_NAME_TEXT: "//form[@class='create-chatroom']//input[@name='name']",
|
||||||
|
CHATROOM_DESCR_TEXT: "//form[@class='create-chatroom']//input[@name='description']",
|
||||||
|
PRIVATE_ROOM_RADIO_BTN: "//form[@class='create-chatroom']//input[@value='PRIVATE']",
|
||||||
|
PUBLIC_ROOM_RADIO_BTN: "//form[@class='create-chatroom']//input[@value='PUBLIC']",
|
||||||
|
CREATE_IM_DONE_BTN: "//button[contains(@class,tempo-btn--good) and text()='Create']",
|
||||||
|
START_CHAT: "//*[contains(@class, 'sym-menu-tooltip__option')]/*[text()='Start a Chat']",
|
||||||
|
LEFT_NAV_SINGLE_ITEM: "//div[contains(@class, 'navigation-item-title')][.//span[@class='navigation-item-name' and normalize-space()='$$']]",
|
||||||
|
CHAT_INPUT_TYPING: "//div[contains(@class,'public-DraftEditor-content')]",
|
||||||
|
SETTTING_BUTTON: "//div[@class='toolbar-settings-text-container']",
|
||||||
|
PERSIS_NOTIFICATION_INPUT_ROOM: "//div[@class='alerts-settings__notification-category']//h5[text()='Rooms:']/..//input[@class='persistent-notification']",
|
||||||
|
PERSIS_NOTIFICATION_INPUT_IM: "//div[@class='alerts-settings__notification-category']//h5[text()='IMs:']/..//input[@class='persistent-notification']",
|
||||||
|
PERSIS_NOTIFICATION_INPUT_SIGNAL: "//div[@class='alerts-settings__notification-category']//h5[text()='Signals:']/..//input[@class='persistent-notification']",
|
||||||
|
ALERT_TAB: "//*[contains(@class,'tempo-tabs__tab tabs-tab') and @data-tab='alerts']",
|
||||||
|
ALERT_OPTION: "//span[@class='sym-menu-tooltip__option-label' and contains(.,'Alerts')]",
|
||||||
|
NAV_ALIAS: "//div[@class='nav-profile__alias']",
|
||||||
|
SIGNAL_HEADER : "//span[@class='navigation-category-name' and contains(.,'Signals')]",
|
||||||
|
WARNING_CLOSE_ICON : "//div[@id='sysMsg']//span[@class='close-icon']",
|
||||||
|
SCROLL_TAB_ACTIVE : "//div[@class='active-tab-container']",
|
||||||
|
|
||||||
|
//Alert Settings
|
||||||
|
MUTE_POPUP_ALERTS_CKB: ".field.field-notifications-on input",
|
||||||
|
|
||||||
|
//Toast Message
|
||||||
|
TOAST_MESSAGE_CONTENT: "#message",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ class App {
|
|||||||
|
|
||||||
this.app = new Application(this.options);
|
this.app = new Application(this.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async startApplication(configurations) {
|
async startApplication(configurations) {
|
||||||
try {
|
try {
|
||||||
this.app = await this.app.start();
|
this.app = await this.app.start();
|
||||||
await this.app.client.waitForVisible(ui.SYM_LOGO, require('./spectronSetup').getTimeOut());
|
await this.app.client.waitForVisible(ui.SYM_LOGO, constants.TIMEOUT_PAGE_LOAD);
|
||||||
await this.app.browserWindow.minimize();
|
await this.app.browserWindow.minimize();
|
||||||
await this.app.browserWindow.restore();
|
await this.app.browserWindow.restore();
|
||||||
if (configurations) {
|
if (configurations) {
|
||||||
|
|||||||
@@ -11,19 +11,34 @@ class Utils {
|
|||||||
await childProcess.exec('taskkill /f /t /im ' + processName);
|
await childProcess.exec('taskkill /f /t /im ' + processName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async sleep(ms) {
|
static async sleep(second) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(resolve, ms)
|
setTimeout(resolve, this.toMs(second));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static getFolderPath(folderName){
|
static getFolderPath(folderName) {
|
||||||
return path.join(require('os').homedir(), folderName);
|
return path.join(require('os').homedir(), folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getFiles(path){
|
static getFiles(path) {
|
||||||
return fs.readdirSync(path);
|
return fs.readdirSync(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static toMs(second) {
|
||||||
|
return second * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async randomString() {
|
||||||
|
var chars = await "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
||||||
|
var string_length = await 8;
|
||||||
|
var randomstring = await '';
|
||||||
|
for (var i = 0; i < string_length; i++) {
|
||||||
|
var rnum = await Math.floor(Math.random() * chars.length);
|
||||||
|
randomstring += await chars.substring(rnum, rnum + 1);
|
||||||
|
}
|
||||||
|
return randomstring;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Utils;
|
module.exports = Utils;
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
const ui = require('./spectronInterfaces.js');
|
const ui = require('./spectronInterfaces.js');
|
||||||
|
const constants = require('./spectronConstants.js');
|
||||||
|
const Utils = require('./spectronUtils');
|
||||||
|
|
||||||
class WebActions {
|
class WebActions {
|
||||||
constructor(app) {
|
constructor(app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickMaximizeButton() {
|
async maximizeButtonByClick() {
|
||||||
await this.app.client.waitForVisible(ui.MAXIMIZE_BTN, 10000).click(ui.MAXIMIZE_BTN);
|
await this.app.client.waitForVisible(ui.MAXIMIZE_BTN, constants.TIMEOUT_WAIT_ELEMENT).click(ui.MAXIMIZE_BTN);
|
||||||
}
|
}
|
||||||
|
|
||||||
async maximizeWindows() {
|
async maximizeWindows() {
|
||||||
await this.clickMaximizeButton();
|
await this.maximizeButtonByClick();
|
||||||
await this.app.browserWindow.isMaximized().then(function (maximized) {
|
await this.app.browserWindow.isMaximized().then(function (maximized) {
|
||||||
expect(maximized).toBeTruthy();
|
expect(maximized).toBeTruthy();
|
||||||
})
|
})
|
||||||
@@ -27,17 +29,141 @@ class WebActions {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async openApplicationMenuByClick() {
|
async closeWindowByClick() {
|
||||||
await this.app.client.click(ui.MAIN_MENU_ITEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
async closeWindowByClick() {
|
|
||||||
await this.app.client.click(ui.CLOSE_BUTTON);
|
await this.app.client.click(ui.CLOSE_BUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
async openApplicationMenuByClick() {
|
async openApplicationMenuByClick() {
|
||||||
await this.app.client.click(ui.MAIN_MENU_ITEM);
|
await this.app.client.click(ui.MAIN_MENU_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getElementByXPath(xpath) {
|
||||||
|
var elem = this.app.client.element(xpath);
|
||||||
|
if (elem.isVisible()) {
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
async inputText(el, data) {
|
||||||
|
var obj = await this.getElementByXPath(el);
|
||||||
|
if (obj != null)
|
||||||
|
await this.app.client.setValue(el, data);
|
||||||
|
}
|
||||||
|
async clickAndWaitElementVisible(xpath, elementToVisible, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
|
||||||
|
await this.app.client.click(xpath).then(async () => {
|
||||||
|
await this.app.client.waitForVisible(elementToVisible, timeOut);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async login(username) {
|
||||||
|
await this.inputText(ui.SIGN_IN_EMAIL, username);
|
||||||
|
await this.inputText(ui.SIGN_IN_PASSWORD, constants.SIGN_IN_PASSWORD);
|
||||||
|
await this.clickAndWaitElementVisible(ui.SIGN_IN_BUTTON, ui.PLUS_BTN, constants.TIMEOUT_PAGE_LOAD);
|
||||||
|
}
|
||||||
|
async scrollAndClick(selector, findElement) {
|
||||||
|
var i = 0;
|
||||||
|
var y = 0;
|
||||||
|
await this.app.client.scroll(selector, 0, y);
|
||||||
|
var size = 0;
|
||||||
|
while (i < 10) {
|
||||||
|
size = this.app.client.getElementSize(findElement);
|
||||||
|
if (findElement != null && size == 0) {
|
||||||
|
y += 50;
|
||||||
|
await this.app.client.scroll(selector, 0, y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await this.app.client.click(findElement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async promiseTimeout(ms, promiseFunc) {
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
// create a timeout to reject promise if not resolved
|
||||||
|
var timer = setTimeout(function () {
|
||||||
|
reject(new Error("promise timeout"));
|
||||||
|
}, ms);
|
||||||
|
|
||||||
|
promiseFunc
|
||||||
|
.then(function (res) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
resolve(res);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
async clickIfElementVisible(selector, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
|
||||||
|
await this.app.client.waitForVisible(selector, timeOut)
|
||||||
|
.click(selector)
|
||||||
|
}
|
||||||
|
|
||||||
|
async openAlertsSettings() {
|
||||||
|
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION);
|
||||||
|
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB);
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkBox(selector, value) {
|
||||||
|
var checked = await this.app.client.isSelected(selector);
|
||||||
|
while (checked != value) {
|
||||||
|
await this.clickIfElementVisible(selector);
|
||||||
|
checked = await this.app.client.isSelected(selector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async verifyToastNotificationShow(message) {
|
||||||
|
let show = false;
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
var 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) {
|
||||||
|
show = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (show){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Utils.sleep(1);
|
||||||
|
}
|
||||||
|
await expect(show).toBeTruthy();
|
||||||
|
await this.app.client.windowByIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
async verifyNoToastNotificationShow(message) {
|
||||||
|
let noShow;
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
var 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) {
|
||||||
|
noShow = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
noShow = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noShow === false){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Utils.sleep(1);
|
||||||
|
}
|
||||||
|
await expect(noShow).toBeTruthy();
|
||||||
|
await this.app.client.windowByIndex(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = WebActions;
|
module.exports = WebActions;
|
||||||
|
|||||||
224
tests/spectron/spectronWebDriver.js
Normal file
224
tests/spectron/spectronWebDriver.js
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
const { Builder, By, Key, until } = require('selenium-webdriver')
|
||||||
|
require('selenium-webdriver/chrome');
|
||||||
|
require('chromedriver');
|
||||||
|
var assert = require('assert');
|
||||||
|
const ui = require('./spectronInterfaces.js');
|
||||||
|
const specconst = require('./spectronConstants.js');
|
||||||
|
|
||||||
|
const waitUntilTime = 20000;
|
||||||
|
|
||||||
|
class WebDriver {
|
||||||
|
constructor(options) {
|
||||||
|
this.options = options;
|
||||||
|
this.d = new Builder().forBrowser(options.browser).build();
|
||||||
|
this.initDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitElelmentIsNotVisible(xpath) {
|
||||||
|
let result = false;
|
||||||
|
try {
|
||||||
|
const el = await this.driver.wait(
|
||||||
|
until.elementLocated(By.xpath(xpath)),
|
||||||
|
waitUntilTime
|
||||||
|
)
|
||||||
|
await this.driver.wait(until.elementIsNotVisible(el), 10000);
|
||||||
|
if (this.driver.findElements(By.xpath(xpath)).length > 0) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
return await assert.equal(result, false);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
await assert.equal(result, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitElementVisibleAndGet(xpath) {
|
||||||
|
const el = await this.driver.wait(
|
||||||
|
until.elementLocated(By.xpath(xpath)),
|
||||||
|
waitUntilTime
|
||||||
|
)
|
||||||
|
return await this.driver.wait(until.elementIsVisible(el), waitUntilTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
async getElementById(id) {
|
||||||
|
const el = await this.driver.wait(until.elementLocated(By.id(id)), waitUntilTime)
|
||||||
|
return await this.driver.wait(until.elementIsVisible(el), waitUntilTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
async getElementByXPath(xpath) {
|
||||||
|
const el = await this.driver.wait(
|
||||||
|
until.elementLocated(By.xpath(xpath)),
|
||||||
|
waitUntilTime
|
||||||
|
)
|
||||||
|
return await this.driver.wait(until.elementIsVisible(el), waitUntilTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
async inputText(el, data) {
|
||||||
|
var obj = await this.getElementByXPath(el);
|
||||||
|
await obj.sendKeys(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
async sendEnter(el) {
|
||||||
|
var obj = await this.getElementByXPath(el);
|
||||||
|
await obj.sendKeys(Key.ENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
async sendMessage(message) {
|
||||||
|
await this.inputText(ui.CHAT_INPUT_TYPING, message);
|
||||||
|
await this.sendEnter(ui.CHAT_INPUT_TYPING, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
async sendMessages(messages) {
|
||||||
|
for (var i = 0; i < messages.length; i++) {
|
||||||
|
await this.sendMessage(messages[i]);
|
||||||
|
await this.sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async login(username) {
|
||||||
|
await this.inputText(ui.SIGN_IN_EMAIL, username);
|
||||||
|
await this.inputText(ui.SIGN_IN_PASSWORD, specconst.SIGN_IN_PASSWORD);
|
||||||
|
var singin = await this.getElementByXPath(ui.SIGN_IN_BUTTON);
|
||||||
|
await singin.click();
|
||||||
|
await this.waitElelmentIsVisible(ui.SETTTING_BUTTON,specconst.TIMEOUT_PAGE_LOAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
async clickShowConversationCreationModal() {
|
||||||
|
var plusButton = await this.getElementByXPath(ui.PLUS_BTN);
|
||||||
|
await plusButton.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectIMTab() {
|
||||||
|
var imTab = await this.getElementByXPath(ui.IM_TAB);
|
||||||
|
await imTab.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectRoomTab() {
|
||||||
|
var roomTab = await this.getElementByXPath(ui.CHATROOM_TAB);
|
||||||
|
await roomTab.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async addParticipant(username) {
|
||||||
|
await this.inputText(ui.ADD_PARTICIPANT_TEXT, username);
|
||||||
|
await this.sleep(5);
|
||||||
|
var el = await this.waitElementVisibleAndGet(ui.USERS_SUGGESTION_LIST);
|
||||||
|
await el.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async clickDoneButton() {
|
||||||
|
var el = await this.getElementByXPath(ui.CREATE_IM_DONE_BTN);
|
||||||
|
await el.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async clickStartChat() {
|
||||||
|
var el = await this.getElementByXPath(ui.START_CHAT);
|
||||||
|
await el.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async createIM(username) {
|
||||||
|
await this.clickShowConversationCreationModal();
|
||||||
|
await this.clickStartChat();
|
||||||
|
await this.selectIMTab();
|
||||||
|
await this.addParticipant(username);
|
||||||
|
await this.clickDoneButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
async createMIM(usernames) {
|
||||||
|
await this.clickShowConversationCreationModal();
|
||||||
|
await this.clickStartChat();
|
||||||
|
await this.selectIMTab();
|
||||||
|
for (var i = 0; i < usernames.length; i++) {
|
||||||
|
await this.addParticipant(usernames[i]);
|
||||||
|
}
|
||||||
|
await this.clickDoneButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectPublicRadioButton() {
|
||||||
|
var el = await this.waitElementVisibleAndGet(ui.PUBLIC_ROOM_RADIO_BTN);
|
||||||
|
await el.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectPrivateRadioButton() {
|
||||||
|
var el = await this.waitElementVisibleAndGet(ui.PRIVATE_ROOM_RADIO_BTN);
|
||||||
|
await el.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async clickLeftNavItem(name) {
|
||||||
|
xpath = ui.LEFT_NAV_SINGLE_ITEM.replace("$$", name);
|
||||||
|
var el = await this.waitElementVisibleAndGet(xpath);
|
||||||
|
await el.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async createRoom(usernames, name, description, type) {
|
||||||
|
await this.clickShowConversationCreationModal();
|
||||||
|
await this.clickStartChat();
|
||||||
|
await this.selectRoomTab();
|
||||||
|
await this.inputText(ui.CHATROOM_NAME_TEXT, name);
|
||||||
|
await this.inputText(ui.CHATROOM_DESCR_TEXT, description);
|
||||||
|
if (type === specconst.TYPE_ROOM.private) {
|
||||||
|
await this.selectPrivateRadioButton();
|
||||||
|
}
|
||||||
|
if (type === specconst.TYPE_ROOM.public) {
|
||||||
|
await this.selectPublicRadioButton();
|
||||||
|
}
|
||||||
|
for (var i = 0; i < usernames.length; i++) {
|
||||||
|
await this.addParticipant(usernames[i]);
|
||||||
|
}
|
||||||
|
await this.clickDoneButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
async initDriver() {
|
||||||
|
return this.d.then(_d => {
|
||||||
|
this.driver = _d
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async startDriver() {
|
||||||
|
await this.driver
|
||||||
|
.manage()
|
||||||
|
.window()
|
||||||
|
.setPosition(0, 0);
|
||||||
|
var size = await await this.driver
|
||||||
|
.manage()
|
||||||
|
.window().getSize();
|
||||||
|
await this.driver.get(specconst.TESTED_HOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
async focusCurrentBrowser() {
|
||||||
|
this.driver.switchTo().window(this.driver.getAllWindowHandles()[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
async quit() {
|
||||||
|
await d.quit();
|
||||||
|
}
|
||||||
|
async sleep(secondSleep) {
|
||||||
|
await this.driver.sleep(secondSleep * 1000);
|
||||||
|
}
|
||||||
|
async timeOut(secondSleep) {
|
||||||
|
return secondSleep * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitElelmentIsVisible(xpath,timeout) {
|
||||||
|
try {
|
||||||
|
const el = await this.driver.wait(
|
||||||
|
until.elementLocated(By.xpath(xpath)),
|
||||||
|
waitUntilTime
|
||||||
|
)
|
||||||
|
await this.driver.wait(until.elementIsVisible(el), timeout);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log("Error:"+err.messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async quit() {
|
||||||
|
await this.driver.quit();
|
||||||
|
}
|
||||||
|
async close() {
|
||||||
|
await this.driver.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = WebDriver;
|
||||||
@@ -3,6 +3,7 @@ const constants = require('./spectronConstants.js');
|
|||||||
const Utils = require('./spectronUtils.js');
|
const Utils = require('./spectronUtils.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const WebActions = require('./spectronWebActions.js')
|
const WebActions = require('./spectronWebActions.js')
|
||||||
|
const ui = require('./spectronInterfaces.js');
|
||||||
|
|
||||||
class WindowsActions {
|
class WindowsActions {
|
||||||
constructor(app) {
|
constructor(app) {
|
||||||
@@ -10,6 +11,119 @@ class WindowsActions {
|
|||||||
this.webAction = new WebActions(app);
|
this.webAction = new WebActions(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async verifyMinimizeWindows() {
|
||||||
|
await this.app.browserWindow.isMinimized().then(async function (minimized) {
|
||||||
|
await expect(minimized).toBeTruthy();
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log("error:" + err.name);
|
||||||
|
});;
|
||||||
|
}
|
||||||
|
|
||||||
|
async isMinimizedWindows() {
|
||||||
|
let rminimized = -1;
|
||||||
|
|
||||||
|
await this.app.browserWindow.isMinimized().then(async function (minimized) {
|
||||||
|
rminimized = constants.MINIMIZED;
|
||||||
|
}).catch((err) => {
|
||||||
|
rminimized = constants.QUIT;
|
||||||
|
return rminimized;
|
||||||
|
});
|
||||||
|
|
||||||
|
return rminimized;
|
||||||
|
}
|
||||||
|
|
||||||
|
async pressCtrlW() {
|
||||||
|
await robot.keyToggle('w', 'down', ['control']);
|
||||||
|
await robot.keyToggle('w', 'up', ['control']);
|
||||||
|
}
|
||||||
|
async pressCtrlM() {
|
||||||
|
await robot.keyToggle('m', 'down', ['control']);
|
||||||
|
await robot.keyToggle('m', 'up', ['control']);
|
||||||
|
}
|
||||||
|
async focusWindow() {
|
||||||
|
await this.app.browserWindow.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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 actionForMenus(arrMenu) {
|
||||||
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
|
await robot.setMouseDelay(100);
|
||||||
|
let x = bounds.x + 95;
|
||||||
|
let y = bounds.y + 35;
|
||||||
|
await robot.moveMouseSmooth(x, y);
|
||||||
|
await robot.moveMouse(x, y);
|
||||||
|
await robot.mouseClick();
|
||||||
|
await this.webAction.openApplicationMenuByClick();
|
||||||
|
await robot.setKeyboardDelay(1000);
|
||||||
|
await robot.keyTap('enter');
|
||||||
|
for (var i = 0; i < arrMenu.length; i++) {
|
||||||
|
|
||||||
|
for (var s = 0; s < arrMenu[i].step; s++) {
|
||||||
|
await robot.keyTap('down');
|
||||||
|
}
|
||||||
|
if (arrMenu.length > 1 && i != arrMenu.length - 1) {
|
||||||
|
//handle right keygen
|
||||||
|
await robot.keyTap('right');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await robot.keyTap('enter');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async reload() {
|
||||||
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
|
await robot.setMouseDelay(100);
|
||||||
|
let x = bounds.x + 95;
|
||||||
|
let y = bounds.y + 200;
|
||||||
|
await robot.moveMouseSmooth(x, y);
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
await this.app.client.waitForVisible(ui.PLUS_BTN, constants.TIMEOUT_PAGE_LOAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
async clickNotification() {
|
||||||
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
|
await robot.setMouseDelay(100);
|
||||||
|
let x = bounds.x + 95;
|
||||||
|
let y = bounds.y + bounds.height - 20;
|
||||||
|
await robot.moveMouseSmooth(x, y);
|
||||||
|
await robot.moveMouse(x, y);
|
||||||
|
await robot.mouseClick();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
timeOut(second) {
|
||||||
|
return second * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
async getCurrentSize() {
|
async getCurrentSize() {
|
||||||
return this.app.browserWindow.getSize();
|
return this.app.browserWindow.getSize();
|
||||||
}
|
}
|
||||||
@@ -137,27 +251,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;
|
|
||||||
|
|
||||||
await this.app.browserWindow.isMinimized().then(async function (minimized) {
|
|
||||||
rminimized = constants.MINIMIZED;
|
|
||||||
}).catch((err) => {
|
|
||||||
rminimized = constants.QUIT;
|
|
||||||
return rminimized;
|
|
||||||
});
|
|
||||||
|
|
||||||
return rminimized;
|
|
||||||
}
|
|
||||||
|
|
||||||
async selectMinimizeOnClose() {
|
async selectMinimizeOnClose() {
|
||||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
||||||
await robot.setMouseDelay(100);
|
await robot.setMouseDelay(100);
|
||||||
@@ -199,63 +292,6 @@ class WindowsActions {
|
|||||||
await robot.keyTap('enter');
|
await robot.keyTap('enter');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async pressCtrlW() {
|
|
||||||
await robot.keyToggle('w', 'down', ['control']);
|
|
||||||
await robot.keyToggle('w', 'up', ['control']);
|
|
||||||
}
|
|
||||||
async focusWindow() {
|
|
||||||
await this.app.browserWindow.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
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 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 actionForMenus(arrMenu) {
|
|
||||||
await this.app.browserWindow.getBounds().then(async (bounds) => {
|
|
||||||
await robot.setMouseDelay(100);
|
|
||||||
let x = bounds.x + 95;
|
|
||||||
let y = bounds.y + 35;
|
|
||||||
await robot.moveMouseSmooth(x, y);
|
|
||||||
await robot.moveMouse(x, y);
|
|
||||||
await robot.mouseClick();
|
|
||||||
await this.webAction.openApplicationMenuByClick();
|
|
||||||
await robot.setKeyboardDelay(200);
|
|
||||||
await robot.keyTap('enter');
|
|
||||||
for (var i = 0; i < arrMenu.length; i++) {
|
|
||||||
for (var s = 0; s < arrMenu[i].step; s++) {
|
|
||||||
await robot.keyTap('down');
|
|
||||||
}
|
|
||||||
if (arrMenu.length > 1 && i != arrMenu.length - 1) {
|
|
||||||
//handle right keygen
|
|
||||||
await robot.keyTap('right');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await robot.keyTap('enter');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = WindowsActions;
|
module.exports = WindowsActions;
|
||||||
|
|||||||
77
tests/spectron/toastNotification.spectron.js
Normal file
77
tests/spectron/toastNotification.spectron.js
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
const Application = require('./spectronSetup');
|
||||||
|
const WebActions = require('./spectronWebActions');
|
||||||
|
const WindowsActions = require('./spectronWindowsActions');
|
||||||
|
const WebDriver = require('./spectronWebDriver');
|
||||||
|
const { isMac } = require('../../js/utils/misc.js');
|
||||||
|
const constants = require('./spectronConstants.js');
|
||||||
|
const ui = require('./spectronInterfaces.js');
|
||||||
|
const Utils = require('./spectronUtils');
|
||||||
|
|
||||||
|
let app, webDriver, webActions, windowsActions;
|
||||||
|
|
||||||
|
describe('Tests for Toast Notification ', () => {
|
||||||
|
|
||||||
|
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = constants.TIMEOUT_PAGE_LOAD;
|
||||||
|
|
||||||
|
beforeAll(async (done) => {
|
||||||
|
try {
|
||||||
|
webDriver = await new WebDriver({ browser: 'chrome' });
|
||||||
|
app = await new Application({}).startApplication({ testedHost: constants.TESTED_HOST, alwaysOnTop: true });
|
||||||
|
webActions = await new WebActions(app);
|
||||||
|
windowsActions = await new WindowsActions(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}`));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify Pop-up alert play depends on setting
|
||||||
|
* TC-ID: 2916217
|
||||||
|
* Cover scenarios in AVT-1024
|
||||||
|
*/
|
||||||
|
it('Pop-up alert play depends on setting', async (done) => {
|
||||||
|
try {
|
||||||
|
if (isMac) {
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
let message1 = await Utils.randomString();
|
||||||
|
let message2 = await Utils.randomString();
|
||||||
|
|
||||||
|
//"Mute pop-up alerts on my desktop"=OFF
|
||||||
|
await webDriver.startDriver();
|
||||||
|
await webActions.login(constants.USER_A);
|
||||||
|
await windowsActions.reload(); //workaround to show topbar menu
|
||||||
|
await webDriver.login(constants.USER_B);
|
||||||
|
await webActions.openAlertsSettings();
|
||||||
|
await webActions.checkBox(ui.MUTE_POPUP_ALERTS_CKB, false);
|
||||||
|
await webDriver.createIM(constants.USER_A);
|
||||||
|
await webDriver.sendMessages([message1]);
|
||||||
|
await webActions.verifyToastNotificationShow(message1);
|
||||||
|
await Utils.sleep(5); //waitting for toast message disappears
|
||||||
|
|
||||||
|
//"Mute pop-up alerts on my desktop"=ON
|
||||||
|
await webActions.checkBox(ui.MUTE_POPUP_ALERTS_CKB, true);
|
||||||
|
await webDriver.sendMessages([message2]);
|
||||||
|
await webActions.verifyNoToastNotificationShow(message2);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
done.fail(new Error(`Fail to verify pop-up alert play depends on setting: ${err}`));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user