From 65e23df021aa94af3b68cca830875b635286b2f8 Mon Sep 17 00:00:00 2001 From: Jonathan Petitcolas Date: Tue, 19 May 2015 11:21:12 +0200 Subject: [PATCH] Fix Protractor tests --- .gitignore | 1 + Gruntfile.js | 67 ++++++++++++++++---------------------- Makefile | 4 +-- package.json | 1 + src/javascripts/vendors.js | 1 + 5 files changed, 33 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index 5d543f57..af6c8f72 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist .sass-cache src/javascripts/bower_components src/javascripts/config.js +src/javascripts/test/fixtures/examples/blog src/styles/*.css build/require build/es6 diff --git a/Gruntfile.js b/Gruntfile.js index e1a41ab1..32540905 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,51 +6,34 @@ module.exports = function (grunt) { // Define the configuration for all the tasks grunt.initConfig({ copy: { - css_dev: { - src: 'build/ng-admin.min.css', - dest: 'examples/blog/build/ng-admin.css', - options: { - process: function(content) { - return content.replace(/url\("\.\.\/src\/javascripts\/bower_components\/bootstrap-sass-official\/assets\/fonts\/bootstrap/g, 'url(".'); - } - } + test_build: { + src: 'build/*', + dest: 'src/javascripts/test/fixtures/examples/blog/' }, - fonts_dev: { - cwd: 'src/javascripts/bower_components/bootstrap-sass-official/assets/fonts/bootstrap/', - src: ['**'], - dest: 'examples/blog/build/', - expand: true - }, - assets_dev: { - cwd: 'assets/', - src: ['**'], - dest: 'examples/blog/assets/', - expand: true - }, - js_dev: { - src: 'build/ng-admin.min.js', - dest: 'examples/blog/build/ng-admin.js' - }, - css: { - src: 'build/ng-admin.min.css', - dest: 'examples/blog/build/ng-admin.min.css', + test_sample_app: { + src: 'examples/blog/*', + dest: 'src/javascripts/test/fixtures/', options: { process: function(content) { - return content.replace(/url\("\.\.\/src\/javascripts\/bower_components\/bootstrap-sass-official\/assets\/fonts\/bootstrap/g, 'url(".'); + return content.replace(/http\:\/\/localhost\:8080\//g, '/'); } } - }, - angular: { - src: 'src/javascripts/bower_components/angular/angular.js', - dest: 'examples/blog/build/angular.js' } }, connect: { - server: { + dev: { options: { port: 8000, base: 'examples/blog/', - keepalive: true, + keepalive: false, + livereload: false + } + }, + test: { + options: { + port: 8000, + base: 'src/javascripts/test/fixtures/examples/blog/', + keepalive: false, livereload: false } } @@ -84,21 +67,27 @@ module.exports = function (grunt) { }, src: ['src/javascripts/ng-admin/es6/tests/**/*.js'] } + }, + exec: { + webpack: './node_modules/webpack/bin/webpack.js', + webpack_watch: './node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress --colors' } }); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-exec'); grunt.loadNpmTasks('grunt-protractor-runner'); grunt.loadNpmTasks('grunt-json-server'); grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-mocha-test'); - grunt.registerTask('test', ['mochaTest', 'karma', 'build', 'copy_build', 'connect', 'protractor']); - grunt.registerTask('copy_build', ['copy:config', 'copy:angular', 'copy:js_dev', 'copy:css', 'copy:fonts_dev']); + grunt.registerTask('test', ['mochaTest', 'karma', 'test:e2e']); + grunt.registerTask('test:e2e', ['test:e2e:prepare', 'json_server', 'connect:test', 'protractor']); + grunt.registerTask('test:e2e:prepare', ['exec:webpack', 'copy:test_sample_app', 'copy:test_build']); - grunt.registerTask('test:local', ['mochaTest', 'karma', 'copy_build:dev', 'test:local:e2e']); - grunt.registerTask('test:local:e2e', ['json_server', 'connect', 'protractor']); + grunt.registerTask('test:local', ['mochaTest', 'karma', 'test:local:e2e']); + grunt.registerTask('test:local:e2e', ['test:e2e:prepare', 'json_server', 'connect:test', 'protractor']); - grunt.registerTask('default', ['copy:angular', 'json_server', 'connect']); + grunt.registerTask('default', ['json_server', 'connect:dev', 'exec:webpack_watch']); }; diff --git a/Makefile b/Makefile index 41069440..6988f908 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,12 @@ install: ./node_modules/protractor/bin/webdriver-manager update run: - @./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress --colors --host=0.0.0.0 & @grunt build: @NODE_ENV=production ./node_modules/webpack/bin/webpack.js -p --progress + @cp -Rf build/* examples/blog/build/ @echo "Files build/ng-admin.min.css and build/ng-admin.min.js updated (with minification)" -test: build +test: @grunt test:local diff --git a/package.json b/package.json index dea842f0..17eb4fcf 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "grunt-contrib-requirejs": "^0.4.4", "grunt-contrib-uglify": "~0.6.0", "grunt-contrib-watch": "~0.5.2", + "grunt-exec": "^0.4.6", "grunt-json-server": "git://github.com/fzaninotto/grunt-json-server.git#c834e50e2151a16930f1378324cf96b91438bdae", "grunt-karma": "^0.8.3", "grunt-mocha-test": "^0.12.7", diff --git a/src/javascripts/vendors.js b/src/javascripts/vendors.js index 3a4c40e2..34e00973 100644 --- a/src/javascripts/vendors.js +++ b/src/javascripts/vendors.js @@ -5,6 +5,7 @@ global.numeral = require('numeral'); require('angular-ui-router'); require('angular-sanitize'); require('angular-ui-codemirror'); +require('nginflection'); require('textangular'); require('../../node_modules/angular-numeraljs/dist/angular-numeraljs');