From 2624e706c5fe4aecbc34f1654820889a433dc84c Mon Sep 17 00:00:00 2001 From: tranducanh Date: Wed, 8 Aug 2018 14:30:44 +0700 Subject: [PATCH] AVT-1031 AND AVT-1032: Verify toast notification for IMs, Signal,Room (#448) --- tests/spectron/spectronConstants.js | 8 +- tests/spectron/spectronSetup.js | 2 +- tests/spectron/spectronWebActions.js | 9 +- tests/spectron/spectronWebDriver.js | 30 ++- tests/spectron/spectronWindowsActions.js | 188 +++--------------- .../toastMouseHoveringForIM.spectron.js | 84 ++++++++ .../turnONPersistentToast.spectron.js | 29 +-- 7 files changed, 142 insertions(+), 208 deletions(-) create mode 100644 tests/spectron/toastMouseHoveringForIM.spectron.js diff --git a/tests/spectron/spectronConstants.js b/tests/spectron/spectronConstants.js index ea0f5cea..2c443a17 100644 --- a/tests/spectron/spectronConstants.js +++ b/tests/spectron/spectronConstants.js @@ -1,4 +1,3 @@ -require('dotenv').config() module.exports = { SYMPHONY_CONFIG_FILE_NAME: "/Symphony.config", @@ -20,10 +19,9 @@ module.exports = { }, 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, + USER_A: {username:process.env.USER_A,password:process.env.PASSWORD,name:process.env.USER_A_NAME}, + USER_B: {username:process.env.USER_B,password:process.env.PASSWORD,name:process.env.USER_B_NAME}, + 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_PAGE_LOAD: 120000, diff --git a/tests/spectron/spectronSetup.js b/tests/spectron/spectronSetup.js index f670681c..03545246 100644 --- a/tests/spectron/spectronSetup.js +++ b/tests/spectron/spectronSetup.js @@ -66,7 +66,7 @@ class App { } static getTimeOut() { - return 90000; + return 600000; } static readConfig(configPath) { diff --git a/tests/spectron/spectronWebActions.js b/tests/spectron/spectronWebActions.js index 07460b53..58d58ad8 100644 --- a/tests/spectron/spectronWebActions.js +++ b/tests/spectron/spectronWebActions.js @@ -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) { var i = 0; var y = 0; @@ -123,7 +118,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) { show = true; } @@ -144,7 +139,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; } diff --git a/tests/spectron/spectronWebDriver.js b/tests/spectron/spectronWebDriver.js index 29f8bb12..5e6fc98b 100644 --- a/tests/spectron/spectronWebDriver.js +++ b/tests/spectron/spectronWebDriver.js @@ -5,8 +5,6 @@ var assert = require('assert'); const ui = require('./spectronInterfaces.js'); const specconst = require('./spectronConstants.js'); -const waitUntilTime = 20000; - class WebDriver { constructor(options) { this.options = options; @@ -19,9 +17,9 @@ class WebDriver { try { const el = await this.driver.wait( 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) { result = true; } @@ -39,7 +37,7 @@ class WebDriver { try { const el = await this.driver.wait( until.elementLocated(By.xpath(xpath)), - waitUntilTime + specconst.TIMEOUT_WAIT_ELEMENT ) await this.driver.wait(until.elementIsVisible(el), timeout); } @@ -51,22 +49,22 @@ class WebDriver { async waitElementVisibleAndGet(xpath) { const el = await this.driver.wait( 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) { - const el = await this.driver.wait(until.elementLocated(By.id(id)), waitUntilTime) - return await this.driver.wait(until.elementIsVisible(el), waitUntilTime) + const el = await this.driver.wait(until.elementLocated(By.id(id)), specconst.TIMEOUT_WAIT_ELEMENT) + return await this.driver.wait(until.elementIsVisible(el), specconst.TIMEOUT_WAIT_ELEMENT) } async getElementByXPath(xpath) { const el = await this.driver.wait( 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) { @@ -91,9 +89,9 @@ class WebDriver { } } - async login(username) { - await this.inputText(ui.SIGN_IN_EMAIL, username); - await this.inputText(ui.SIGN_IN_PASSWORD, specconst.SIGN_IN_PASSWORD); + async login(user) { + await this.inputText(ui.SIGN_IN_EMAIL, user.username); + await this.inputText(ui.SIGN_IN_PASSWORD, user.password); var singin = await this.getElementByXPath(ui.SIGN_IN_BUTTON); await singin.click(); await this.waitElelmentIsVisible(ui.SETTTING_BUTTON,specconst.TIMEOUT_PAGE_LOAD); @@ -198,7 +196,7 @@ class WebDriver { var el = await this.getElementByXPath(xpath); await el.click(); 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) { @@ -262,7 +260,7 @@ class WebDriver { try { const el = await this.driver.wait( until.elementLocated(By.xpath(xpath)), - waitUntilTime + specconst.TIMEOUT_WAIT_ELEMENT ) await this.driver.wait(until.elementIsVisible(el), timeout); } diff --git a/tests/spectron/spectronWindowsActions.js b/tests/spectron/spectronWindowsActions.js index afee5391..f84090af 100644 --- a/tests/spectron/spectronWindowsActions.js +++ b/tests/spectron/spectronWindowsActions.js @@ -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() { let expected = false; let path = await Utils.getFolderPath('Downloads'); @@ -178,36 +129,7 @@ class WindowsActions { } 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) { if (element.name == namevalue) { @@ -224,16 +146,6 @@ class WindowsActions { 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); @@ -297,22 +209,7 @@ class WindowsActions { async focusWindow() { this.app.browserWindow.focus(); 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) { var arrStep = []; @@ -346,7 +243,7 @@ class WindowsActions { { let screen = await this.app.electron.screen.getAllDisplays(); await this.app.browserWindow.getBounds().then(async (bounds) => { - await robot.setMouseDelay(100); + await robot.setMouseDelay(50); let x = screen[0].bounds.width-50; let y = screen[0].bounds.height - 100; await robot.moveMouseSmooth(x, y); @@ -359,7 +256,7 @@ class WindowsActions { { let screen = await this.app.electron.screen.getAllDisplays(); await this.app.browserWindow.getBounds().then(async (bounds) => { - await robot.setMouseDelay(100); + await robot.setMouseDelay(50); let x = screen[0].bounds.width-50; let y = screen[0].bounds.height - 100; await robot.moveMouseSmooth(x, y); @@ -371,41 +268,28 @@ class WindowsActions { { let screen = await this.app.electron.screen.getAllDisplays(); await this.app.browserWindow.getBounds().then(async (bounds) => { - await robot.setMouseDelay(100); + 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 verifyNotCloseToastWhenMouseOver() + async veriryPersistToastNotification(message) { - await this.mouseMoveNotification(); var i =0; - while(i < 11) + while(i < 6) { await Utils.sleep(1); await i++; } - await this.verifyToastNotificationShow(); - await this.mouseMoveCenter(); - } - - async veriryPersistToastNotification() - { - var i =0; - while(i < 11) - { - await Utils.sleep(1); - await i++; - } - await this.verifyToastNotificationShow(); + await this.webAction.verifyToastNotificationShow(message); await this.clickNotification(); await this.mouseMoveCenter(); } - async veriryNotPersistToastNotification() + async verifyNotPersistToastNotification(message) { var i = 0; let count =0; @@ -415,49 +299,23 @@ class WindowsActions { await Utils.sleep(1); await i++; } - await this.verifyNotShowToastNotification(); + await this.webAction.verifyNoToastNotificationShow(message); await this.mouseMoveCenter(); - } + } - async verifyToastNotificationShow() { - 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() + async verifyNotCloseToastWhenMouseOver(message) { - let notshow = true; - for (let i = 0; i < 10; i++) { - var winCount = await this.app.client.getWindowCount(); - if (winCount == 1) { - notshow = true; - break; - } - else - { - await this.app.client.windowByIndex(1); - if (await this.app.browserWindow.getTitle() !== 'Electron') { - notshow = true; - break; - } - } - await Utils.sleep(1); + await this.mouseMoveNotification(); + var i =0; + while(i < 8) + { + await Utils.sleep(1); + await i++; } - await expect(notshow).toBeTruthy(); - await this.app.client.windowByIndex(0); - } + await this.webAction.verifyToastNotificationShow(message); + await this.mouseMoveCenter(); + } + } module.exports = WindowsActions; \ No newline at end of file diff --git a/tests/spectron/toastMouseHoveringForIM.spectron.js b/tests/spectron/toastMouseHoveringForIM.spectron.js new file mode 100644 index 00000000..5f138611 --- /dev/null +++ b/tests/spectron/toastMouseHoveringForIM.spectron.js @@ -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(); diff --git a/tests/spectron/turnONPersistentToast.spectron.js b/tests/spectron/turnONPersistentToast.spectron.js index 2df538b2..0e8bb0a0 100644 --- a/tests/spectron/turnONPersistentToast.spectron.js +++ b/tests/spectron/turnONPersistentToast.spectron.js @@ -48,21 +48,21 @@ let webActions, windowAction; await webdriver.startDriver(); await webdriver.login(specconst.USER_A); - await webdriver.createIM(specconst.USER_B); - await webdriver.sendMessages([Utils.randomString()]); + await webdriver.createIM(specconst.USER_B.username); await webActions.login(specconst.USER_B); 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 windowAction.pressCtrlM(); - await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); - await windowAction.veriryPersistToastNotification(); + var message = await Utils.randomString(); + await webdriver.sendMessages([message]); + await windowAction.veriryPersistToastNotification(message); await webdriver.startDriver(); - await webdriver.createMIM([specconst.USER_B, specconst.USER_C]); - await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); - await windowAction.veriryPersistToastNotification(); + await webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.username]); + await webdriver.sendMessages([message]); + 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 () => { 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 webdriver.clickLeftNavItem(specconst.USER_B.name); - await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); - await windowAction.veriryNotPersistToastNotification(); - await webdriver.createMIM([specconst.USER_B, specconst.USER_C]); - await webdriver.sendMessages([Utils.randomString(),Utils.randomString()]); - await windowAction.veriryNotPersistToastNotification(); + var message = await Utils.randomString(); + await webdriver.sendMessages([message]); + await windowAction.verifyNotPersistToastNotification("Electron"); + await webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.username]); + await webdriver.sendMessages([message]); + await windowAction.verifyNotPersistToastNotification("Electron"); })