diff --git a/tests/spectron/spectronWebActions.js b/tests/spectron/spectronWebActions.js index 66cad5ec..d7d5724c 100644 --- a/tests/spectron/spectronWebActions.js +++ b/tests/spectron/spectronWebActions.js @@ -82,24 +82,6 @@ class WebActions { 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) diff --git a/tests/spectron/spectronWebDriver.js b/tests/spectron/spectronWebDriver.js index 5e6fc98b..6c0ad444 100644 --- a/tests/spectron/spectronWebDriver.js +++ b/tests/spectron/spectronWebDriver.js @@ -31,20 +31,7 @@ class WebDriver { catch (err) { await assert.equal(result, false); } - } - - 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.log("Error:"+err.messages); - } - } + } async waitElementVisibleAndGet(xpath) { const el = await this.driver.wait( @@ -265,7 +252,7 @@ class WebDriver { await this.driver.wait(until.elementIsVisible(el), timeout); } catch (err) { - console.log("Error:"+err.messages); + console.error(`Error wait element is visible: ${err}`); } } @@ -275,5 +262,16 @@ class WebDriver { async close() { await this.driver.close(); } + + async sendMessagesAndVerifyToast(messages) { + for (var i = 0; i < messages.length; i++) { + await this.sendMessage(messages[i]).then(async() => + { + await this.webAction.verifyToastNotificationShow(messages[i]) + }).catch((err) => { + console.error(`Toast notification is not show: ${err}`); + }); + } + } } module.exports = WebDriver; \ No newline at end of file diff --git a/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js b/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js new file mode 100644 index 00000000..0574c663 --- /dev/null +++ b/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js @@ -0,0 +1,67 @@ +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 Flash notification in taskbar option when multiple applications are opened', () => { + 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); + webdriver.webAction = webActions; + 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 Flash notification in taskbar option when multiple applications are opened + * TC-ID: 47308146 + * Cover scenarios in AVT-1083 + */ + it('Verify Flash notification in taskbar option when multiple applications are opened', 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); + let messages = []; + await messages.push(await Utils.randomString()); + await messages.push(await Utils.randomString()); + await messages.push(await Utils.randomString()); + await webdriver.sendMessagesAndVerifyToast(messages); + + }); + +}) : describe.skip(); +