Skip to content

Commit

Permalink
merged pull request #20: Initial commit for #5, with a single basic e…
Browse files Browse the repository at this point in the history
…2e test
  • Loading branch information
leob committed Aug 26, 2015
2 parents 0d65d42 + 3cd2307 commit 4971585
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ node_modules/
resources/
platforms/
plugins/

src/lib/

_*
Expand All @@ -18,3 +17,8 @@ src/index.html
src/css/ionic.app.css
src/css/ionic.app.min.css
src/js/config/config.js
npm-debug.log

# EXCLUDE TYPE DEFINITIONS, IF USED LOCALLY BY DEVELOPER
typings/
tsd.json
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"private": "true",
"private": true,
"version": "0.0.0",
"authors": [
"leob <leob@users.noreply.github.com>"
Expand Down
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "app",
"version": "1.0.0",
"private": true,
"description": "app: An Ionic project",
"dependencies": {
"gulp": "^3.5.6",
Expand Down Expand Up @@ -32,13 +33,21 @@
"karma-jasmine": "^0.3.6",
"karma-story-reporter": "^0.3.1",
"shelljs": "^0.3.0",
"vinyl-paths": "^1.0.0"
"vinyl-paths": "^1.0.0",
"protractor": "^2.1.0"
},
"cordovaPlugins": [
"org.apache.cordova.device",
"org.apache.cordova.console",
"org.apache.cordova.splashscreen",
"com.ionic.keyboard",
"cordova-plugin-whitelist"
]
],
"scripts": {
"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",

"preprotractor": "npm run update-webdriver",
"protractor": "protractor protractor.conf.js"
}
}
25 changes: 25 additions & 0 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* global browser */
exports.config = {
allScriptsTimeout: 20000,
specs: [
// E2E test specs are organized by user stories, not necessarily
// reflecting the code structure of the project. Imagine things your
// users might do, and write e2e tests around those behaviors.
'test/e2e/**/*.spec.js',
],
capabilities: {
// You can use other browsers
// like firefox, phantoms, safari, IE, etc.
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8100',

framework: 'jasmine',

jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose: true,
}
};
1 change: 1 addition & 0 deletions scss/app/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ label.item.valid {
.form-error {
padding: 2px 0 2px 16px;
color: $primary;
clear: both;
}
/* END from https://calendee.com/2014/12/26/validation-in-ionic-framework-apps-with-ngmessages/ */

4 changes: 3 additions & 1 deletion src/js/app/auth/login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
</div>

<div class="text-center padding-top">
<button class="button button-full button-primary" ng-click="vm.login(vm.form)" translate>button.login</button>
<button name="login" class="button button-full button-primary" ng-click="vm.login(vm.form)" translate>
button.login
</button>

<span class="note padding" translate>prompt.no-account</span><span
class="link padding" ui-sref="signup" translate>link.signup</span>
Expand Down
2 changes: 1 addition & 1 deletion src/js/app/menu/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ion-item class="item-icon-left" menu-close ng-show="!main.isLoggedIn()" ng-click="main.login()">
<i class="icon primary ion-log-in"></i> <span translate>menu.login</span>
</ion-item>
<ion-item class="item-icon-left" menu-close ng-show="main.isLoggedIn()" ng-click="main.logout()">
<ion-item name="logout" class="item-icon-left" menu-close ng-show="main.isLoggedIn()" ng-click="main.logout()">
<i class="icon primary ion-log-out"></i> <span translate>menu.logout</span>
</ion-item>
</ion-list>
Expand Down
2 changes: 1 addition & 1 deletion src/js/app/util/directives/formErrors.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return {
restrict: 'E',
replace: true,
template: '<div class="text-center" style="clear:both;" ng-show="vm.error.message">' +
template: '<div class="text-center form-error" ng-show="vm.error.message">' +
'<div class="padding badge badge-royal">' +
'{{vm.error.message}}' +
'</div>' +
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/auth/login.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Test the login experience
describe('Login', function(){

beforeEach(function() {
// before each spec, load the login page
browser.get('/#/login');
});

it('should fail with an appropriate error message when password is invalid', function() {
// Enter an invalid password and try to log in
element(by.name('email')).sendKeys('someone@example.com');
element(by.name('password')).sendKeys('badpassword');
element(by.name('login')).click();

// We should see an error message about the invalid password
var errorDisplay = element(by.css(".form-error"));
expect(errorDisplay.getText()).toContain('Invalid');
});

it('should log in and go to home when a valid password is entered', function() {
// Enter a valid password, and try to log in
element(by.name('email')).sendKeys('someone@example.com');
element(by.name('password')).sendKeys('password');
element(by.name('login')).click();

// We should navigate to the app (home or intro if it is first use)
// on successful sign-in
expect(browser.getLocationAbsUrl()).toContain('/app/');

// Test logout experience
describe('Logout', function() {

it('should be able to log out after a successful login', function() {
// Click the logout button
element(by.name('logout')).click();

// We should now go to the logged out screen
expect(browser.getLocationAbsUrl()).toContain('/loggedout');
});
});
});
});

0 comments on commit 4971585

Please sign in to comment.