From a46f4f063f6d8cec2071c0e3182e5034c086c230 Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Mon, 13 Nov 2017 12:44:42 +0200 Subject: [PATCH] =?UTF-8?q?separate=20wait=20for=20when=20we=E2=80=99re=20?= =?UTF-8?q?expecting=20login=20not=20to=20succeed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/pages/login-page.ts | 8 ++++++++ e2e/suites/authentication/login.test.ts | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/e2e/pages/login-page.ts b/e2e/pages/login-page.ts index 41aec9292..95cc0bc19 100644 --- a/e2e/pages/login-page.ts +++ b/e2e/pages/login-page.ts @@ -58,4 +58,12 @@ export class LoginPage extends Page { loginWithAdmin(): promise.Promise { return this.loginWith(ADMIN_USERNAME, ADMIN_PASSWORD); } + + tryLoginWith(username: string, password?: string): promise.Promise { + const pass = password || username; + return this.login.enterCredentials(username, pass).submit() + .then(() => { + browser.wait(EC.presenceOf(this.login.errorMessage), BROWSER_WAIT_TIMEOUT); + }); + } } diff --git a/e2e/suites/authentication/login.test.ts b/e2e/suites/authentication/login.test.ts index 527483553..80fa54a38 100644 --- a/e2e/suites/authentication/login.test.ts +++ b/e2e/suites/authentication/login.test.ts @@ -150,7 +150,7 @@ describe('Login', () => { it('shows error when entering nonexistent user', () => { loginPage - .loginWith('nonexistent-user', 'any-password') + .tryLoginWith('nonexistent-user', 'any-password') .then(() => { expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN); expect(errorMessage.isDisplayed()).toBe(true); @@ -161,7 +161,7 @@ describe('Login', () => { const { username } = johnDoe; loginPage - .loginWith(username, 'incorrect-password') + .tryLoginWith(username, 'incorrect-password') .then(() => { expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN); expect(errorMessage.isDisplayed()).toBe(true);