separate wait for when we’re expecting login not to succeed

This commit is contained in:
Adina Parpalita
2017-11-13 12:44:42 +02:00
parent 4040e80db7
commit a46f4f063f
2 changed files with 10 additions and 2 deletions

View File

@@ -58,4 +58,12 @@ export class LoginPage extends Page {
loginWithAdmin(): promise.Promise<any> { loginWithAdmin(): promise.Promise<any> {
return this.loginWith(ADMIN_USERNAME, ADMIN_PASSWORD); return this.loginWith(ADMIN_USERNAME, ADMIN_PASSWORD);
} }
tryLoginWith(username: string, password?: string): promise.Promise<void> {
const pass = password || username;
return this.login.enterCredentials(username, pass).submit()
.then(() => {
browser.wait(EC.presenceOf(this.login.errorMessage), BROWSER_WAIT_TIMEOUT);
});
}
} }

View File

@@ -150,7 +150,7 @@ describe('Login', () => {
it('shows error when entering nonexistent user', () => { it('shows error when entering nonexistent user', () => {
loginPage loginPage
.loginWith('nonexistent-user', 'any-password') .tryLoginWith('nonexistent-user', 'any-password')
.then(() => { .then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN); expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
expect(errorMessage.isDisplayed()).toBe(true); expect(errorMessage.isDisplayed()).toBe(true);
@@ -161,7 +161,7 @@ describe('Login', () => {
const { username } = johnDoe; const { username } = johnDoe;
loginPage loginPage
.loginWith(username, 'incorrect-password') .tryLoginWith(username, 'incorrect-password')
.then(() => { .then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN); expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
expect(errorMessage.isDisplayed()).toBe(true); expect(errorMessage.isDisplayed()).toBe(true);