AVT-1031 AND AVT-1032: Verify toast notification for IMs, Signal,Room (#448)

This commit is contained in:
tranducanh 2018-08-08 14:30:44 +07:00 committed by Vishwas Shashidhar
parent d3f77685dd
commit 2624e706c5
7 changed files with 142 additions and 208 deletions

View File

@ -1,4 +1,3 @@
require('dotenv').config()
module.exports = { module.exports = {
SYMPHONY_CONFIG_FILE_NAME: "/Symphony.config", SYMPHONY_CONFIG_FILE_NAME: "/Symphony.config",
@ -20,10 +19,9 @@ module.exports = {
}, },
LOG_FILENAME_PREFIX: "logs_symphony_", LOG_FILENAME_PREFIX: "logs_symphony_",
USER_A: process.env.USER_A, USER_A: {username:process.env.USER_A,password:process.env.PASSWORD,name:process.env.USER_A_NAME},
USER_B: process.env.USER_B, USER_B: {username:process.env.USER_B,password:process.env.PASSWORD,name:process.env.USER_B_NAME},
USER_C: process.env.USER_C, USER_C: {username:process.env.USER_C,password:process.env.PASSWORD,name:process.env.USER_C_NAME},
SIGN_IN_PASSWORD: process.env.PASSWORD,
TESTED_HOST: process.env.TESTED_HOST, TESTED_HOST: process.env.TESTED_HOST,
TYPE_ROOM: {private:"PRIVATE",public:"PUBLIC"}, TYPE_ROOM: {private:"PRIVATE",public:"PUBLIC"},
TIMEOUT_PAGE_LOAD: 120000, TIMEOUT_PAGE_LOAD: 120000,

View File

@ -66,7 +66,7 @@ class App {
} }
static getTimeOut() { static getTimeOut() {
return 90000; return 600000;
} }
static readConfig(configPath) { static readConfig(configPath) {

View File

@ -61,11 +61,6 @@ class WebActions {
}); });
} }
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) { async scrollAndClick(selector, findElement) {
var i = 0; var i = 0;
var y = 0; var y = 0;
@ -123,7 +118,7 @@ class WebActions {
var winCount = await this.app.client.getWindowCount(); var winCount = await this.app.client.getWindowCount();
if (winCount > 1) { if (winCount > 1) {
for (let j = 1; j < winCount; j++) { 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) { if (await this.app.client.getText(ui.TOAST_MESSAGE_CONTENT) === message) {
show = true; show = true;
} }
@ -144,7 +139,7 @@ class WebActions {
var winCount = await this.app.client.getWindowCount(); var winCount = await this.app.client.getWindowCount();
if (winCount > 1) { if (winCount > 1) {
for (let j = 1; j < winCount; j++) { 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) { if (await this.app.client.getText(ui.TOAST_MESSAGE_CONTENT) !== message) {
noShow = true; noShow = true;
} }

View File

@ -5,8 +5,6 @@ var assert = require('assert');
const ui = require('./spectronInterfaces.js'); const ui = require('./spectronInterfaces.js');
const specconst = require('./spectronConstants.js'); const specconst = require('./spectronConstants.js');
const waitUntilTime = 20000;
class WebDriver { class WebDriver {
constructor(options) { constructor(options) {
this.options = options; this.options = options;
@ -19,9 +17,9 @@ class WebDriver {
try { try {
const el = await this.driver.wait( const el = await this.driver.wait(
until.elementLocated(By.xpath(xpath)), until.elementLocated(By.xpath(xpath)),
waitUntilTime specconst.TIMEOUT_WAIT_ELEMENT
) )
await this.driver.wait(until.elementIsNotVisible(el), waitUntilTime); await this.driver.wait(until.elementIsNotVisible(el), specconst.TIMEOUT_WAIT_ELEMENT);
if (this.driver.findElements(By.xpath(xpath)).length > 0) { if (this.driver.findElements(By.xpath(xpath)).length > 0) {
result = true; result = true;
} }
@ -39,7 +37,7 @@ class WebDriver {
try { try {
const el = await this.driver.wait( const el = await this.driver.wait(
until.elementLocated(By.xpath(xpath)), until.elementLocated(By.xpath(xpath)),
waitUntilTime specconst.TIMEOUT_WAIT_ELEMENT
) )
await this.driver.wait(until.elementIsVisible(el), timeout); await this.driver.wait(until.elementIsVisible(el), timeout);
} }
@ -51,22 +49,22 @@ class WebDriver {
async waitElementVisibleAndGet(xpath) { async waitElementVisibleAndGet(xpath) {
const el = await this.driver.wait( const el = await this.driver.wait(
until.elementLocated(By.xpath(xpath)), until.elementLocated(By.xpath(xpath)),
waitUntilTime specconst.TIMEOUT_WAIT_ELEMENT
) )
return await this.driver.wait(until.elementIsVisible(el), waitUntilTime) return await this.driver.wait(until.elementIsVisible(el), specconst.TIMEOUT_WAIT_ELEMENT)
} }
async getElementById(id) { async getElementById(id) {
const el = await this.driver.wait(until.elementLocated(By.id(id)), waitUntilTime) const el = await this.driver.wait(until.elementLocated(By.id(id)), specconst.TIMEOUT_WAIT_ELEMENT)
return await this.driver.wait(until.elementIsVisible(el), waitUntilTime) return await this.driver.wait(until.elementIsVisible(el), specconst.TIMEOUT_WAIT_ELEMENT)
} }
async getElementByXPath(xpath) { async getElementByXPath(xpath) {
const el = await this.driver.wait( const el = await this.driver.wait(
until.elementLocated(By.xpath(xpath)), until.elementLocated(By.xpath(xpath)),
waitUntilTime specconst.TIMEOUT_WAIT_ELEMENT
) )
return await this.driver.wait(until.elementIsVisible(el), waitUntilTime) return await this.driver.wait(until.elementIsVisible(el), specconst.TIMEOUT_WAIT_ELEMENT)
} }
async inputText(el, data) { async inputText(el, data) {
@ -91,9 +89,9 @@ class WebDriver {
} }
} }
async login(username) { async login(user) {
await this.inputText(ui.SIGN_IN_EMAIL, username); await this.inputText(ui.SIGN_IN_EMAIL, user.username);
await this.inputText(ui.SIGN_IN_PASSWORD, specconst.SIGN_IN_PASSWORD); await this.inputText(ui.SIGN_IN_PASSWORD, user.password);
var singin = await this.getElementByXPath(ui.SIGN_IN_BUTTON); var singin = await this.getElementByXPath(ui.SIGN_IN_BUTTON);
await singin.click(); await singin.click();
await this.waitElelmentIsVisible(ui.SETTTING_BUTTON,specconst.TIMEOUT_PAGE_LOAD); await this.waitElelmentIsVisible(ui.SETTTING_BUTTON,specconst.TIMEOUT_PAGE_LOAD);
@ -198,7 +196,7 @@ class WebDriver {
var el = await this.getElementByXPath(xpath); var el = await this.getElementByXPath(xpath);
await el.click(); await el.click();
var eheader = await this.getElementByXPath(ui.HEADER_MODULE); var eheader = await this.getElementByXPath(ui.HEADER_MODULE);
await this.driver.wait(until.elementIsVisible(eheader), waitUntilTime) await this.driver.wait(until.elementIsVisible(eheader), specconst.TIMEOUT_WAIT_ELEMENT)
} }
async createRoom(usernames, name, description, type) { async createRoom(usernames, name, description, type) {
@ -262,7 +260,7 @@ class WebDriver {
try { try {
const el = await this.driver.wait( const el = await this.driver.wait(
until.elementLocated(By.xpath(xpath)), until.elementLocated(By.xpath(xpath)),
waitUntilTime specconst.TIMEOUT_WAIT_ELEMENT
) )
await this.driver.wait(until.elementIsVisible(el), timeout); await this.driver.wait(until.elementIsVisible(el), timeout);
} }

View File

@ -67,55 +67,6 @@ 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) {
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');
});
}
async verifyLogExported() { async verifyLogExported() {
let expected = false; let expected = false;
let path = await Utils.getFolderPath('Downloads'); let path = await Utils.getFolderPath('Downloads');
@ -178,36 +129,7 @@ class WindowsActions {
} }
await robot.keyTap('enter'); await robot.keyTap('enter');
}); });
} }
async quitApp() {
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');
await robot.keyTap('down');
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 focusWindow() {
await this.app.browserWindow.show();
}
async menuSearch(element, namevalue) { async menuSearch(element, namevalue) {
if (element.name == namevalue) { if (element.name == namevalue) {
@ -224,16 +146,6 @@ class WindowsActions {
return await null; 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) { async actionForMenus(arrMenu) {
await this.app.browserWindow.getBounds().then(async (bounds) => { await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(100); await robot.setMouseDelay(100);
@ -297,22 +209,7 @@ class WindowsActions {
async focusWindow() { async focusWindow() {
this.app.browserWindow.focus(); this.app.browserWindow.focus();
this.app.browserWindow.setAlwaysOnTop(true); this.app.browserWindow.setAlwaysOnTop(true);
} }
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) { async openMenu(arrMenu) {
var arrStep = []; var arrStep = [];
@ -346,7 +243,7 @@ class WindowsActions {
{ {
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(100); 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);
@ -359,7 +256,7 @@ class WindowsActions {
{ {
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(100); 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);
@ -371,41 +268,28 @@ class WindowsActions {
{ {
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(100); 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 verifyNotCloseToastWhenMouseOver() async veriryPersistToastNotification(message)
{ {
await this.mouseMoveNotification();
var i =0; var i =0;
while(i < 11) while(i < 6)
{ {
await Utils.sleep(1); await Utils.sleep(1);
await i++; await i++;
} }
await this.verifyToastNotificationShow(); await this.webAction.verifyToastNotificationShow(message);
await this.mouseMoveCenter();
}
async veriryPersistToastNotification()
{
var i =0;
while(i < 11)
{
await Utils.sleep(1);
await i++;
}
await this.verifyToastNotificationShow();
await this.clickNotification(); await this.clickNotification();
await this.mouseMoveCenter(); await this.mouseMoveCenter();
} }
async veriryNotPersistToastNotification() async verifyNotPersistToastNotification(message)
{ {
var i = 0; var i = 0;
let count =0; let count =0;
@ -415,49 +299,23 @@ class WindowsActions {
await Utils.sleep(1); await Utils.sleep(1);
await i++; await i++;
} }
await this.verifyNotShowToastNotification(); await this.webAction.verifyNoToastNotificationShow(message);
await this.mouseMoveCenter(); await this.mouseMoveCenter();
} }
async verifyToastNotificationShow() { async verifyNotCloseToastWhenMouseOver(message)
let show = false;
for (let i = 0; i < 10; i++) {
var winCount = await this.app.client.getWindowCount();
if (winCount > 1) {
await this.app.client.windowByIndex(1);
if (await this.app.browserWindow.getTitle() === 'Electron') {
show = true;
break;
}
}
await Utils.sleep(1);
}
await expect(show).toBeTruthy();
await this.app.client.windowByIndex(0);
}
async verifyNotShowToastNotification()
{ {
let notshow = true; await this.mouseMoveNotification();
for (let i = 0; i < 10; i++) { var i =0;
var winCount = await this.app.client.getWindowCount(); while(i < 8)
if (winCount == 1) { {
notshow = true; await Utils.sleep(1);
break; await i++;
}
else
{
await this.app.client.windowByIndex(1);
if (await this.app.browserWindow.getTitle() !== 'Electron') {
notshow = true;
break;
}
}
await Utils.sleep(1);
} }
await expect(notshow).toBeTruthy(); await this.webAction.verifyToastNotificationShow(message);
await this.app.client.windowByIndex(0); await this.mouseMoveCenter();
} }
} }
module.exports = WindowsActions; module.exports = WindowsActions;

View File

@ -0,0 +1,84 @@
const Application = require('./spectronSetup');
const WebDriver = require('./spectronWebDriver');
const { isMac } = require('../../js/utils/misc.js');
var app = new Application({
startTimeout: Application.getTimeOut(),
waitTimeout: Application.getTimeOut()
});
var webdriver = new WebDriver({ browser: 'chrome' });
const WindowsAction = require('./spectronWindowsActions');
const WebActions = require('./spectronWebActions');
const specconst = require('./spectronConstants.js');
const Utils = require('./spectronUtils');
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;
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((done) => {
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
app.stop().then(() => {
webdriver.close();
webdriver.quit();
done();
}).catch((err) => {
done();
});
}
});
/**
* Verify toast notification for IMs
* TC-ID: 3395297
* Cover scenarios in AVT-1031
*/
it('Toast notification should not be closed', async () => {
await webdriver.startDriver();
await webdriver.login(specconst.USER_A);
await webdriver.createIM(specconst.USER_B.username);
await webActions.login(specconst.USER_B);
await windowAction.reload();
await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50));
await webActions.clickIfElementVisible(ifc.SETTTING_BUTTON);
await windowAction.pressCtrlM();
await webdriver.clickLeftNavItem(specconst.USER_B.name);
var message = await Utils.randomString();
await webdriver.sendMessages([message]);
await windowAction.verifyNotCloseToastWhenMouseOver(message);
});
/**
* Verify toast notification for signals, mentions and keywords
* TC-ID: 3395306
* Cover scenarios in AVT-1032
*/
it('Verify toast notification for signals, mentions and keywords', async () => {
var nameSignal = await Utils.randomString();
var nameHashTag = await Utils.randomString();
var roomName = await Utils.randomString();
var description =await Utils.randomString();
await webdriver.createSignal(nameSignal,nameHashTag);
await webdriver.createRoom([specconst.USER_B.username],roomName,description,specconst.TYPE_ROOM.public)
await webdriver.clickLeftNavItem(roomName);
await webdriver.sendMessages(["#"+nameHashTag]);
await windowAction.verifyNotCloseToastWhenMouseOver(specconst.USER_A.name+": #"+nameHashTag);
await webdriver.mentionUserOnChat(specconst.USER_B);
await windowAction.verifyNotCloseToastWhenMouseOver(specconst.USER_A.name+": @"+specconst.USER_B.name);
});
}):describe.skip();

View File

@ -48,21 +48,21 @@ let webActions, windowAction;
await webdriver.startDriver(); await webdriver.startDriver();
await webdriver.login(specconst.USER_A); await webdriver.login(specconst.USER_A);
await webdriver.createIM(specconst.USER_B); await webdriver.createIM(specconst.USER_B.username);
await webdriver.sendMessages([Utils.randomString()]);
await webActions.login(specconst.USER_B); await webActions.login(specconst.USER_B);
await windowAction.reload(); await windowAction.reload();
await app.client.waitForVisible(ifc.SETTTING_BUTTON, windowAction.timeOut(50)); await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50));
await webActions.persistToastIM(); await webActions.persistToastIM();
await windowAction.pressCtrlM(); await windowAction.pressCtrlM();
await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); var message = await Utils.randomString();
await windowAction.veriryPersistToastNotification(); await webdriver.sendMessages([message]);
await windowAction.veriryPersistToastNotification(message);
await webdriver.startDriver(); await webdriver.startDriver();
await webdriver.createMIM([specconst.USER_B, specconst.USER_C]); await webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.username]);
await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); await webdriver.sendMessages([message]);
await windowAction.veriryPersistToastNotification(); await windowAction.veriryPersistToastNotification(message);
}) })
/** /**
@ -73,14 +73,15 @@ let webActions, windowAction;
it('Toast notification appears on screen and should disappear in few seconds IM', async () => { it('Toast notification appears on screen and should disappear in few seconds IM', async () => {
await windowAction.showWindow(); await windowAction.showWindow();
await app.client.waitForVisible(ifc.SETTTING_BUTTON, windowAction.timeOut(50)); await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50));
await webActions.persistToastIM(); await webActions.persistToastIM();
await webdriver.clickLeftNavItem(specconst.USER_B.name); await webdriver.clickLeftNavItem(specconst.USER_B.name);
await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); var message = await Utils.randomString();
await windowAction.veriryNotPersistToastNotification(); await webdriver.sendMessages([message]);
await webdriver.createMIM([specconst.USER_B, specconst.USER_C]); await windowAction.verifyNotPersistToastNotification("Electron");
await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); await webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.username]);
await windowAction.veriryNotPersistToastNotification(); await webdriver.sendMessages([message]);
await windowAction.verifyNotPersistToastNotification("Electron");
}) })