From 39d0ce00153de2f774eb48cae051b9e22a8ffddd Mon Sep 17 00:00:00 2001 From: Tran Duc Anh Date: Mon, 10 Sep 2018 11:28:35 +0700 Subject: [PATCH] resolve conflict --- tests/spectron/bringToFront.spectron.js | 137 ++++++----------------- tests/spectron/close.spectron.js | 31 ----- tests/spectron/spectronConstants.js | 12 +- tests/spectron/spectronInterfaces.js | 5 +- tests/spectron/spectronWindowsActions.js | 29 +++-- 5 files changed, 68 insertions(+), 146 deletions(-) diff --git a/tests/spectron/bringToFront.spectron.js b/tests/spectron/bringToFront.spectron.js index 4bfe064d..a2167f0d 100644 --- a/tests/spectron/bringToFront.spectron.js +++ b/tests/spectron/bringToFront.spectron.js @@ -1,118 +1,55 @@ const Application = require('./spectronSetup'); -const bluebird = require('bluebird'); -const { isMac, isWindowsOS } = require('../../js/utils/misc'); -const robot = require('robotjs'); - +const specconst = require('./spectronConstants.js'); +const WindowsAction = require('./spectronWindowsActions'); +let windowAction; let app = new Application({}); -function blurBrowserWindow() { - robot.setMouseDelay(200); - robot.moveMouse(0, 100); - robot.mouseClick(); -} - describe('Tests for Bring to front', () => { - let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); - - beforeAll((done) => { - return app.startApplication().then((startedApp) => { - app = startedApp; + beforeAll(async (done) => { + try { + app = await new Application({}).startApplication({ testedHost: specconst.TESTED_HOST, alwaysOnTop: true }); + windowAction = await new WindowsAction(app); done(); - }).catch((err) => { + } 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(() => { + afterAll(async (done) => { + try { + if (app && app.isRunning()) { + jasmine.DEFAULT_TIMEOUT_INTERVAL = await originalTimeout; + await app.stop(); + await webdriver.quit(); done(); - }).catch((err) => { - done(); - }); - } - }); - - it('should launch the app and verify window count', (done) => { - return app.client.waitUntilWindowLoaded().then(() => { - return app.client.getWindowCount().then((count) => { - expect(count === 1).toBeTruthy(); - done(); - }).catch((err) => { - done.fail(new Error(`bringToFront failed in getWindowCount with error: ${err}`)); - }); - }).catch((err) => { - done.fail(new Error(`bringToFront failed in waitUntilWindowLoaded with error: ${err}`)); - }); - }); - - it('should minimize the app and verify if the window isMinimized', (done) => { - return app.browserWindow.minimize().then(() => { - return app.browserWindow.isMinimized().then((isMinimized) => { - expect(isMinimized).toBeTruthy(); - done(); - }).catch((err) => { - done.fail(new Error(`bringToFront failed in isMinimized with error: ${err}`)); - }); - }); - }); - - it('should restore the browser window and verify window focus', (done) => { - bluebird.all([ - blurBrowserWindow, - app.browserWindow.restore, - app.browserWindow.isMinimized, - app.browserWindow.isFocused, - ]).mapSeries((method) => { - return method(); - }).then((results) => { - if (isMac) { - expect(results[2]).toBe(false); - expect(results[3]).toBe(false); } - - if (isWindowsOS) { - expect(results[2]).toBe(false); - expect(results[3]).toBe(true); - } - done(); - }).catch((err) => { - done.fail(new Error(`bringToFront failed to restore with error: ${err}`)); - }); + } catch (err) { + done.fail(new Error(`Failed at post-condition: ${err}`)); + }; }); - it('should minimize and verify if the window isMinimized again', function () { - return app.browserWindow.minimize().then(() => { - return app.browserWindow.isMinimized().then((isMinimized) => { - expect(isMinimized).toBeTruthy(); - }).catch((err) => { - done.fail(new Error(`bringToFront failed to minimize with error: ${err}`)); - }); - }); + it('should show the browser window and verify window focus', async (done) => { + await windowAction.blurBrowserWindow() + await app.browserWindow.minimize(); + let isMinimized = await app.browserWindow.isMinimized(); + await expect(isMinimized).toBe(true); + await app.browserWindow.showInactive(); + let isFocused = await app.browserWindow.isFocused(); + await expect(isFocused).toBe(false); + done(); }); - it('should show the browser window and verify window focus', (done) => { - bluebird.all([ - blurBrowserWindow, - app.browserWindow.showInactive, - app.browserWindow.isFocused - ]).mapSeries((method) => { - return method(); - }).then((results) => { - if (isMac) { - expect(results[2]).toBe(false); - } - - if (isWindowsOS) { - expect(results[2]).toBe(true); - } - done(); - }).catch((err) => { - done.fail(new Error(`bringToFront failed to focus with error: ${err}`)); - }); + it('should restore the browser window and verify window focus', async (done) => { + await windowAction.blurBrowserWindow() + await app.browserWindow.minimize(); + let isMinimized = await app.browserWindow.isMinimized(); + await expect(isMinimized).toBe(true); + await app.browserWindow.restore(); + let isFocused = await app.browserWindow.isFocused(); + await expect(isFocused).toBe(true); + done(); }); -}); \ No newline at end of file +}); diff --git a/tests/spectron/close.spectron.js b/tests/spectron/close.spectron.js index ca49ee58..37b647dd 100644 --- a/tests/spectron/close.spectron.js +++ b/tests/spectron/close.spectron.js @@ -29,37 +29,6 @@ describe('Tests for Close', () => { } }); - 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(`close failed in getWindowCount with error: ${err}`)); - }); - }).catch((err) => { - done.fail(new Error(`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(`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(`close failed in isVisible with error: ${err}`)); - }); - }); - it('should close the app', () => { return app.stop(); }); diff --git a/tests/spectron/spectronConstants.js b/tests/spectron/spectronConstants.js index 552928f7..dbe91eaa 100644 --- a/tests/spectron/spectronConstants.js +++ b/tests/spectron/spectronConstants.js @@ -17,7 +17,17 @@ module.exports = { ] } }, - + MENUMAC: { + "root": { + name: "menu", step: 0, items: [ + { name: "Electron", step: 0, items: [{ name: "About Symphony", step: 0 }, { name: "Services", step: 1 }]}, + { name: "Edit", step: 1, 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: 2, 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: "Minimize on Close", step: 8 }] }, + { name: "Window", step: 3, items: [{ name: "Close", step: 0 }, { name: "Minimize", step: 1 }, { name: "Zoom", step: 2 }]}, + { name: "Help", step: 4, 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 }] } + ] + } + }, LOG_FILENAME_PREFIX: "logs_symphony_", 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 }, diff --git a/tests/spectron/spectronInterfaces.js b/tests/spectron/spectronInterfaces.js index b321f46c..4b91f5e8 100644 --- a/tests/spectron/spectronInterfaces.js +++ b/tests/spectron/spectronInterfaces.js @@ -6,6 +6,7 @@ module.exports= { CLOSE_BUTTON: "button#title-bar-close-button", MAIN_MENU_ITEM: "#hamburger-menu-button", SYM_LOGO: "#logo", + MINIMIZE_BTN: "#title-bar-minimize-button", //Sign In SIGN_IN_BUTTON: "//button[@name='signin-submit']", @@ -56,6 +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')])[$$]", //Popin Popout POPOUT_BUTTON: ".enhanced-pop-out", @@ -76,7 +78,7 @@ module.exports= { INBOX_HEADER: ".inbox-header", //ACP - ACP_LINK: "//button[@class='show-admin-link left-action button-reset']", + ACP_LINK: "//*[contains(@class,'show-admin-link')]", IMG_ADMIN_LOGO: "//img[@src='./img/nav_admin_logo.png']", //LOG OUT @@ -91,4 +93,3 @@ module.exports= { //Symphony Electron API Demo TAG_TEXTBOX: "#tag" }; - diff --git a/tests/spectron/spectronWindowsActions.js b/tests/spectron/spectronWindowsActions.js index a86308a5..981d325c 100644 --- a/tests/spectron/spectronWindowsActions.js +++ b/tests/spectron/spectronWindowsActions.js @@ -87,10 +87,13 @@ class WindowsActions { await robot.mouseClick(); } - async verifyWindowsOnTop() { - let isAlwaysOnTop = await this.app.browserWindow.isAlwaysOnTop(); - await expect(isAlwaysOnTop === true).toBeTruthy(); - + async verifyWindowsOnTop(value) { + let isAlwaysOnTop = await this.app.browserWindow.isAlwaysOnTop(); + if (value) { + await expect(isAlwaysOnTop).toBeTruthy(); + } else { + await expect(isAlwaysOnTop).toBeFalsy(); + } } async menuSearch(element, namevalue) { @@ -155,17 +158,14 @@ class WindowsActions { } async actionForMenusOnMac(arrMenu) { - let webAction = await new WebActions(this.app); - //await this.app.browserWindow.getBounds().then(async (bounds) => { + let webAction = await new WebActions(this.app); await robot.setMouseDelay(2000); let x = 5; let y = 5; await robot.moveMouseSmooth(x, y); await robot.moveMouse(x, y); - await robot.mouseClick(); - //await webAction.openApplicationMenuByClick(); - await robot.setKeyboardDelay(100); - + await robot.mouseClick(); + await robot.setKeyboardDelay(100); for (var i = 0; i < arrMenu.length; i++) { if (i==0) { @@ -186,8 +186,7 @@ class WindowsActions { await robot.keyTap('right'); } } - await robot.keyTap('enter'); - //}); + await robot.keyTap('enter'); } async verifyLogExported() { @@ -588,6 +587,12 @@ class WindowsActions { } await robot.keyTap('enter'); } + + async blurBrowserWindow() { + await robot.setMouseDelay(200); + await robot.moveMouse(0, 100); + await robot.mouseClick(); + } } module.exports = WindowsActions;