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 64f533b commit 64aeaff
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 75 deletions.
73 changes: 50 additions & 23 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
var coffee, gulp, uglify;
'use strict';

gulp = require( 'gulp' );
coffee = require( 'gulp-coffee' );
uglify = require( 'gulp-uglify' );
var del = require('del');
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify');
var protractor = require('gulp-protractor').protractor;

gulp.task( 'js', function () {

gulp.task('clean', function(cb) {
del(['build'], cb);
});

/**
* CoffeeScript Source Files
*/
gulp.task('js', function () {
gulp
.src( './app/scripts/**/*.coffee' )
.pipe( coffee({
.src('./app/scripts/**/*.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(gulp.dest('./.tmp/scripts'));
});

/**
* CoffeeScript Test Files
*/
gulp.task('js:test', function () {
gulp.src('./test/**/*.coffee')
.pipe(coffee({
bare: true
}) )
.pipe( gulp.dest( './.tmp' ) );
} );

gulp.task( 'watch', function () {
gulp.watch( './app/scripts/**/*.coffee', ['js'] );
gulp.watch( './test/**/*.coffee', ['js:test'] )
} );
})).pipe(gulp.dest('./.tmp'));
});

gulp.task('watch', function () {
gulp.watch('./app/scripts/**/*.coffee', ['js']);
gulp.watch('./test/**/*.coffee', ['js:test'])
});




gulp.task('test', ['js:test'], function(){
gulp.src(['./.tmp/protractor/**/*-spec.js'])
.pipe(protractor({
configFile: 'protractor.conf.js'
}))
.on('error', function (e) {
throw e;
});
});

gulp.task('default', ['js:test', 'test']);
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"devDependencies": {
"chai": "^1.10.0",
"connect-proxy": "~1.0.2",
"del": "^1.1.0",
"grunt": "~0.4.4",
"grunt-angular-templates": "~0.5.1",
"grunt-autoprefixer": "~0.4.0",
Expand Down Expand Up @@ -97,6 +98,7 @@
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~2.0.2",
"gulp-ngmin": "^0.3.0",
"gulp-protractor": "0.0.11",
"gulp-uglify": "^1.0.2",
"jasmine-core": "^2.1.2",
"jasmine-node": "~1.11.0",
Expand All @@ -111,7 +113,7 @@
"karma-phantomjs-launcher": "~0.1",
"load-grunt-tasks": "~0.2.0",
"mocha": "^2.0.1",
"protractor": "^1.0.0",
"protractor": "^1.5.0",
"supertest": "^0.15.0",
"time-grunt": "~0.2.1"
},
Expand Down
14 changes: 6 additions & 8 deletions test/protractor/j$.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
###*
J$ Helpers - I am test helpers
###
j$ =
element: (selector, label) ->
console.warn('finding', label) if label
$(selector)
input: (name) ->
element(protractor.By.css("[name=#{name}]")).getWebElement()

module.exports = j$
module.exports =
element: (selector, label) ->
console.warn('finding', label) if label
$(selector)
input: (name) ->
element(protractor.By.css("[name=#{name}]")).getWebElement()
9 changes: 5 additions & 4 deletions test/protractor/pages/app-page.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

###*
App Page - I handle general actions in the app.
###
AppPage =
title: $('.navbar-brand')
get: ->
browser.get '/'
title: $('.navbar-brand')
get: ->
browser.get '/#'
refresh: ->
browser.refresh()

module.exports = AppPage
22 changes: 14 additions & 8 deletions test/protractor/pages/login-page.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
Login Page - I handle actions on the login page.
###
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()
username: $('#username')
password: $('#password')
get: ->
browser.get '#/login'
logout: ->
$('.dropdown-toggle').getWebElement().then((el)->
el.click().then(()->
$('[href="#/login"]').click()
)
)
login: (u, p) ->
@username.sendKeys(u)
@password.sendKeys(p)
element(protractor.By.css('button[type="submit"]')).click()

module.exports = LoginPage
32 changes: 17 additions & 15 deletions test/protractor/pages/register-page.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ j$ = require('../j$')
Register Page - I handle actions on the register page
###
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()
email: $('#email')
username: $('#username')
password: $('#password')
password2: $('#password2')
agree: $('#agree')
submit: element(protractor.By.buttonText('Sign up'))
get: ->
browser.get '#/register'
register: (username, password) ->
@email.sendKeys(username)
@username.sendKeys(username)
@password.sendKeys(password)
@password2.sendKeys(password)
@agree.click().then(()=>
@submit.click()
)


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


###*
Protractor e2e Tests
###

describe "Angular-CMS App", ->
beforeEach ->
appPage.refresh()
it 'should have the correct title', ->
appPage.title.getText().then((val)->
expect(val).toContain('angular-cms')
)
describe 'Angular-CMS App', ->
appPage = require('../pages/app-page')
it 'should have the correct title', ->
appPage.title.getText().then((val)->
expect(val).toContain('angular-cms')
)
14 changes: 8 additions & 6 deletions test/protractor/spec/login-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ loginPage = require('../pages/login-page')
Login - The user login implementation
###
describe 'Login:', ->
beforeEach ->
$('[href="#/login"]').click()
it 'should have Username and password inputs with a button to submit the form', ->
loginPage.login('[email protected]', 'test').then(()->
expect(browser.getLocationAbsUrl()).toContain '/dashboard'
)
beforeEach ->
loginPage.get()
afterEach ->
loginPage.logout()
it 'should have Username and password inputs with a button to submit the form', ->
loginPage.login('[email protected]', 'test').then(()->
expect(browser.getLocationAbsUrl()).toContain '/dashboard'
)

0 comments on commit 64aeaff

Please sign in to comment.