diff --git a/tests/spectron/clipboard.spectron.js b/tests/spectron/clipboard.spectron.js index 67327fcb..9a16c166 100644 --- a/tests/spectron/clipboard.spectron.js +++ b/tests/spectron/clipboard.spectron.js @@ -1,20 +1,25 @@ const Application = require('./spectronSetup'); const path = require('path'); - -let app = new Application({}); +const WebActions = require('./spectronWebActions'); +const ifc = require('./spectronInterfaces.js'); +let mainApp = new Application({}); +let app,webActions; describe('Tests for clipboard', () => { let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); - beforeAll((done) => { - return app.startApplication().then((startedApp) => { - app = startedApp; - done(); - }).catch((err) => { + beforeAll(async (done) => { + try { + let testHost = await 'file:///' + path.join(__dirname, '..', '..', 'demo/index.html'); + app = await mainApp.startApplication({testedHost:testHost, alwaysOnTop: false }); + webActions = await new WebActions(app); + webActions.fillTagText("Test") + await done(); + } catch (err) { done.fail(new Error(`Unable to start application error: ${err}`)); - }); + }; }); afterAll((done) => { @@ -28,48 +33,17 @@ describe('Tests for clipboard', () => { } }); - it('should launch the app', (done) => { - return app.client.waitUntilWindowLoaded().then(() => { - return app.client.getWindowCount().then((count) => { - expect(count === 1).toBeTruthy(); - done(); - }).catch((err) => { - done.fail(new Error(`clipboard failed in getWindowCount with error: ${err}`)); - }); - }).catch((err) => { - done.fail(new Error(`clipboard failed in waitUntilWindowLoaded with error: ${err}`)); - }); - }); - - it('should check window count', () => { - return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html')); - }); - - it('should set the username field', () => { - return app.client - .windowByIndex(0) - .setValue('#tag', 'Test') - .getValue('#tag').then((value) => { - expect(value === 'Test').toBeTruthy(); - }); - }); - - it('should verify electron clipboard', () => { - return app.client - .getValue('#tag').then((value) => { - return app.electron.clipboard.writeText(value) - .electron.clipboard.readText().then((clipboardText) => { - expect(clipboardText === 'Test').toBeTruthy(); - }); - }); - }); - - it('should verify electron clipboard copy', () => { - return app.electron.clipboard.writeText('Testing copy') - .electron.clipboard.readText().then((clipboardText) => { - return app.client.setValue('#tag', clipboardText).getValue('#tag').then((value) => { - expect(value === 'Testing copy').toBeTruthy(); - }); - }); - }); + it('should verify electron clipboard', async () => { + let valueTag = await app.client.getValue(ifc.TAG_TEXTBOX); + await app.electron.clipboard.writeText(valueTag); + let clipboardText = await app.electron.clipboard.readText(); + expect(clipboardText === valueTag).toBeTruthy(); + let tempText = "Testing copy"; + await app.electron.clipboard.writeText(tempText); + clipboardText = await app.electron.clipboard.readText(); + await app.client.setValue(ifc.TAG_TEXTBOX, clipboardText); + valueTag = await app.client.getValue(ifc.TAG_TEXTBOX); + expect(clipboardText === valueTag).toBeTruthy(); + + }); }); diff --git a/tests/spectron/close.spectron.js b/tests/spectron/close.spectron.js index 37b647dd..6873dbbb 100644 --- a/tests/spectron/close.spectron.js +++ b/tests/spectron/close.spectron.js @@ -29,12 +29,11 @@ describe('Tests for Close', () => { } }); - it('should close the app', () => { - return app.stop(); - }); - - it('should check whether the app is running', () => { - expect(app.isRunning()).toBe(false); + it('should check whether the app is running', async (done) => { + await app.stop(); + let isRun = await app.isRunning(); + await expect(isRun).toBe(false); + await done(); }); }); diff --git a/tests/spectron/minimize-on-close-icon.spectron.js b/tests/spectron/minimize-on-close-icon.spectron.js index 21337946..a1fd9e70 100644 --- a/tests/spectron/minimize-on-close-icon.spectron.js +++ b/tests/spectron/minimize-on-close-icon.spectron.js @@ -6,8 +6,6 @@ const Utils = require('./spectronUtils'); let mainApp = new Application({}); let app, wActions, config, userConfig; - - describe('Add Test To Verify Minimize on Close', () => { jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000; let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; @@ -45,8 +43,7 @@ describe('Add Test To Verify Minimize on Close', () => { jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; try { if (app && app.isRunning()) { - if (isMac) { - //await wActions.closeChromeDriverOnMac(); + if (isMac) { await app.stop(); } else { @@ -70,33 +67,12 @@ describe('Add Test To Verify Minimize on Close', () => { try { userConfig = await Application.readConfig(config); if (userConfig.minimizeOnClose == false) { - if (!isMac) { - await wActions.openMenu(["Window", "Minimize on Close"]); - await wActions.openMenu(["Window", "Close"]); - - } - else { - - await wActions.openMenuOnMac(["View", "Minimize on Close"]); - await wActions.openMenuOnMac(["Window", "Close"]); - } - - await wActions.verifyMinimizeWindows() + await wActions.openMinimizeAndClose(1, 1); + await wActions.verifyMinimizeWindows(); await done(); } else { - if (!isMac) { - - await wActions.openMenu(["Window", "Minimize on Close"]); - await wActions.openMenu(["Window", "Minimize on Close"]) - await wActions.openMenu(["Window", "Close"]); - } - else { - await wActions.openMenuOnMac(["View", "Minimize on Close"]); - await wActions.openMenuOnMac(["View", "Minimize on Close"]); - await wActions.openMenuOnMac(["Window", "Close"]); - } - + wActions.openMinimizeAndClose(2, 1); await wActions.verifyMinimizeWindows(); await done(); } @@ -117,73 +93,54 @@ describe('Add Test To Verify Minimize on Close', () => { try { await wActions.bringToFront("Symphony"); - - if (!isMac) { - - await wActions.openMenu(["Window", "Minimize on Close"]); - await wActions.openMenu(["Window", "Minimize on Close"]) - await wActions.openMenu(["Window", "Close"]); - } - else { - await wActions.openMenuOnMac(["View", "Minimize on Close"]); - await wActions.openMenuOnMac(["View", "Minimize on Close"]); - await wActions.openMenuOnMac(["Window", "Close"]); - } - - await wActions.verifyMinimizeWindows() + await wActions.openMinimizeAndClose(2, 1); + await wActions.verifyMinimizeWindows(); await wActions.bringToFront("Symphony"); await Utils.sleep(2); if (!isMac) + { await wActions.pressCtrlW(); + } else - await wActions.pressCtrlWOnMac() + { + await wActions.pressCtrlWOnMac(); + } await wActions.verifyMinimizeWindows(); - await done() + await done(); } catch (err) { done.fail(new Error(`Close window when "Minimize on Close" is ON: ${err}`)); }; }); - // /** - // * Verify by deselecting Minimize on Close option once the application is launched - // * TC-ID: 3084612 - // * Cover scenarios in AVT-938 - // */ + /** + * Verify by deselecting Minimize on Close option once the application is launched + * TC-ID: 3084612 + * Cover scenarios in AVT-938 + */ it('Verify by deselecting Minimize on Close option once the application is launched', async (done) => { try { - //userConfig = await Application.readConfig(config); await wActions.bringToFront("Symphony"); - let count = await app.client.getWindowCount(); - if (!isMac) { - await wActions.openMenu(["Window", "Minimize on Close"]); - } - else { - await wActions.openMenuOnMac(["View", "Minimize on Close"]); - } - - if (!isMac) { - await wActions.openMenu(["Window", "Close"]); - } - else { - await wActions.openMenuOnMac(["Window", "Close"]); - } + let count = await app.client.getWindowCount(); + await wActions.openMinimizeAndClose(1, 1); try { - count = await app.client.getWindowCount() + count = await app.client.getWindowCount(); } catch (err1) { count = 0; } - if (!isMac) { - await expect(count === 0).toBeTruthy(); + finally { + if (!isMac) { + await expect(count === 0).toBeTruthy(); + } + else { + await expect(count === 1).toBeTruthy(); + } + await done(); } - else { - await expect(count === 1).toBeTruthy(); - } - await done(); } catch (err) { done.fail(new Error(`should check whether the app is minimized: ${err}`)); }; }) -}); +}) diff --git a/tests/spectron/minimize-on-close.spectron.js b/tests/spectron/minimize-on-close.spectron.js deleted file mode 100644 index dae10376..00000000 --- a/tests/spectron/minimize-on-close.spectron.js +++ /dev/null @@ -1,114 +0,0 @@ -const Application = require('./spectronSetup'); -const { isMac } = require('../../js/utils/misc'); -const robot = require('robotjs'); -const WindowsActions = require('./spectronWindowsActions'); -const Utils = require('./spectronUtils'); -let configPath,wActions,app; -let mainApp = new Application({}); - -!isMac? describe('Tests for Minimize on Close', () => { - - jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); - let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - - beforeAll(async (done) => { - try { - app = await mainApp.startApplication({ alwaysOnTop: false }); - await Utils.sleep(2); - wActions = await new WindowsActions(app); - configPath = await getConfigPath(); - await wActions.focusWindow(); - await done(); - } catch (err) { - done.fail(new Error(`Unable to start application error: ${err}`)); - }; - }); - - function getConfigPath() { - return new Promise(function (resolve, reject) { - app.client.addCommand('getUserDataPath', function () { - return this.execute(function () { - return require('electron').remote.app.getPath('userData'); - }) - }); - app.client.getUserDataPath().then((userConfigPath) => { - resolve(userConfigPath.value) - }).catch((err) => { - reject(err); - }); - }); - } - - afterAll(async (done) => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - try { - if (app && app.isRunning()) { - done(); - wActions.closeChrome(); - } - } catch (error) { - done.fail(new Error(`After all: ${error}`)); - - } - }); - - it('should launch the app', (done) => { - return app.client.waitUntilWindowLoaded().then(() => { - return app.client.getWindowCount().then((count) => { - expect(count === 1).toBeTruthy(); - done(); - }).catch((err) => { - done.fail(new Error(`minimize-on-close failed in getWindowCount with error: ${err}`)); - }); - }).catch((err) => { - done.fail(new Error(`minimize-on-close failed in waitUntilWindowLoaded with error: ${err}`)); - }); - }); - - it('should check window count', (done) => { - return app.client.getWindowCount().then((count) => { - expect(count === 1).toBeTruthy(); - done(); - }).catch((err) => { - done.fail(new Error(`minimize-on-close failed in getWindowCount with error: ${err}`)); - }); - }); - - it('should check browser window visibility', (done) => { - return app.browserWindow.isVisible().then((isVisible) => { - expect(isVisible).toBeTruthy(); - done(); - }).catch((err) => { - done.fail(new Error(`minimize-on-close failed in isVisible with error: ${err}`)); - }); - }); - - it('should bring the app to top', () => { - app.browserWindow.focus(); - return app.browserWindow.setAlwaysOnTop(true).then(() => { - return app.browserWindow.isAlwaysOnTop().then((isOnTop) => { - expect(isOnTop).toBeTruthy(); - }); - }); - }); - - it('should check whether the app is minimized', async(done) => { - try { - let userConfig = await Application.readConfig(configPath); - await wActions.focusWindow(); - await wActions.openMenu(["Window", "Minimize on Close"]); - if (userConfig.minimizeOnClose == false) { - await wActions.openMenu(["Window", "Minimize on Close"]); - } - await wActions.openMenu(["Window", "Close"]) - await Utils.sleep(5); - let status = await wActions.isElectronProcessRunning() ; - await console.log(status); - await expect(status === false).toBeTruthy(); - await done(); - } catch (err) { - done.fail(new Error(`should check whether the app is minimized: ${err}`)); - }; - }); - -}) : describe.skip(); diff --git a/tests/spectron/notificationPosition.spectron.js b/tests/spectron/notificationPosition.spectron.js index ed8bc3cd..f9608734 100644 --- a/tests/spectron/notificationPosition.spectron.js +++ b/tests/spectron/notificationPosition.spectron.js @@ -12,8 +12,8 @@ describe('Tests for Notification position', () => { beforeAll(async (done) => { try { - let testHost = await 'file:///' + path.join(__dirname, '..', '..', 'demo/index.html') - app = await mainApp.startApplication({testedHost:testHost, alwaysOnTop: false }) + let testHost = await 'file:///' + path.join(__dirname, '..', '..', 'demo/index.html'); + app = await mainApp.startApplication({testedHost:testHost, alwaysOnTop: false }); await done(); } catch (err) { done.fail(new Error(`Unable to start application error: ${err}`)); diff --git a/tests/spectron/openACP.spectron.js b/tests/spectron/openACP.spectron.js index b2096099..ae2cf263 100644 --- a/tests/spectron/openACP.spectron.js +++ b/tests/spectron/openACP.spectron.js @@ -1,11 +1,7 @@ const Application = require('./spectronSetup'); -const WebDriver = require('./spectronWebDriver'); const { isMac } = require('../../js/utils/misc.js'); const Utils = require('./spectronUtils'); -var app = new Application({ - startTimeout: 1200000, - waitTimeout: 1200000 -}); +var app = new Application({}); const WindowsAction = require('./spectronWindowsActions'); const WebActions = require('./spectronWebActions'); const ifc = require('./spectronInterfaces.js'); @@ -13,7 +9,8 @@ const specconst = require('./spectronConstants.js'); let webActions, windowAction; !isMac ? describe(' Open ACP inside Electron when clicking on the "Go to AC portal"', () => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = 1200000; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000; + let originalTimeout = Application.getTimeOut(); beforeAll(async (done) => { try { app = await new Application({}).startApplication({ testedHost: specconst.TESTED_HOST, alwaysOnTop: true }); @@ -25,12 +22,16 @@ let webActions, windowAction; }; }); afterAll(async (done) => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; try { if (app && app.isRunning()) { await app.stop(); + await windowAction.closeChromeDriver(); done(); } } catch (err) { + await app.stop(); + await windowAction.closeChromeDriver(); done.fail(new Error(`Failed at post-condition: ${err}`)); }; }); @@ -40,15 +41,18 @@ let webActions, windowAction; * TC-ID: 3308790 * Cover scenarios in AVT-1107 */ - it('The user is directed to the ACP inside Electron and does not login again', async () => { - - await webActions.login(specconst.USER_A); - await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50)); - await windowAction.pressF11(); - await webActions.openACP(); - await webActions.verifyElementExist(ifc.IMG_ADMIN_LOGO); - - + it('The user is directed to the ACP inside Electron and does not login again', async (done) => { + try { + await webActions.login(specconst.USER_A); + await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50)); + await windowAction.pressF11(); + await webActions.openACP(); + await app.client.waitForVisible(ifc.IMG_ADMIN_LOGO, Utils.toMs(20)); + await webActions.verifyElementExist(ifc.IMG_ADMIN_LOGO); + await done(); + } catch (err) { + done.fail(new Error(`Fail to verify open ACP: ${err}`)); + }; }); }) : describe.skip(); diff --git a/tests/spectron/spectronConstants.js b/tests/spectron/spectronConstants.js index 1ac21d22..a4a1c4c9 100644 --- a/tests/spectron/spectronConstants.js +++ b/tests/spectron/spectronConstants.js @@ -11,7 +11,7 @@ module.exports = { "root": { name: "menu", step: 0, items: [ { name: "Edit", step: 0, items: [{ name: "Undo", step: 0 }, { name: "Redo", step: 1 }, { name: "Cut", step: 2 }, { name: "Copy", step: 3 }, { name: "Paste", step: 4 }, { name: "Paste and Match Style", step: 5 }, { name: "Delete", step: 6 }, { name: "Select All", step: 7 }] }, - { name: "View", step: 1, items: [{ name: "Reload", step: 0 }, { name: "Actual Size", step: 1 }, { name: "Zoom In", step: 2 }, { name: "Zoom Out", step: 3 }, { name: "Toogle Full Screen", step: 4 }] }, + { name: "View", step: 1, items: [{ name: "Reload", step: 0 }, { name: "Actual Size", step: 1 }, { name: "Zoom In", step: 2 }, { name: "Zoom Out", step: 3 }, { name: "Toggle Full Screen", step: 4 }] }, { name: "Window", step: 2, items: [{ name: "Minimize", step: 0 }, { name: "Close", step: 1 }, { name: "Auto Launch On Startup", step: 2 }, { name: "Always on Top", step: 3 }, { name: "Minimize on Close", step: 4 }] }, { name: "Help", step: 3, items: [{ name: "Symphony Help", step: 0 }, { name: "Learn More", step: 1 }, { name: "Troubleshooting", step: 2, items: [{ name: "Show Logs in Explorer", step: 0 }] }, { name: "About Symphony", step: 3 }] } ] diff --git a/tests/spectron/spectronInterfaces.js b/tests/spectron/spectronInterfaces.js index a4dcdcac..77ac6942 100644 --- a/tests/spectron/spectronInterfaces.js +++ b/tests/spectron/spectronInterfaces.js @@ -1,7 +1,7 @@ -module.exports= { +module.exports = { // Title bar TITLE_BAR: "#title-bar", - MAXIMIZE_BTN: "#title-bar-maximize-button", + MAXIMIZE_BTN: "#title-bar-maximize-button", MINIMIZE_BTN: "#title-bar-minimize-button", CLOSE_BUTTON: "button#title-bar-close-button", MAIN_MENU_ITEM: "#hamburger-menu-button", @@ -26,7 +26,7 @@ module.exports= { PUBLIC_ROOM_RADIO_BTN: "//form[@class='create-chatroom']//input[@value='PUBLIC']", 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']", + 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()='$$']", CHAT_INPUT_TYPING: "//div[contains(@class,'public-DraftEditor-content')]", SETTTING_BUTTON: "//div[@class='toolbar-settings-text-container']", @@ -57,7 +57,7 @@ module.exports= { HEADER_MODULE_NAME: "//header[contains(@class,'module-header gs-draggable')]//span[contains(@class,'aliasable') and normalize-space()='$$']", CLOSE_MODULE: "//button[contains(@class,'close-module')]", CLOSE_MODULES: "(//button[contains(@class,'close-module')])[$$]", - PIN_CHAT_MODS: "(//button[contains(@class,'pin-view')])[$$]", + PIN_CHAT_MODS: "(//button[contains(@class,'pin-view')])[$$]", //Popin Popout POPOUT_BUTTON: ".enhanced-pop-out", @@ -69,7 +69,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", @@ -91,8 +91,9 @@ module.exports= { INPUT_SEARCH_ENTITIES: "//input[@id='search-entities']", //Symphony Electron API Demo -GET_VERSION_BUTTON: "#get-version", + GET_VERSION_BUTTON: "#get-version", OPEN_WINDOW_BUTTON: "#open-win", - //Symphony Electron API Demo TAG_TEXTBOX: "#tag" + //Symphony Electron API Demo + TAG_TEXTBOX: "#tag" }; diff --git a/tests/spectron/spectronWebActions.js b/tests/spectron/spectronWebActions.js index 1cb0dbd9..e50fb30b 100644 --- a/tests/spectron/spectronWebActions.js +++ b/tests/spectron/spectronWebActions.js @@ -419,21 +419,26 @@ class WebActions { const bluebird = require('bluebird'); const API_VERSION = '2.0.0'; const SEARCH_API_VERSION = '3.0.0'; - + const ELECTRON_VERSION = '3.0.0'; let values = await bluebird.all([ '#api-version', '#container-identifier', '#container-ver', '#build-number', '#search-api-ver' - ]).mapSeries((string) => {return this.app.client.getText(string)}) - + ]).mapSeries((string) => {return this.app.client.getText(string)}); + await console.log(values); await expect(values[ 0 ]).toBe(API_VERSION); await expect(values[ 1 ]).toBe('Electron'); - await expect(values[ 2 ]).toBe(electronVersion); + await expect(values[ 2 ]).toBe(ELECTRON_VERSION); await expect(values[ 3 ]).toBe(buildNumber); await expect(values[ 4 ]).toBe(SEARCH_API_VERSION); } + + async fillTagText(value) + { + await this.inputText(ui.TAG_TEXTBOX,value) + } } module.exports = WebActions; diff --git a/tests/spectron/spectronWindowsActions.js b/tests/spectron/spectronWindowsActions.js index c3088f4c..acaf66e2 100644 --- a/tests/spectron/spectronWindowsActions.js +++ b/tests/spectron/spectronWindowsActions.js @@ -628,6 +628,28 @@ class WindowsActions { } await expect(expected).toBeTruthy(); } + + async openMinimizeAndClose(minimizeTimes,closeTimes) + { + for (let i = 0; i < minimizeTimes; i++) { + if (!isMac) { + await this.openMenu(["Window", "Minimize on Close"]); + } + else + { + await this.openMenuOnMac(["View", "Minimize on Close"]); + } + } + for (let j = 0; j < closeTimes; j++) { + if (!isMac) { + await this.openMenu(["Window", "Close"]); + } + else + { + await this.openMenuOnMac(["Window", "Close"]); + } + } + } } module.exports = WindowsActions; diff --git a/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js b/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js index 0574c663..0ede196f 100644 --- a/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js +++ b/tests/spectron/toastFlashWhenOpenMultiApplication.spectron.js @@ -5,23 +5,25 @@ var app = new Application({ startTimeout: Application.getTimeOut(), waitTimeout: Application.getTimeOut() }); -var webdriver = new WebDriver({ browser: 'chrome' }); +let webdriver,webActions, windowAction; 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(); + jasmine.DEFAULT_TIMEOUT_INTERVAL = specconst.TIMEOUT_TEST_SUITE; let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeAll(async (done) => { try { + webdriver = await new WebDriver({ browser: 'chrome' }) app = await new Application({}).startApplication({ testedHost: specconst.TESTED_HOST, alwaysOnTop: true }); windowAction = await new WindowsAction(app); - webActions = await new WebActions(app); - webdriver.webAction = webActions; + webActions = await new WebActions(app); + webdriver.windowAction = windowAction; + webdriver.webActions = webActions; + await webdriver.startDriver(); done(); } catch (err) { done.fail(new Error(`Unable to start application error: ${err}`)); @@ -45,14 +47,13 @@ let webActions, windowAction; * 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 webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.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 app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50)); await windowAction.pressCtrlM(); await webdriver.clickLeftNavItem(specconst.USER_B.name); let messages = []; diff --git a/tests/spectron/toastMouseHoveringForIM.spectron.js b/tests/spectron/toastMouseHoveringForIM.spectron.js index c26f591d..d9f8958c 100644 --- a/tests/spectron/toastMouseHoveringForIM.spectron.js +++ b/tests/spectron/toastMouseHoveringForIM.spectron.js @@ -1,17 +1,13 @@ 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' }); +var app = new Application({}); +let webdriver, webActions, windowAction, message; 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', () => { let originalTimeout = specconst.DEFAULT_TIMEOUT_INTERVAL; @@ -19,45 +15,53 @@ let webActions, windowAction; beforeAll(async (done) => { try { + webdriver = await new WebDriver({ browser: 'chrome' }); app = await new Application({}).startApplication({ testedHost: specconst.TESTED_HOST, alwaysOnTop: true }); windowAction = await new WindowsAction(app); - webActions = await new WebActions(app); + webActions = await new WebActions(app); + await webdriver.startDriver(); 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(); + afterAll(async (done) => { + try { + if (app && app.isRunning()) { + jasmine.DEFAULT_TIMEOUT_INTERVAL = await originalTimeout; + await app.stop(); + await webdriver.quit(); done(); - }).catch((err) => { - done(); - }); - } + } + } catch (err) { + done.fail(new Error(`Failed at post-condition: ${err}`)); + }; }); /** * 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); + it('Toast notification should not be closed', async (done) => { + try { + await webdriver.startDriver(); + await webdriver.login(specconst.USER_A); + await webdriver.closeAllGridModules(); + 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(30)); + await webActions.persistToastIM(false); + await windowAction.pressCtrlM(); + await webdriver.clickLeftNavItem(specconst.USER_B.name); + message = await Utils.randomString(); + await webdriver.sendMessages([message]); + await windowAction.verifyNotCloseToastWhenMouseOver(message); + await done(); + } + catch (err) { + done.fail(new Error(`Failed at toast notification should not be closed: ${err}`)); + }; }); /** @@ -65,20 +69,26 @@ let webActions, windowAction; * 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(); + it('Verify toast notification for signals, mentions and keywords', async (done) => { + try { + let nameSignal = await Utils.randomString(); + let nameHashTag = await Utils.randomString(); + let roomName = await Utils.randomString(); + let 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.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); + 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); + await done(); + } + catch (err) { + done.fail(new Error(`Failed at Verify toast notification for signals, mentions and keywords: ${err}`)); + }; }); }) : describe.skip(); diff --git a/tests/spectron/toastNotification.spectron.js b/tests/spectron/toastNotification.spectron.js index ca8e1ce4..11bad46f 100644 --- a/tests/spectron/toastNotification.spectron.js +++ b/tests/spectron/toastNotification.spectron.js @@ -11,6 +11,7 @@ let app, webDriver, webActions, windowsActions; !isMac ? describe('Tests for Toast Notification ', () => { jasmine.DEFAULT_TIMEOUT_INTERVAL = constants.TIMEOUT_TEST_SUITE; + let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeAll(async (done) => { try { @@ -33,6 +34,7 @@ let app, webDriver, webActions, windowsActions; afterAll(async (done) => { try { + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; await windowsActions.stopApp(); await webDriver.quit(); done(); diff --git a/tests/spectron/turnONPersistentToast.spectron.js b/tests/spectron/turnONPersistentToast.spectron.js index 68c28825..ce30c7ad 100644 --- a/tests/spectron/turnONPersistentToast.spectron.js +++ b/tests/spectron/turnONPersistentToast.spectron.js @@ -3,35 +3,39 @@ const WebDriver = require('./spectronWebDriver'); const { isMac } = require('../../js/utils/misc.js'); const Utils = require('./spectronUtils'); var app = new Application({}); -var webdriver = new WebDriver({ browser: 'chrome' }); +let webdriver,webActions, windowAction; const WindowsAction = require('./spectronWindowsActions'); const WebActions = require('./spectronWebActions'); const ifc = require('./spectronInterfaces.js'); const specconst = require('./spectronConstants.js'); -let webActions, windowAction; !isMac ? describe('Verify toast notification when Persist Notification is ON', () => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000; + jasmine.DEFAULT_TIMEOUT_INTERVAL = specconst.TIMEOUT_TEST_SUITE; + let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeAll(async(done) => { try - { + { + webdriver = await new WebDriver({ browser: 'chrome' }); app = await new Application({}).startApplication({testedHost:specconst.TESTED_HOST, alwaysOnTop: true}); windowAction = await new WindowsAction(app); - webActions = await new WebActions(app); + webActions = await new WebActions(app); + await webdriver.startDriver(); + windowAction.webAction = await webActions; done(); } catch(err) { done.fail(new Error(`Unable to start application error: ${err}`)); }; - }); + }) + afterAll(async (done) => { try { if (app && app.isRunning()) { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + jasmine.DEFAULT_TIMEOUT_INTERVAL = await originalTimeout; await app.stop(); - await webdriver.quit(); + await webdriver.quit(); done(); } - } catch (err) { + } catch (err) { done.fail(new Error(`Failed at post-condition: ${err}`)); }; }); @@ -42,23 +46,23 @@ let webActions, windowAction; */ it('Toast notification appears on screen and should stay on the screen IM', async () => { - await webdriver.startDriver(); await webdriver.login(specconst.USER_A); + await webdriver.closeAllGridModules(); 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.persistToastIM(); + await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(30)); + await webActions.persistToastIM(true); await windowAction.pressCtrlM(); - var message = await Utils.randomString(); + message = await Utils.randomString(); await webdriver.sendMessages([message]); - await windowAction.veriryPersistToastNotification(message); - await webdriver.startDriver(); + await windowAction.verifyPersistToastNotification(message); + await windowAction.pressCtrlM(); await webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.username]); await webdriver.sendMessages([message]); - await windowAction.veriryPersistToastNotification(message); + await windowAction.verifyPersistToastNotification(message); }) /** @@ -67,17 +71,17 @@ let webActions, windowAction; * Cover scenarios in AVT-1027 */ it('Toast notification appears on screen and should disappear in few seconds IM', async () => { - - await windowAction.showWindow(); - await app.client.waitForVisible(ifc.SETTTING_BUTTON, Utils.toMs(50)); - await webActions.persistToastIM(); + await windowAction.bringToFront("Symphony"); + await Utils.sleep(5); + await webActions.persistToastIM(false); + await windowAction.pressCtrlM(); await webdriver.clickLeftNavItem(specconst.USER_B.name); - var message = await Utils.randomString(); - await webdriver.sendMessages([message]); - await windowAction.verifyNotPersistToastNotification("Electron"); + message = await Utils.randomString(); + await webdriver.sendMessages([message]); + await windowAction.verifyNotPersistToastNotification(); await webdriver.createMIM([specconst.USER_B.username, specconst.USER_C.username]); await webdriver.sendMessages([message]); - await windowAction.verifyNotPersistToastNotification("Electron"); + await windowAction.verifyNotPersistToastNotification(); })