Skip to content

Commit

Permalink
updated specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniespratley committed Dec 9, 2014
1 parent c620d9c commit 64f533b
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 90 deletions.
26 changes: 11 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* jshint camelcase:false */
// Generated on 2013-12-06 using generator-angular 0.6.0-rc.2
var fs = require('fs');
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

/**
* @TODO - Externalize configuration for server and proxy, mongodb
*/
var config = JSON.parse(fs.readFileSync(__dirname + '/config/config.json'));
var cmsRoutes = require(__dirname + '/routes/cms-routes');
var serverEndpoint = 'http://localhost:8181';
var proxyConfig = {
proxy: {
Expand All @@ -31,10 +35,7 @@ module.exports = function (grunt) {
//Connect proxy to route requests to localhost:8181/api
grunt.loadNpmTasks('grunt-connect-proxy');
require('json-proxy').initialize({});
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

var GruntConfig = {
Expand All @@ -57,7 +58,7 @@ module.exports = function (grunt) {
files: ['test/spec/{,**/}*.{coffee,litcoffee,coffee.md}'],
tasks: ['coffee:test', 'newer:coffee:test', 'karma:unit']
},

compass: {
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
Expand Down Expand Up @@ -89,22 +90,17 @@ module.exports = function (grunt) {
// Change this to '0.0.0.0' to access the server from outside.
hostname: '127.0.0.1',
livereload: 35729,
middleware: function (connect, options) {
return [
require('json-proxy').initialize(proxyConfig),
mountFolder(connect, '.grunt'),
mountFolder(connect, '.tmp')
];
}
base: ['.tmp', '<%= yeoman.app %>']
},
livereload: {
options: {
open: true,
base: ['.tmp', '<%= yeoman.app %>'],
middleware: function (connect, options) {
return [
require('json-proxy').initialize(proxyConfig),
mountFolder(connect, '.tmp'),
require('json-proxy').initialize(proxyConfig),
mountFolder(connect, '.grunt'),
mountFolder(connect, '.tmp'),
mountFolder(connect, 'app')
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/login.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ angular.module('angularCmsApp').controller 'LoginCtrl', ($scope, $rootScope, $co
,
(err)->
console.error(err)
cmsNotify( '.login-message', 'danger', 'Error!', err.data.message, 2500)
cmsNotify( '.login-message', 'danger', 'Error!', err.data.message)
)

###
Expand Down
2 changes: 1 addition & 1 deletion app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
http://127.0.0.1:9000/styles/main.css
http://localhost:9000/styles/main.css
*/
@import url('https://cdn.rawgit.com/McNull/angular-form-gen/v0.0.1/dist/angular-form-gen.min.css');
@import url('../bower_components/angular-form-gen/dist/angular-form-gen.min.css');

.navbar-avatar {
height: 20px;
Expand Down
4 changes: 2 additions & 2 deletions app/views/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</div>

<div class="form-group">
<input name="email" class="form-control" type="email" placeholder="Email" ng-model="user.email" required
<input id="username" name="username" class="form-control" type="text" placeholder="Username" ng-model="user.username" required
autofocus>
</div>
<div class="form-group">
<input name="password" class="form-control" type="password" placeholder="Password" ng-model="user.password"
<input id="password" name="password" class="form-control" type="password" placeholder="Password" ng-model="user.password"
required>
</div>
<p>
Expand Down
11 changes: 5 additions & 6 deletions app/views/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

</div>
<div class="form-group">
<input name="email" type="email" class="form-control" placeholder="Email" ng-model="user.email" required/>
<input id="email" name="email" type="email" class="form-control" placeholder="Email" ng-model="user.email" required/>
</div>
<div class="form-group">
<input name="username" type="text" class="form-control" placeholder="Username" ng-model="user.username" required/>
<input id="username" name="username" type="text" class="form-control" placeholder="Username" ng-model="user.username"/>
</div>
<div class="form-group">
<input name="password" type="password" class="form-control" placeholder="Password" ng-model="user.password" required/>
<input id="password" name="password" type="password" class="form-control" placeholder="Password" ng-model="user.password" required/>
</div>
<div class="form-group">
<input name="password2" type="password" class="form-control" placeholder="Confirm Password" ng-model="user.password2"
<input id="password2" name="password2" type="password" class="form-control" placeholder="Confirm Password" ng-model="user.password2"
required/>
</div>
<div class="form-group">
<label>
<input name="agree" class="inline-checkbox" type="checkbox" ng-model="user.agree" required>
<input id="agree" name="agree" class="inline-checkbox" type="checkbox" ng-model="user.agree" required>
Agree to Terms of Use
</label>
</div>
Expand All @@ -34,6 +34,5 @@
</form>
<div class="clearfix">
<span class="pull-left"> Back to <a href="#/login">Login</a> </span>

</div>
</div>
9 changes: 6 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ uglify = require( 'gulp-uglify' );
gulp.task( 'js', function () {
gulp
.src( './app/scripts/**/*.coffee' )
.pipe( coffee() )
.pipe( coffee({
bare: true
}) )
.pipe( uglify() )
.pipe( gulp.dest( './.tmp/scripts' ) );
} );
gulp.task( 'js:test', function () {
gulp
.src( './test/**/*.coffee' )
.pipe( coffee() )
.pipe( uglify() )
.pipe( coffee({
bare: true
}) )
.pipe( gulp.dest( './.tmp' ) );
} );

Expand Down
4 changes: 2 additions & 2 deletions routes/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ var MESSAGES = {
};
var DS = require('jps-ds').DS;
var _ds = new DS({
host: 'angularcms:[email protected]:10089/app19632340',
//host: 'localhost/angular-cms',
//host: 'angularcms:[email protected]:10089/app19632340',
host: 'localhost/angular-cms',
models: {
'groups': {
title: String,
Expand Down
2 changes: 1 addition & 1 deletion test/protractor/j$.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ j$ =
console.warn('finding', label) if label
$(selector)
input: (name) ->
$('#'+name)
element(protractor.By.css("[name=#{name}]")).getWebElement()

module.exports = j$
7 changes: 5 additions & 2 deletions test/protractor/pages/app-page.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
###*
App Page - I handle general actions in the app.
###
module.exports = AppPage = () ->
@get = ->
AppPage =
title: $('.navbar-brand')
get: ->
browser.get '/'

module.exports = AppPage
18 changes: 11 additions & 7 deletions test/protractor/pages/login-page.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
###*
Login Page - I handle actions on the login page.
###
module.exports = LoginPage = () ->
@get = ->
browser.get '/#/login'
@login = (u, p) ->
j$.input('username').sendKeys(u)
j$.input('password').sendKeys(p)
j$.element('button[type="submit"]').click()
LoginPage =
username: $('#username')
password: $('#password')
get: ->
browser.get '/login'
login: (u, p) ->
@username.sendKeys(u)
@password.sendKeys(p)
element(protractor.By.css('button[type="submit"]')).click()

module.exports = LoginPage
35 changes: 20 additions & 15 deletions test/protractor/pages/register-page.coffee
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
j$ = require('../j$')

###*
Register Page - I handle actions on the register page
###
module.exports = RegisterPage = () ->
email = j$.input('email')
username = j$.input('username')
password = j$.input('password')
password2 = j$.input('password2')
agree = j$.input('agree')
@get = ->
browser.get '/#/register'
@register = ->
email.sendKeys('[email protected]')
username.sendKeys('test')
password.sendKeys('test')
password2.sendKeys('test')
agree.click()
element(protractor.By.css('button[type="submit"]')).click()
RegisterPage =
email = $('#email')
username: $('#username')
password: $('#password')
password2: $('#password2')
agree: $('#agree')
submit: element(protractor.By.css('button'))
get: ->
browser.get '/register'
register: (username, password) ->
@email.sendKeys(username)
@username.sendKeys(username)
@password.sendKeys(password)
@password2.sendKeys(password)
@agree.click()
@submit.click()

module.exports = RegisterPage
15 changes: 7 additions & 8 deletions test/protractor/spec/app-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
AppPage = require('../pages/app-page')
appPage = require('../pages/app-page')


###*
Protractor e2e Tests
###
App = new AppPage()

describe "Angular-CMS App", ->
beforeEach ->
App.get()

#Welome Story: the initial page
describe 'Index:', ->
it "should display the main index view as default", ->
expect(browser.getLocationAbsUrl()).toEqual '/'
appPage.refresh()
it 'should have the correct title', ->
appPage.title.getText().then((val)->
expect(val).toContain('angular-cms')
)
24 changes: 6 additions & 18 deletions test/protractor/spec/login-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
LoginPage = require('../pages/login-page')
loginPage = new LoginPage()
loginPage = require('../pages/login-page')

###*
Login - The user login implementation
###
describe 'Login:', ->

#Click the login button each time
beforeEach ->
$('a[href="#/login"]').click()

#Make sure we end up at the login page to enter our credentials
#Make sure there is a username and password input with button
$('[href="#/login"]').click()
it 'should have Username and password inputs with a button to submit the form', ->
expect(browser.getLocationAbsUrl()).toEqual '/login'

#Login to the page
loginPage.login('[email protected]', 'test')

#Wait for the api call to go thru
sleep 1

#We should end up at the dashboard page.
expect(browser.getLocationAbsUrl()).toEqual '/dashboard'
loginPage.login('[email protected]', 'test').then(()->
expect(browser.getLocationAbsUrl()).toContain '/dashboard'
)
15 changes: 6 additions & 9 deletions test/protractor/spec/register-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
RegisterPage = require('../pages/register-page')
j$ = require('../j$')
registerPage = require('../pages/register-page')

###*
Register - The user registration implementation
###
testEmail = Date.now() + '[email protected]'
describe 'Register: ', ->
it 'should have email and password inputs with a button to submit the form', ->
registerPage = new RegisterPage()
it 'should allow a user to register', ->
registerPage.get()
expect(browser.getCurrentUrl()).toContain 'register'
expect(j$.element('form', 'Login form').count()).toEqual 1
expect(j$.element('input[name="email"]', 'Email input').count()).toEqual 1
expect(j$.element('input[name="username"]', 'Username input').count()).toEqual 1
expect(j$.element('input[name="password"]', 'Password input').count()).toEqual 2
expect(j$.element('button[type="submit"]', 'Submit button').count()).toEqual 1
registerPage.register(testEmail, 'test').then(()->
expect(browser.getCurrentUrl()).toContain 'dashboard'
)

0 comments on commit 64f533b

Please sign in to comment.