mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
AVT-1026 [Spectron][Windows] Configure alert position at top/bottom left/right (#466)
* Add test * Updated
This commit is contained in:
committed by
Vishwas Shashidhar
parent
66d1a9f8e7
commit
146db038f0
@@ -60,6 +60,7 @@ module.exports= {
|
||||
|
||||
//Alert Settings
|
||||
MUTE_POPUP_ALERTS_CKB: ".field.field-notifications-on input",
|
||||
ALERT_POSITION: ".field-configure-desktop-alerts button",
|
||||
|
||||
//Toast Message
|
||||
TOAST_MESSAGE_CONTENT: "#message",
|
||||
|
||||
@@ -248,7 +248,7 @@ class WebActions {
|
||||
await this.waitElementNotVisible(ui.SPINNER, constants.TIMEOUT_PAGE_LOAD);
|
||||
}
|
||||
|
||||
async verifyPopInIconDisplay(windowTitle){
|
||||
async verifyPopInIconDisplay(windowTitle) {
|
||||
let windowsActions = await new WindowsActions(this.app);
|
||||
let index = await windowsActions.getWindowIndexFromTitle(windowTitle);
|
||||
await windowsActions.windowByIndex(index);
|
||||
@@ -260,12 +260,12 @@ class WebActions {
|
||||
await this.clickIfElementVisible(ui.INBOX_BUTTON);
|
||||
}
|
||||
|
||||
async clickLeftNavItem(item){
|
||||
let singleItemLocator = ui.LEFT_NAV_SINGLE_ITEM.replace("$$",item);
|
||||
async clickLeftNavItem(item) {
|
||||
let singleItemLocator = ui.LEFT_NAV_SINGLE_ITEM.replace("$$", item);
|
||||
await this.clickIfElementVisible(singleItemLocator);
|
||||
}
|
||||
|
||||
async logout(){
|
||||
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);
|
||||
@@ -285,15 +285,27 @@ class WebActions {
|
||||
|
||||
}
|
||||
|
||||
async sleepAndWaitForLoginForm() {
|
||||
let i = 0;
|
||||
while (i <= 400) {
|
||||
await Utils.sleep(2);
|
||||
i++;
|
||||
}
|
||||
await this.app.client.waitForVisible(ui.SIGN_IN_BUTTON, constants.TIMEOUT_WAIT_ELEMENT);
|
||||
async openNotificationPosition() {
|
||||
await this.clickIfElementVisible(ui.ALERT_POSITION);
|
||||
}
|
||||
|
||||
async adjustNotificationPosition(position) {
|
||||
await this.openNotificationPosition();
|
||||
let windowsActions = await new WindowsActions(this.app);
|
||||
let winCount = await windowsActions.getWindowCount();
|
||||
await windowsActions.windowByIndex(winCount - 1);
|
||||
await this.clickIfElementVisible("#" + position);
|
||||
await this.clickIfElementVisible("#ok-button");
|
||||
await windowsActions.windowByIndex(0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WebActions;
|
||||
|
||||
@@ -31,8 +31,16 @@ class WebDriver {
|
||||
catch (err) {
|
||||
await assert.equal(result, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async waitElelmentIsVisible(xpath, timeout) {
|
||||
const el = await this.driver.wait(
|
||||
until.elementLocated(By.xpath(xpath)),
|
||||
timeout
|
||||
)
|
||||
await this.driver.wait(until.elementIsVisible(el), timeout);
|
||||
}
|
||||
|
||||
async waitElementVisibleAndGet(xpath) {
|
||||
const el = await this.driver.wait(
|
||||
until.elementLocated(By.xpath(xpath)),
|
||||
@@ -80,22 +88,20 @@ class WebDriver {
|
||||
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);
|
||||
await singin.click();
|
||||
await this.waitElelmentIsVisible(ui.SETTTING_BUTTON, specconst.TIMEOUT_PAGE_LOAD);
|
||||
}
|
||||
|
||||
async mentionUserOnChat(user)
|
||||
{
|
||||
await this.inputText(ui.CHAT_INPUT_TYPING, "@"+user.name);
|
||||
var suggestion = ui.MENTION_USER_SUGGESTION.replace("$$",user.name);
|
||||
async mentionUserOnChat(user) {
|
||||
await this.inputText(ui.CHAT_INPUT_TYPING, "@" + user.name);
|
||||
var suggestion = ui.MENTION_USER_SUGGESTION.replace("$$", user.name);
|
||||
var el = await this.getElementByXPath(suggestion);
|
||||
await el.click();
|
||||
await this.sendEnter(ui.CHAT_INPUT_TYPING);
|
||||
await this.sendEnter(ui.CHAT_INPUT_TYPING);
|
||||
}
|
||||
|
||||
async waitSuggestionShowOnlyOneItem(xpath)
|
||||
{
|
||||
if (this.driver.findElements(By.xpath(xpath)).length==1) {
|
||||
async waitSuggestionShowOnlyOneItem(xpath) {
|
||||
if (this.driver.findElements(By.xpath(xpath)).length == 1) {
|
||||
return result = true;
|
||||
}
|
||||
return false;
|
||||
@@ -133,7 +139,7 @@ class WebDriver {
|
||||
await el.click();
|
||||
await this.waitElelmentIsNotVisible(ui.CREATE_IM_DONE_BTN);
|
||||
}
|
||||
|
||||
|
||||
async clickConfirmCreateRoom() {
|
||||
var el = await this.getElementByXPath(ui.CONFIRM_CREATE_ROOM_BUTTON);
|
||||
await el.click();
|
||||
@@ -176,13 +182,13 @@ class WebDriver {
|
||||
async selectPrivateRadioButton() {
|
||||
var el = await this.waitElementVisibleAndGet(ui.PRIVATE_ROOM_RADIO_BTN);
|
||||
await el.click();
|
||||
}
|
||||
}
|
||||
|
||||
async clickLeftNavItem(name) {
|
||||
var xpath = await ui.LEFT_NAV_SINGLE_ITEM.replace("$$", name);
|
||||
var xpath = await ui.LEFT_NAV_SINGLE_ITEM.replace("$$", name);
|
||||
var el = await this.getElementByXPath(xpath);
|
||||
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), specconst.TIMEOUT_WAIT_ELEMENT)
|
||||
}
|
||||
|
||||
@@ -205,12 +211,11 @@ class WebDriver {
|
||||
// await this.clickConfirmCreateRoom();
|
||||
}
|
||||
|
||||
async createSignal(signalName, hashTag)
|
||||
{
|
||||
async createSignal(signalName, hashTag) {
|
||||
await this.clickShowConversationCreationModal();
|
||||
await this.clickCreateSignal();
|
||||
await this.inputText(ui.SIGNAL_NAME,signalName);
|
||||
await this.inputText(ui.LAST_RULE_ROW+ui.ENTER_KEYWORD_IN_LAST_INPUT,hashTag);
|
||||
await this.inputText(ui.SIGNAL_NAME, signalName);
|
||||
await this.inputText(ui.LAST_RULE_ROW + ui.ENTER_KEYWORD_IN_LAST_INPUT, hashTag);
|
||||
await this.clickDoneButton();
|
||||
}
|
||||
|
||||
@@ -242,24 +247,11 @@ class WebDriver {
|
||||
async timeOut(secondSleep) {
|
||||
return secondSleep * 1000;
|
||||
}
|
||||
|
||||
async waitElelmentIsVisible(xpath,timeout) {
|
||||
try {
|
||||
const el = await this.driver.wait(
|
||||
until.elementLocated(By.xpath(xpath)),
|
||||
specconst.TIMEOUT_WAIT_ELEMENT
|
||||
)
|
||||
await this.driver.wait(until.elementIsVisible(el), timeout);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(`Error wait element is visible: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
async quit() {
|
||||
await this.driver.quit();
|
||||
}
|
||||
async close() {
|
||||
async close() {
|
||||
await this.driver.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -509,6 +509,73 @@ class WindowsActions {
|
||||
}
|
||||
await this.windowByIndex(0);
|
||||
}
|
||||
|
||||
async stopApp() {
|
||||
if (this.app && this.app.isRunning()) {
|
||||
await this.app.stop();
|
||||
}
|
||||
}
|
||||
async isAppRunning() {
|
||||
return this.app.isRunning();
|
||||
}
|
||||
|
||||
async getToastNotificationIndex(message) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let 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) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
await Utils.sleep(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
async getToastNotificationPosition(message) {
|
||||
let index = await this.getToastNotificationIndex(message);
|
||||
await this.windowByIndex(index);
|
||||
let currentPosition = await this.getCurrentPosition();
|
||||
await this.windowByIndex(0);
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
async getToastNotificationSize(message) {
|
||||
let index = await this.getToastNotificationIndex(message);
|
||||
await this.windowByIndex(index);
|
||||
let currentSize = await this.getCurrentSize();
|
||||
await this.windowByIndex(0);
|
||||
return currentSize;
|
||||
}
|
||||
|
||||
async verifyToastNotificationPosition(message, expectedPosition) {
|
||||
let screen = await this.app.electron.screen.getPrimaryDisplay();
|
||||
let screenWidth = screen.size.width;
|
||||
let screenHeight = screen.size.height;
|
||||
let currentPosition = await this.getToastNotificationPosition(message);
|
||||
let curentSize = await this.getToastNotificationSize(message);
|
||||
switch (expectedPosition) {
|
||||
case "lower-right":
|
||||
expect(currentPosition[0] + curentSize[0]).toEqual(screenWidth);
|
||||
expect(screenHeight - (currentPosition[1] + curentSize[1])).toBeLessThan(100);
|
||||
break;
|
||||
case "upper-right":
|
||||
expect(currentPosition[0] + curentSize[0]).toEqual(screenWidth);
|
||||
expect(currentPosition[1]).toEqual(0);
|
||||
break;
|
||||
case "upper-left":
|
||||
expect(currentPosition[0]).toEqual(0);
|
||||
expect(currentPosition[1]).toEqual(0);
|
||||
break;
|
||||
case "lower-left":
|
||||
expect(currentPosition[0]).toEqual(0);
|
||||
expect(screenHeight - (currentPosition[1] + curentSize[1])).toBeLessThan(100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WindowsActions;
|
||||
|
||||
@@ -8,14 +8,9 @@ const ui = require('./spectronInterfaces.js');
|
||||
const Utils = require('./spectronUtils');
|
||||
|
||||
let app, webDriver, webActions, windowsActions;
|
||||
app = new Application({
|
||||
startTimeout: Application.getTimeOut(),
|
||||
waitTimeout: Application.getTimeOut()
|
||||
});
|
||||
describe('Tests for Toast Notification ', () => {
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
!isMac ? describe('Tests for Toast Notification ', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = constants.TIMEOUT_TEST_SUITE;
|
||||
|
||||
beforeAll(async (done) => {
|
||||
try {
|
||||
@@ -23,21 +18,27 @@ describe('Tests for Toast Notification ', () => {
|
||||
app = await new Application({}).startApplication({ testedHost: constants.TESTED_HOST, alwaysOnTop: true });
|
||||
webActions = await new WebActions(app);
|
||||
windowsActions = await new WindowsActions(app);
|
||||
await webDriver.startDriver();
|
||||
await webActions.login(constants.USER_A);
|
||||
await windowsActions.bringToFront("Symphony");
|
||||
await windowsActions.reload(); //workaround to show topbar menu
|
||||
await webDriver.login(constants.USER_B);
|
||||
done();
|
||||
} catch (err) {
|
||||
await windowsActions.stopApp();
|
||||
await webDriver.quit();
|
||||
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();
|
||||
}
|
||||
await windowsActions.stopApp();
|
||||
await webDriver.quit();
|
||||
done();
|
||||
} catch (err) {
|
||||
await windowsActions.stopApp();
|
||||
await webDriver.quit();
|
||||
done.fail(new Error(`Failed at post-condition: ${err}`));
|
||||
};
|
||||
});
|
||||
@@ -49,20 +50,14 @@ describe('Tests for Toast Notification ', () => {
|
||||
*/
|
||||
it('Pop-up alert play depends on setting', async (done) => {
|
||||
try {
|
||||
if (isMac) {
|
||||
done();
|
||||
} else {
|
||||
if (await windowsActions.isAppRunning()) {
|
||||
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.createIM(constants.USER_A.name);
|
||||
await webDriver.sendMessages([message1]);
|
||||
await webActions.verifyToastNotificationShow(message1);
|
||||
await Utils.sleep(5); //waitting for toast message disappears
|
||||
@@ -71,10 +66,48 @@ describe('Tests for Toast Notification ', () => {
|
||||
await webActions.checkBox(ui.MUTE_POPUP_ALERTS_CKB, true);
|
||||
await webDriver.sendMessages([message2]);
|
||||
await webActions.verifyNoToastNotificationShow(message2);
|
||||
done();
|
||||
}
|
||||
done();
|
||||
} catch (err) {
|
||||
done.fail(new Error(`Fail to verify pop-up alert play depends on setting: ${err}`));
|
||||
};
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* Verify Configure alert position at top/bottom left/right
|
||||
* TC-ID: 2916213, 2916214, 2916215, 2916216
|
||||
* Cover scenarios in AVT-1026
|
||||
*/
|
||||
it('Configure alert position at top/bottom left/right ', async (done) => {
|
||||
try {
|
||||
if (await windowsActions.isAppRunning()) {
|
||||
let lowerRightMessage = await Utils.randomString();
|
||||
let upperRightMessage = await Utils.randomString();
|
||||
let upperLeftMessage = await Utils.randomString();
|
||||
let lowerLeftMessage = await Utils.randomString();
|
||||
|
||||
await webDriver.createIM(constants.USER_A.name);
|
||||
await webActions.openAlertsSettings();
|
||||
await webActions.checkBox(ui.MUTE_POPUP_ALERTS_CKB, false);
|
||||
await webActions.adjustNotificationPosition("lower-right");
|
||||
await webDriver.sendMessages([lowerRightMessage]);
|
||||
await windowsActions.verifyToastNotificationPosition(lowerRightMessage, "lower-right");
|
||||
|
||||
await webActions.adjustNotificationPosition("upper-right");
|
||||
await webDriver.sendMessages([upperRightMessage]);
|
||||
await windowsActions.verifyToastNotificationPosition(upperRightMessage, "upper-right");
|
||||
|
||||
await webActions.adjustNotificationPosition("upper-left");
|
||||
await webDriver.sendMessages([upperLeftMessage]);
|
||||
await windowsActions.verifyToastNotificationPosition(upperLeftMessage, "upper-left");
|
||||
|
||||
await webActions.adjustNotificationPosition("lower-left");
|
||||
await webDriver.sendMessages([lowerLeftMessage]);
|
||||
await windowsActions.verifyToastNotificationPosition(lowerLeftMessage, "lower-left");
|
||||
}
|
||||
done();
|
||||
} catch (err) {
|
||||
done.fail(new Error(`Fail to configure alert position at top/bottom left/right : ${err}`));
|
||||
};
|
||||
});
|
||||
}) : describe.skip();
|
||||
|
||||
Reference in New Issue
Block a user