AVT-1081 [Spectron][Windows] pop-out chat, inbox (#460)

This commit is contained in:
thaisym1912
2018-08-14 11:50:16 +07:00
committed by Vishwas Shashidhar
parent a0968d1752
commit 21b79f7714
8 changed files with 336 additions and 71 deletions

View File

@@ -0,0 +1,84 @@
const Application = require('./spectronSetup');
const WebActions = require('./spectronWebActions');
const WindowsActions = require('./spectronWindowsActions');
const { isMac } = require('../../js/utils/misc.js');
const constants = require('./spectronConstants.js');
const Utils = require('./spectronUtils');
let app, webActions, windowsActions;
describe('Tests for Pop-Outs', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = constants.TIMEOUT_TEST_SUITE;
beforeAll(async (done) => {
try {
app = await new Application({}).startApplication({testedHost: constants.TESTED_HOST});
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 {
await windowsActions.closeAllPopOutWindow();
if (app && app.isRunning()) {
await app.stop();
await webDriver.quit();
done();
}
} catch (err) {
done.fail(new Error(`Failed at post-condition: ${err}`));
};
});
/**
* Verify pop-out chat, inbox
* TC-ID: 2897209
* Cover scenarios in AVT-1081
*/
it('Verify pop-out chat, inbox', async (done) => {
try {
if (isMac) {
done();
} else {
await webActions.login(constants.USER_A);
await windowsActions.closeAllPopOutWindow();
await windowsActions.bringToFront("Symphony");
await webActions.createIM(constants.USER_B.name);
await webActions.clickPopOutIcon();
await windowsActions.verifyPopOutWindowAppear(constants.USER_B.name);
await webActions.verifyPopInIconDisplay(constants.USER_B.name);
await webActions.clickInboxIcon();
await webActions.clickInboxPopOutIcon();
await windowsActions.verifyPopOutWindowAppear("Inbox");
await webActions.verifyPopInIconDisplay("Inbox");
await windowsActions.bringToFront("Symphony");
await webActions.clickInboxIcon();
await windowsActions.verifyWindowFocus("Inbox");
await windowsActions.bringToFront("Symphony");
await webActions.clickLeftNavItem(constants.USER_B.name);
await Utils.sleep(1); //wait for popout overlaying completely
await windowsActions.verifyWindowFocus(constants.USER_B.name);
await windowsActions.bringToFront("Symphony");
await webActions.logout();
await webActions.login(constants.USER_A);
await windowsActions.verifyPopOutWindowAppear(constants.USER_B.name);
await windowsActions.verifyPopOutWindowAppear("Inbox");
await windowsActions.closeAllPopOutWindow();
done();
}
} catch (err) {
done.fail(new Error(`Fail to verify pop-out chat, inbox: ${err}`));
};
});
})

View File

@@ -24,6 +24,7 @@ module.exports = {
USER_C: { username: process.env.USER_C, password: process.env.PASSWORD, name: process.env.USER_C_NAME },
TESTED_HOST: process.env.TESTED_HOST,
TYPE_ROOM: { private: "PRIVATE", public: "PUBLIC" },
TIMEOUT_TEST_SUITE: 600000,
TIMEOUT_PAGE_LOAD: 120000,
TIMEOUT_WAIT_ELEMENT: 10000
};

View File

@@ -25,7 +25,7 @@ module.exports= {
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']",
SIGNAL_OPTION: "//div[@class='sym-menu-tooltip__option']/*[text()='Create a Signal']",
LEFT_NAV_SINGLE_ITEM: "//div[contains(@class, 'navigation-item-title')][.//span[@class='navigation-item-name' and normalize-space()='$$']]",
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']",
@@ -45,9 +45,25 @@ module.exports= {
MENTION_USER_SUGGESTION: "//span[@class='draftJs__suggestionsEntryText' and text()='$$']",
SUGGESTED_ENTITY_DROPDOWN: "//span[@class='draftJs__suggestionsEntryText']",
CONFIRM_CREATE_ROOM_BUTTON: "//div[@class='modal-box__footer-buttons']//button[text()='Yes']",
MODULE_ON_GRID: "#simple_grid",
SPINNER: ".spinner",
SIGNOUT: ".sign-out",
SIGNOUT_MODAL_BUTTON: "//div[@class='modal-content-buttons buttons']//button[contains(text(), 'Sign Out')]",
//Popin Popout
POPOUT_BUTTON: ".enhanced-pop-out",
POPOUT_INBOX_BUTTON: ".add-margin.popout",
POPIN_BUTTON: "//*[contains(@class, 'enhanced-pop-in') or contains(@class, 'add-margin popin')]",
PIN_CHAT_MOD: ".chat-module .pin-view",
//Alert Settings
MUTE_POPUP_ALERTS_CKB: ".field.field-notifications-on input",
//Toast Message
TOAST_MESSAGE_CONTENT: "#message",
//Inbox
INBOX_BUTTON: ".toolbar-btn-inbox",
INBOX_HEADER: ".inbox-header",
};

View File

@@ -34,8 +34,6 @@ class App {
try {
this.app = await this.app.start();
await this.app.client.waitForVisible(ui.SYM_LOGO, constants.TIMEOUT_PAGE_LOAD);
await this.app.browserWindow.minimize();
await this.app.browserWindow.restore();
if (configurations) {
if (typeof configurations.alwaysOnTop !== "undefined") {
await this.app.browserWindow.setAlwaysOnTop(configurations.alwaysOnTop);
@@ -51,6 +49,8 @@ class App {
if ((typeof configurations === "undefined") || (typeof configurations.defaultPosition === "undefined") || (configurations.defaultPosition === true)) {
await this.app.browserWindow.center();
}
await this.app.browserWindow.minimize();
await this.app.browserWindow.restore();
return this.app;
} catch (err) {
throw new Error("Unable to start application " + err);
@@ -66,7 +66,7 @@ class App {
}
static getTimeOut() {
return 600000;
return 90000;
}
static readConfig(configPath) {

View File

@@ -1,6 +1,7 @@
const ui = require('./spectronInterfaces.js');
const constants = require('./spectronConstants.js');
const Utils = require('./spectronUtils');
const WindowsActions = require('./spectronWindowsActions');
class WebActions {
constructor(app) {
@@ -58,7 +59,6 @@ class WebActions {
async clickAndWaitElementVisible(xpath, elementToVisible, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
await this.app.client.click(xpath).then(async () => {
await this.app.client.waitForVisible(elementToVisible, timeOut);
});
}
@@ -83,14 +83,11 @@ class WebActions {
}
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);
@@ -116,7 +113,7 @@ class WebActions {
async verifyToastNotificationShow(message) {
let show = false;
for (let i = 0; i < 10; i++) {
var winCount = await this.app.client.getWindowCount();
let winCount = await this.app.client.getWindowCount();
if (winCount > 1) {
for (let j = 1; j < winCount; j++) {
await this.app.client.windowByIndex(j);
@@ -137,7 +134,7 @@ class WebActions {
async verifyNoToastNotificationShow(message) {
let noShow;
for (let i = 0; i < 10; i++) {
var winCount = await this.app.client.getWindowCount();
let winCount = await this.app.client.getWindowCount();
if (winCount > 1) {
for (let j = 1; j < winCount; j++) {
await this.app.client.windowByIndex(j);
@@ -172,12 +169,12 @@ class WebActions {
await this.app.client.setValue(el, data);
}
async clickAndWaitElementVisible(xpath, elementToVisible, timeOut = 5000) {
async clickAndWaitElementVisible(xpath, elementToVisible, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
await this.app.client.click(xpath);
await this.app.client.waitForVisible(elementToVisible, timeOut);
}
async clickIfElementVisible(xpath, timeOut = 5000) {
async clickIfElementVisible(xpath, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
await this.app.client.waitForVisible(xpath, timeOut)
.click(xpath)
}
@@ -185,18 +182,97 @@ 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, constants.TIMEOUT_PAGE_LOAD);
await this.waitElementNotVisible(ui.SPINNER);
}
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);
await this.clickAndWaitElementVisible(ui.SETTTING_BUTTON, ui.ALERT_OPTION);
await this.clickAndWaitElementVisible(ui.ALERT_OPTION, ui.ALERT_TAB);
await this.clickAndWaitElementVisible(ui.PERSIS_NOTIFICATION_INPUT_IM, ui.PERSIS_NOTIFICATION_INPUT_IM);
}
async clickLeftNavItem(name) {
let xpath = await ui.LEFT_NAV_SINGLE_ITEM.replace("$$", name);
await this.clickAndWaitElementVisible(xpath,ui.HEADER_MODULE);
async clickPlusButton() {
await this.clickIfElementVisible(ui.PLUS_BTN);
}
async clickStartChat() {
await this.clickIfElementVisible(ui.START_CHAT);
}
async selectIMTab() {
await this.clickIfElementVisible(ui.IM_TAB);
}
async addParticipant(username) {
await this.inputText(ui.ADD_PARTICIPANT_TEXT, username);
await this.clickIfElementVisible(ui.USERS_SUGGESTION_LIST, 20000);
}
async clickDoneButton() {
await this.clickIfElementVisible(ui.CREATE_IM_DONE_BTN);
await this.waitElementVisible(ui.HEADER_MODULE);
}
async waitElementNotVisible(locator, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
return await this.app.client.waitForVisible(locator, timeOut, true);
}
async waitElementVisible(locator, timeOut = constants.TIMEOUT_WAIT_ELEMENT) {
return await this.app.client.waitForVisible(locator, timeOut);
}
async mouseOver(locator) {
await this.app.client.moveToObject(locator);
}
async createIM(username) {
await this.clickPlusButton();
await this.clickStartChat();
await this.selectIMTab();
await this.addParticipant(username);
await this.clickDoneButton();
}
async clickPopOutIcon() {
let windowsActions = await new WindowsActions(this.app);
await this.mouseOver(ui.PIN_CHAT_MOD);
await Utils.sleep(2); //wait popout button clickable
await this.clickIfElementVisible(ui.POPOUT_BUTTON);
let index = await windowsActions.getWindowCount() - 1;
await windowsActions.windowByIndex(index);
await this.waitElementNotVisible(ui.SPINNER, constants.TIMEOUT_PAGE_LOAD);
}
async clickInboxPopOutIcon() {
let windowsActions = await new WindowsActions(this.app);
await this.clickIfElementVisible(ui.POPOUT_INBOX_BUTTON);
let index = await windowsActions.getWindowCount() - 1;
await windowsActions.windowByIndex(index);
await this.waitElementNotVisible(ui.SPINNER, constants.TIMEOUT_PAGE_LOAD);
}
async verifyPopInIconDisplay(windowTitle){
let windowsActions = await new WindowsActions(this.app);
let index = await windowsActions.getWindowIndexFromTitle(windowTitle);
await windowsActions.windowByIndex(index);
await this.waitElementVisible(ui.POPIN_BUTTON, constants.TIMEOUT_WAIT_ELEMENT);
await windowsActions.windowByIndex(0);
}
async clickInboxIcon() {
await this.clickIfElementVisible(ui.INBOX_BUTTON);
}
async clickLeftNavItem(item){
let singleItemLocator = ui.LEFT_NAV_SINGLE_ITEM.replace("$$",item);
await this.clickIfElementVisible(singleItemLocator);
}
async logout(){
await this.openAlertsSettings();
await this.clickAndWaitElementVisible(ui.SIGNOUT, ui.SIGNOUT_MODAL_BUTTON);
await this.clickAndWaitElementVisible(ui.SIGNOUT_MODAL_BUTTON, ui.SIGN_IN_BUTTON, constants.TIMEOUT_PAGE_LOAD);
}
}

View File

@@ -7,7 +7,6 @@ const WebActions = require('./spectronWebActions.js')
class WindowsActions {
constructor(app) {
this.app = app;
this.webAction = new WebActions(app);
}
async getCurrentSize() {
@@ -68,6 +67,56 @@ 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 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) {
let webAction = await new WebActions(this.app);
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 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');
});
}
async verifyLogExported() {
let expected = false;
let path = await Utils.getFolderPath('Downloads');
@@ -112,6 +161,7 @@ class WindowsActions {
}
async selectMinimizeOnClose() {
let webAction = await new WebActions(this.app);
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(100);
let x = bounds.x + 95;
@@ -119,7 +169,7 @@ class WindowsActions {
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
await robot.mouseClick();
await this.webAction.openApplicationMenuByClick();
await webAction.openApplicationMenuByClick();
await robot.setKeyboardDelay(1000);
await robot.keyTap('enter');
await robot.keyTap('down');
@@ -132,22 +182,8 @@ class WindowsActions {
});
}
async menuSearch(element, namevalue) {
if (element.name == namevalue) {
return await element;
}
else if (element.items !== undefined) {
let 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 actionForMenus(arrMenu) {
async quitApp() {
let webAction = await new WebActions(this.app);
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(100);
let x = bounds.x + 95;
@@ -155,22 +191,24 @@ class WindowsActions {
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
await robot.mouseClick();
await this.webAction.openApplicationMenuByClick();
await robot.setKeyboardDelay(200);
await 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('down');
await robot.keyTap('right');
}
for (let i = 0; i < 6; i++) {
await robot.keyTap('down');
}
await robot.keyTap('enter');
});
}
async pressCtrlW() {
await robot.keyToggle('w', 'down', ['control']);
await robot.keyToggle('w', 'up', ['control']);
}
async verifyMinimizeWindows() {
await this.app.browserWindow.isMinimized().then(async function (minimized) {
await expect(minimized).toBeTruthy();
@@ -192,11 +230,6 @@ class WindowsActions {
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']);
@@ -212,16 +245,6 @@ class WindowsActions {
this.app.browserWindow.setAlwaysOnTop(true);
}
async openMenu(arrMenu) {
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 this.actionForMenus(arrStep);
return arrStep;
}
async reload() {
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(100);
@@ -337,6 +360,69 @@ class WindowsActions {
await expect(expected).toBeTruthy();
}
async getWindowIndexFromTitle(windowTitle) {
let winCount = await this.getWindowCount();
if (winCount > 1) {
for (let j = 1; j < winCount; j++) {
await this.windowByIndex(j);
//wait 120s for title loading
let title = await this.app.browserWindow.getTitle();
for (let i = 1; i <= 120; i++) {
if (title != "Symphony") {
break;
}
await Utils.sleep(1);
title = await this.app.browserWindow.getTitle();;
}
if (title === windowTitle) {
await this.windowByIndex(0);
return j;
}
}
}
await this.windowByIndex(0);
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 verifyWindowFocus(windowTitle) {
let index = await this.getWindowIndexFromTitle(windowTitle);
await this.windowByIndex(index);
expect(await this.app.browserWindow.isFocused()).toBeTruthy();
await this.windowByIndex(0);
}
async verifyPopOutWindowAppear(windowTitle) {
let index = await this.getWindowIndexFromTitle(windowTitle);
expect(index).toBeGreaterThan(0);
}
async closeAllPopOutWindow() {
let winCount = await this.getWindowCount();
while (winCount > 1) {
await this.windowByIndex(winCount - 1);
await this.app.browserWindow.close();
await Utils.sleep(2);
winCount = await this.getWindowCount();
}
await this.windowByIndex(0);
}
}
module.exports = WindowsActions;

View File

@@ -14,8 +14,9 @@ const ifc = require('./spectronInterfaces.js');
let webActions, windowAction;
!isMac? describe('Verify toast notification for IMs', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
let originalTimeout = specconst.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = specconst.TIMEOUT_TEST_SUITE;
beforeAll(async(done) => {
try
{

View File

@@ -14,8 +14,9 @@ const specconst = require('./spectronConstants.js');
let webActions, windowAction;
!isMac ? describe('Verify toast notification when Persist Notification is ON', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = specconst.TIMEOUT_TEST_SUITE;
beforeAll(async(done) => {
try
{