diff --git a/.gitignore b/.gitignore index 48aea4af..23326089 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /rethinkdb_data/ /temp /tmp +/res/test_out/* diff --git a/res/app/device-list/device-column-service.js b/res/app/device-list/device-column-service.js index 6f3a5cb6..a8dd6005 100644 --- a/res/app/device-list/device-column-service.js +++ b/res/app/device-list/device-column-service.js @@ -451,31 +451,51 @@ function DeviceStatusCell(options) { var a = td.firstChild , t = a.firstChild , classes = 'btn btn-xs device-status ' - switch (device.state) { - case 'using': - a.className = classes + 'btn-primary' - break - case 'busy': - a.className = classes + 'btn-warning' - break - case 'available': - case 'ready': - case 'present': - a.className = classes + 'btn-primary-outline' - break - case 'preparing': - a.className = classes + 'btn-primary-outline btn-success-outline' - break - case 'unauthorized': - a.className = classes + 'btn-danger-outline' - break - case 'offline': - a.className = classes + 'btn-warning-outline' - break - default: - a.className = classes + 'btn-default-outline' - break + + function getStateClasses(state) { + var stateClasses = { + using: 'state-using btn-primary', + busy: 'state-busy btn-warning', + available: 'state-available btn-primary-outline', + ready: 'state-ready btn-primary-outline', + present: 'state-present btn-primary-outline', + preparing: 'state-preparing btn-primary-outline btn-success-outline', + unauthorized: 'state-unauthorized btn-danger-outline', + offline: 'state-offline btn-warning-outline' + }[state] + if (typeof stateClasses === 'undefined') { + stateClasses = 'btn-default-outline' + } + return stateClasses } + + a.className = classes + getStateClasses(device.state) + + //switch (device.state) { + //case 'using': + // a.className = classes + 'btn-primary' + // break + //case 'busy': + // a.className = classes + 'btn-warning' + // break + //case 'available': + //case 'ready': + //case 'present': + // a.className = classes + 'btn-primary-outline' + // break + //case 'preparing': + // a.className = classes + 'btn-primary-outline btn-success-outline' + // break + //case 'unauthorized': + // a.className = classes + 'btn-danger-outline' + // break + //case 'offline': + // a.className = classes + 'btn-warning-outline' + // break + //default: + // a.className = classes + 'btn-default-outline' + // break + //} if (device.usable && !device.using) { a.href = '#!/control/' + device.serial } diff --git a/res/app/device-list/device-list-icons-directive.js b/res/app/device-list/device-list-icons-directive.js index 3459ce92..6fc95df7 100644 --- a/res/app/device-list/device-list-icons-directive.js +++ b/res/app/device-list/device-list-icons-directive.js @@ -56,32 +56,25 @@ module.exports = function DeviceListDetailsDirective( // button at.nodeValue = $filter('translate')(device.enhancedStateAction) - switch (device.state) { - case 'using': - button.className = classes + 'btn-primary' - break - case 'busy': - button.className = classes + 'btn-warning' - break - case 'available': - case 'ready': - case 'present': - button.className = classes + 'btn-primary-outline' - break - case 'preparing': - button.className = classes + 'btn-primary-outline btn-success-outline' - break - case 'unauthorized': - button.className = classes + 'btn-danger-outline' - break - case 'offline': - button.className = classes + 'btn-warning-outline' - break - default: - button.className = classes + 'btn-default-outline' - break + function getStateClasses(state) { + var stateClasses = { + using: 'state-using btn-primary', + busy: 'state-busy btn-warning', + available: 'state-available btn-primary-outline', + ready: 'state-ready btn-primary-outline', + present: 'state-present btn-primary-outline', + preparing: 'state-preparing btn-primary-outline btn-success-outline', + unauthorized: 'state-unauthorized btn-danger-outline', + offline: 'state-offline btn-warning-outline' + }[state] + if (typeof stateClasses === 'undefined') { + stateClasses = 'btn-default-outline' + } + return stateClasses } + button.className = classes + getStateClasses(device.state) + if (device.usable) { a.href = '#!/control/' + device.serial li.classList.remove('device-is-busy') diff --git a/res/test/e2e/control/control-spec.js b/res/test/e2e/control/control-spec.js index 7ee7a534..97dd2110 100644 --- a/res/test/e2e/control/control-spec.js +++ b/res/test/e2e/control/control-spec.js @@ -22,17 +22,9 @@ describe('Control Page', function () { it('should control an usable device', function () { deviceListPage.controlAvailableDevice() - browser.waitUrl(/control/) + waitUrl(/control/) - //browser.debugger(); - //console.log('after') - - - //browser.driver.wait(function () { - // return browser.driver.getCurrentUrl().then(function (url) { - // return /control/.test(url) - // }) - //}) + browser.sleep(1000) browser.getLocationAbsUrl().then(function (newUrl) { expect(newUrl).toMatch(protractor.getInstance().baseUrl + 'control') @@ -43,51 +35,108 @@ describe('Control Page', function () { expect(controlPage.kickDeviceButton, true) }) - - describe('Dashboard', function () { - var DashboardTab = function () { - this.shellInput = element(by.model('command')) - this.shellResults = element.all(by.css('.shell-results')).first() - - this.helloString = 'hello adb' - this.echoCommand = 'echo "' + this.helloString + '"' - this.clearCommand = 'clear' - this.openMenuCommand = 'input keyevent 3' - - this.shellExecute = function (command) { - this.shellInput.sendKeys(command) - this.shellInput.sendKeys(protractor.Key.ENTER) - } + describe('Remote Control', function () { + var RemoteCtrl = function () { + this.paneHandleHorizontal = element(by.css('.fa-pane-handle.horizontal')) } - var dashboardTab = new DashboardTab() + it('should resize panel to the right', function () { - describe('Shell', function () { - - it('should echo "hello adb" to the adb shell', function () { - expect(dashboardTab.shellInput.isPresent()).toBe(true) - - dashboardTab.shellExecute(dashboardTab.echoCommand) - - expect(dashboardTab.shellResults.getText()).toBe(dashboardTab.helloString) - }) - - it('should clear adb shell input', function () { - dashboardTab.shellExecute(dashboardTab.clearCommand) - expect(dashboardTab.shellResults.getText()).toBeFalsy() - }) - - it('should open and close the menu button trough adb shell', function () { - dashboardTab.shellExecute(dashboardTab.openMenuCommand) - dashboardTab.shellExecute(dashboardTab.openMenuCommand) - }) + }) + it('should rotate device', function () { }) }) + describe('Dashboard Tab', function () { + + describe('Shell', function () { + var ShellCtrl = function () { + this.commandInput = element(by.model('command')) + this.results = element.all(by.css('.shell-results')).first() + + this.helloString = 'hello adb' + this.echoCommand = 'echo "' + this.helloString + '"' + this.clearCommand = 'clear' + this.openMenuCommand = 'input keyevent 3' + + this.execute = function (command) { + this.commandInput.sendKeys(command, protractor.Key.ENTER) + } + } + var shell = new ShellCtrl() + + it('should echo "hello adb" to the adb shell', function () { + expect(shell.commandInput.isPresent()).toBe(true) + + shell.execute(shell.echoCommand) + + expect(shell.results.getText()).toBe(shell.helloString) + }) + + it('should clear adb shell input', function () { + shell.execute(shell.clearCommand) + expect(shell.results.getText()).toBeFalsy() + }) + + it('should open and close the menu button trough adb shell', function () { + shell.execute(shell.openMenuCommand) + shell.execute(shell.openMenuCommand) + }) + + }) + + describe('Navigation', function () { + var NavigationCtrl = function () { + this.urlInput = element(by.model('textURL')) + this.goToUrl = function (url) { + this.urlInput.sendKeys(url, protractor.Key.ENTER) + } + this.resetButton = element(by.css('[ng-click="clearSettings()"]')) + } + var navigation = new NavigationCtrl() + + it('should go to an URL', function () { + var url = 'google.com' + navigation.goToUrl(url) + expect(navigation.urlInput.getAttribute('value')).toBe(url) + + browser.sleep(1000) + }) + + it('should clear the URL input', function () { + navigation.urlInput.clear() + expect(navigation.urlInput.getAttribute('value')).toBeFalsy() + }) + + it('should reset browser settings', function () { + navigation.resetButton.click() + }) + }) + + }) + + describe('Screenshots Tab', function () { + + }) + + describe('Automation Tab', function () { + + }) + + describe('Advanced Tab', function () { + + }) + + describe('Logs Tab', function () { + + }) + it('should stop controlling an usable device', function () { controlPage.kickDevice() + waitUrl(/devices/) + browser.getLocationAbsUrl().then(function (newUrl) { expect(newUrl).toBe(protractor.getInstance().baseUrl + 'devices') }) diff --git a/res/test/e2e/devices/devices-spec.js b/res/test/e2e/devices/devices-spec.js index 5a277fd8..41162508 100644 --- a/res/test/e2e/devices/devices-spec.js +++ b/res/test/e2e/devices/devices-spec.js @@ -1,8 +1,7 @@ describe('Device Page', function () { describe('Icon View', function () { - var DeviceListPage = require('./') - var deviceListPage = new DeviceListPage() + var deviceListPage = require('./') it('should go to Devices List page', function () { deviceListPage.get() @@ -25,7 +24,7 @@ describe('Device Page', function () { }) it('should have one device usable', function () { - expect(deviceListPage.availableDevice().getText()).toBe('Use') + expect(deviceListPage.availableDevice().getAttribute('class')).toMatch('state-available') }) }) diff --git a/res/test/e2e/devices/index.js b/res/test/e2e/devices/index.js index 06c71445..ee4db7b2 100644 --- a/res/test/e2e/devices/index.js +++ b/res/test/e2e/devices/index.js @@ -1,12 +1,11 @@ -module.exports = function DeviceListPage() { +function DeviceListPage() { this.get = function () { // TODO: Let's get rid off the login first browser.get(protractor.getInstance().baseUrl + 'devices') } this.devices = element(by.model('tracker.devices')) this.devicesByCss = element.all(by.css('ul.devices-icon-view > li')) - this.devicesUsable = - element.all(by.css('button.device-status.btn-primary-outline')) + this.devicesUsable = element.all(by.css('.state-available')) this.searchInput = element(by.model('search.deviceFilter')) this.filterAvailableDevices = function () { return this.searchInput.sendKeys('state: "available"') @@ -21,3 +20,5 @@ module.exports = function DeviceListPage() { return this.availableDevice().click() } } + +module.exports = new DeviceListPage() diff --git a/res/test/e2e/login/index.js b/res/test/e2e/login/index.js index 63016534..52e082c8 100644 --- a/res/test/e2e/login/index.js +++ b/res/test/e2e/login/index.js @@ -1,4 +1,4 @@ -module.exports = function LoginPage() { +function LoginPage() { this.login = protractor.getInstance().params.login this.get = function () { @@ -49,3 +49,5 @@ module.exports = function LoginPage() { this.email = null } } + +module.exports = new LoginPage() diff --git a/res/test/e2e/login/login-spec.js b/res/test/e2e/login/login-spec.js index 778022e7..f0395f67 100644 --- a/res/test/e2e/login/login-spec.js +++ b/res/test/e2e/login/login-spec.js @@ -1,6 +1,5 @@ describe('Login Page', function () { - var LoginPage = require('./') - var loginPage = new LoginPage() + var loginPage = require('./') it('should have an url to login', function () { expect(loginPage.login.url).toMatch('http') diff --git a/res/test/protractor-multi.conf.js b/res/test/protractor-multi.conf.js index 8b1b27ff..4b39bab4 100644 --- a/res/test/protractor-multi.conf.js +++ b/res/test/protractor-multi.conf.js @@ -6,12 +6,12 @@ var WaitUrl = require('./e2e/helpers/wait-url') config.chromeOnly = false config.capabilities = null config.multiCapabilities = [ - //{ - // browserName: 'chrome', - // chromeOptions: { - // args: ['--test-type'] // Prevent security warning bug in ChromeDriver - // } - //}, + { + browserName: 'chrome', + chromeOptions: { + args: ['--test-type'] // Prevent security warning bug in ChromeDriver + } + }, { browserName: 'firefox' } @@ -21,17 +21,17 @@ config.multiCapabilities = [ // add appium/sauce labs ] -config.onPrepare = function () { - var loginPage = new LoginPage() - loginPage.doLogin() - loginPage.cleanUp() - - var waitUrl = WaitUrl - - jasmine.getEnv().addReporter(new HtmlReporter({ - baseDirectory: './res/test/test_out/screenshots' - })) -} +//config.onPrepare = function () { +// var loginPage = new LoginPage() +// loginPage.doLogin() +// loginPage.cleanUp() +// +// this.waitUrl = WaitUrl +// +// jasmine.getEnv().addReporter(new HtmlReporter({ +// baseDirectory: './res/test/test_out/screenshots' +// })) +//} exports.config = config diff --git a/res/test/protractor.conf.js b/res/test/protractor.conf.js index 3b221016..7548a7d9 100644 --- a/res/test/protractor.conf.js +++ b/res/test/protractor.conf.js @@ -43,16 +43,15 @@ exports.config = { loginPage.doLogin() loginPage.cleanUp() - waitUrl = WaitUrl + this.waitUrl = WaitUrl - - //jasmine.getEnv().addReporter(new HtmlReporter({ - // baseDirectory: './res/test/test_out/screenshots' - //})) + jasmine.getEnv().addReporter(new HtmlReporter({ + baseDirectory: './res/test/test_out/screenshots' + })) afterEach(function () { BrowserLogs({expectNoLogs: true}) - FailFast() + //FailFast() }) }, onComplete: function () {