Mercurial > hg > thermostat-ng > web-client
changeset 197:ed977dff0ba2
Fix itest login helper and basic launch integration test
Reviewed-by: jkang
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/024943.html
author | Andrew Azores <aazores@redhat.com> |
---|---|
date | Tue, 12 Sep 2017 14:23:58 -0400 |
parents | a9b83aee75b0 |
children | 90e9e14c8a29 |
files | integration-test/login-helper.js integration-test/specs/launch.spec.js src/app/index.html |
diffstat | 3 files changed, 91 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/integration-test/login-helper.js Tue Sep 12 12:20:37 2017 -0400 +++ b/integration-test/login-helper.js Tue Sep 12 14:23:58 2017 -0400 @@ -1,31 +1,70 @@ -module.exports = function () { - var EC = protractor.ExpectedConditions; +/** + * Copyright 2012-2017 Red Hat, Inc. + * + * Thermostat is distributed under the GNU General Public License, + * version 2 or any later version (with a special exception described + * below, commonly known as the "Classpath Exception"). + * + * A copy of GNU General Public License (GPL) is included in this + * distribution, in the file COPYING. + * + * Linking Thermostat code with other modules is making a combined work + * based on Thermostat. Thus, the terms and conditions of the GPL + * cover the whole combination. + * + * As a special exception, the copyright holders of Thermostat give you + * permission to link this code with independent modules to produce an + * executable, regardless of the license terms of these independent + * modules, and to copy and distribute the resulting executable under + * terms of your choice, provided that you also meet, for each linked + * independent module, the terms and conditions of the license of that + * module. An independent module is a module which is not derived from + * or based on Thermostat code. If you modify Thermostat, you may + * extend this exception to your version of the software, but you are + * not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + */ + +beforeEach(() => { + let EC = protractor.ExpectedConditions; browser.ignoreSynchronization = true; browser.driver.get(browser.params.webClientUrl); - var logout = element(by.id('logoutButton')); - browser.isElementPresent(logout).then(function (present) { + let username = element(by.id('username')); + browser.wait(EC.visibilityOf(username), 10000); + + username.sendKeys('client'); + element(by.id('password')).sendKeys('client-pwd'); + element(by.id('kc-login')).click(); + + browser.wait(EC.visibilityOf(element(by.id('brandLogoImg')), 10000)); + + browser.call(() => { + browser.ignoreSynchronization = false; + }); + browser.waitForAngular(); +}); + +afterEach(() => { + let userMenu = element(by.id('userMenu')); + browser.isElementPresent(userMenu).then(present => { if (present) { - logout.isDisplayed().then(function (displayed) { + userMenu.isDisplayed().then(displayed => { if (displayed) { - logout.click(); + userMenu.click(); + let logout = element(by.id('logoutButton')); + browser.isElementPresent(logout).then(present => { + if (present) { + logout.isDisplayed().then(displayed => { + if (displayed) { + logout.click(); + } + }); + } + }); } }); } }); - - var username = element(by.id('username')); - browser.wait(EC.visibilityOf(username), 10000); - - username.sendKeys('test-user'); - element(by.id('password')).sendKeys('test-pass'); - element(by.id('kc-login')).click(); - - browser.wait(EC.visibilityOf(element(by.id('brandLogoImg')), 10000)); - - browser.call(function () { - browser.ignoreSynchronization = false; - }); - browser.waitForAngular(); -} +});
--- a/integration-test/specs/launch.spec.js Tue Sep 12 12:20:37 2017 -0400 +++ b/integration-test/specs/launch.spec.js Tue Sep 12 14:23:58 2017 -0400 @@ -1,6 +1,33 @@ -describe('Basic web-client launch', function () { +/** + * Copyright 2012-2017 Red Hat, Inc. + * + * Thermostat is distributed under the GNU General Public License, + * version 2 or any later version (with a special exception described + * below, commonly known as the "Classpath Exception"). + * + * A copy of GNU General Public License (GPL) is included in this + * distribution, in the file COPYING. + * + * Linking Thermostat code with other modules is making a combined work + * based on Thermostat. Thus, the terms and conditions of the GPL + * cover the whole combination. + * + * As a special exception, the copyright holders of Thermostat give you + * permission to link this code with independent modules to produce an + * executable, regardless of the license terms of these independent + * modules, and to copy and distribute the resulting executable under + * terms of your choice, provided that you also meet, for each linked + * independent module, the terms and conditions of the license of that + * module. An independent module is a module which is not derived from + * or based on Thermostat code. If you modify Thermostat, you may + * extend this exception to your version of the software, but you are + * not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + */ - beforeEach(require('../login-helper.js')); +describe('Basic web-client launch', () => { + + require('../login-helper.js'); it('should set page title', () => { browser.getTitle().should.eventually.equal('Thermostat'); @@ -9,4 +36,5 @@ it('should navigate to landing state', () => { browser.getCurrentUrl().should.eventually.containEql('landing'); }); + });
--- a/src/app/index.html Tue Sep 12 12:20:37 2017 -0400 +++ b/src/app/index.html Tue Sep 12 14:23:58 2017 -0400 @@ -31,7 +31,7 @@ </ul> </li> - <li hidden ng-show="loginStatus()" class="dropdown"> + <li id="userMenu" hidden ng-show="loginStatus()" class="dropdown"> <a class="dropdown-toggle nav-item-iconic" id="userDropwdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <span translate-attr="{title: 'navbar.USERNAME'}" class="fa pficon-user"></span> {{username}} <span class="caret"></span> </a>