Skip to content

Commit

Permalink
Add E2E tests for login (#64)
Browse files Browse the repository at this point in the history
* Add E2E test that checks if login form is visible
* Add tests for login where user enters input

See DIH-155
  • Loading branch information
Adrian Alexander Eriksen authored and essoen committed Jul 5, 2016
1 parent 9fd9598 commit 6bcb362
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/features/login.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Feature: Login
I want to be able to see the form
And I want generic feedback when credentials are missing
And I want generic feedback when credentials are wrong
And I want to be able to login with correct credentials

Scenario: Open login page
Given I open the page "login"
Then I expect that element "email" is visible
Then I expect that element "password" is visible

Scenario: Unsuccessful login with blank input
Given I open the page "login"
When I press the button "submit"
Then I expect that "messages" contains "The combination of username and password is invalid"

Scenario: Unsuccessful login with invalid credentials
Given I open the page "login"
When I set "E-mail" to the inputfield "[email protected]"
And I set "Password" to the inputfield "wrongpassword"
And I press the button "submit"
Then I expect that "messages" contains "The combination of username and password is invalid"

Scenario: Login succeeds with valid credentials
Given I open the page "login"
When I set "E-mail" to the inputfield "[email protected]"
And I set "Password" to the inputfield "password"
And I press the button "submit"
34 changes: 34 additions & 0 deletions test/pages/login.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import page from './page';

module.exports = Object.create(page, {

email: {
get() {
return browser.element('#email');
}
},

password: {
get() {
return browser.element('#password');
}
},

submit: {
value() {
return browser.click('button#submit');
}
},

messages: {
get() {
return browser.element('li#message');
}
},

open: {
value() {
page.open.call(this, '/login');
}
}
});

0 comments on commit 6bcb362

Please sign in to comment.