diff --git a/Gruntfile.js b/Gruntfile.js index 74ddd1eb9d03..b8e1e4b34413 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,7 +23,7 @@ module.exports = function(grunt) { parallel: { travis: { tasks: [ - util.parallelTask(['test:unit', 'test:promises-aplus'/*, 'tests:docs'*/], {stream: true}), + util.parallelTask(['test:unit', 'test:promises-aplus', 'tests:docs'], {stream: true}), util.parallelTask(['test:e2e']) ] } @@ -77,7 +77,7 @@ module.exports = function(grunt) { tests: { jqlite: 'karma-jqlite.conf.js', jquery: 'karma-jquery.conf.js', - //docs: 'karma-docs.conf.js', + docs: 'karma-docs.conf.js', modules: 'karma-modules.conf.js' }, @@ -86,7 +86,7 @@ module.exports = function(grunt) { jqlite: 'karma-jqlite.conf.js', jquery: 'karma-jquery.conf.js', modules: 'karma-modules.conf.js', - //docs: 'karma-docs.conf.js' + docs: 'karma-docs.conf.js' }, @@ -217,14 +217,6 @@ module.exports = function(grunt) { }, - // docs: { - // process: ['build/docs/*.html', 'build/docs/.htaccess'] - // }, - - "jasmine_node": { - projectRoot: 'docs/spec' - }, - "ddescribe-iit": { files: [ 'test/**/*.js', @@ -286,11 +278,11 @@ module.exports = function(grunt) { //alias tasks - grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'package','test:unit','test:promises-aplus'/*, 'tests:docs'*/, 'test:protractor']); + grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor']); grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']); grunt.registerTask('test:jquery', 'Run the jQuery unit tests with Karma', ['tests:jquery']); grunt.registerTask('test:modules', 'Run the Karma module tests with Karma', ['tests:modules']); - grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package'/*, 'tests:docs'*/]); + grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package', 'tests:docs']); grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']); grunt.registerTask('test:protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:normal']); grunt.registerTask('test:jq-protractor', 'Run the end to end tests against jquery with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:jquery']); diff --git a/docs/app/src/app.js b/docs/app/src/app.js new file mode 100644 index 000000000000..0ac5f258fd73 --- /dev/null +++ b/docs/app/src/app.js @@ -0,0 +1,23 @@ +angular.module('docsApp', [ + 'ngRoute', + 'ngCookies', + 'ngSanitize', + 'ngAnimate', + 'DocsController', + 'versionsData', + 'pagesData', + 'directives', + 'errors', + 'examples', + 'search', + 'tutorials', + 'versions', + 'bootstrap', + 'bootstrapPrettify', + 'ui.bootstrap.dropdown' +]) + + +.config(function($locationProvider) { + $locationProvider.html5Mode(true).hashPrefix('!'); +}); \ No newline at end of file diff --git a/docs/app/src/docs.js b/docs/app/src/docs.js index cb4f029fa58d..5163e98225eb 100644 --- a/docs/app/src/docs.js +++ b/docs/app/src/docs.js @@ -1,26 +1,4 @@ -angular.module('docsApp', [ - 'ngRoute', - 'ngCookies', - 'ngSanitize', - 'ngAnimate', - 'versionsData', - 'pagesData', - 'directives', - 'errors', - 'examples', - 'search', - 'tutorials', - 'versions', - 'bootstrap', - 'bootstrapPrettify', - 'ui.bootstrap.dropdown' -]) - - -.config(function($locationProvider) { - $locationProvider.html5Mode(true).hashPrefix('!'); -}) - +angular.module('DocsController', []) .controller('DocsController', function($scope, $rootScope, $location, $window, $cookies, NG_PAGES, NG_NAVIGATION, NG_VERSION) { @@ -52,7 +30,8 @@ angular.module('docsApp', [ }; $scope.afterPartialLoaded = function() { - $window._gaq.push(['_trackPageview', $location.path()]); + var pagePath = $scope.currentPage ? $scope.currentPage.path : $location.path(); + $window._gaq.push(['_trackPageview', pagePath]); }; /** stores a cookie that is used by apache to decide which manifest ot send */ diff --git a/docs/app/test/docsSpec.js b/docs/app/test/docsSpec.js new file mode 100644 index 000000000000..ea6c6ba930aa --- /dev/null +++ b/docs/app/test/docsSpec.js @@ -0,0 +1,33 @@ +describe("DocsController", function() { + var $scope; + + angular.module('fake', []) + .value('$cookies', {}) + .value('NG_PAGES', {}) + .value('NG_NAVIGATION', {}) + .value('NG_VERSION', {}); + + beforeEach(module('fake', 'DocsController')); + beforeEach(inject(function($rootScope, $controller) { + $scope = $rootScope; + $controller('DocsController', { $scope: $scope }); + })); + + + describe('afterPartialLoaded', function() { + it("should update the Google Analytics with currentPage path if currentPage exists", inject(function($window) { + $window._gaq = []; + $scope.currentPage = { path: 'a/b/c' }; + $scope.afterPartialLoaded(); + expect($window._gaq.pop()).toEqual(['_trackPageview', 'a/b/c']); + })); + + + it("should update the Google Analytics with $location.path if currentPage is missing", inject(function($window, $location) { + $window._gaq = []; + spyOn($location, 'path').andReturn('x/y/z'); + $scope.afterPartialLoaded(); + expect($window._gaq.pop()).toEqual(['_trackPageview', 'x/y/z']); + })); + }); +}); \ No newline at end of file diff --git a/gen_docs.sh b/gen_docs.sh deleted file mode 100755 index 039daa4670b2..000000000000 --- a/gen_docs.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -JASMINE_NODE='jasmine-node' -local_jasmine='./node_modules/.bin/jasmine-node' - -if ! type -p "$JASMINE_NODE" >/dev/null 2>&1;then - if [[ -x "$local_jasmine" ]];then - JASMINE_NODE="$local_jasmine" - else - echo 'Could not find a locally or globally installed executable of' \ - 'jasmine-node. Try: `npm install jasmine-node`.' >&2 - exit 1 - fi -fi - -if [[ ! -e gen_docs.disable ]]; then - echo 'Testing, then building documentation...' - "$JASMINE_NODE" docs/spec --noColor && node docs/src/gen-docs.js -fi diff --git a/jenkins_build.sh b/jenkins_build.sh index 2dc69cbceed2..806eb0f2c95f 100755 --- a/jenkins_build.sh +++ b/jenkins_build.sh @@ -24,15 +24,15 @@ grunt ci-checks package --no-color mkdir -p test_out -# DOCS generator unit tests # -grunt test:docgen --no-color - # UNIT TESTS # grunt test:unit --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color # END TO END TESTS # grunt test:ci-protractor +# DOCS APP TESTS # +grunt test:docs --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color + # Promises/A+ TESTS # grunt test:promises-aplus --no-color diff --git a/karma-docs.conf.js b/karma-docs.conf.js index c27e33971e2e..ea9dfb26a29e 100644 --- a/karma-docs.conf.js +++ b/karma-docs.conf.js @@ -5,29 +5,10 @@ module.exports = function(config) { config.set({ files: [ - 'build/docs/components/jquery.js', - 'test/jquery_remove.js', - 'build/angular.js', - 'build/angular-cookies.js', - 'build/angular-resource.js', - 'build/angular-touch.js', - 'build/angular-sanitize.js', - 'build/angular-route.js', - 'build/angular-animate.js', 'build/angular-mocks.js', - - 'build/docs/components/lunr.js', - 'build/docs/components/google-code-prettify.js', - 'build/docs/components/marked.js', - - 'build/docs/components/angular-bootstrap.js', - 'build/docs/components/angular-bootstrap-prettify.js', - 'build/docs/js/docs.js', - 'build/docs/docs-data.js', - - 'docs/component-spec/mocks.js', - 'docs/component-spec/*.js' + 'docs/app/src/**/*.js', + 'docs/app/test/**/*Spec.js' ], junitReporter: { diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 9a0d268fff7b..c3879a7f2ccc 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -6,9 +6,9 @@ export SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev` if [ $JOB = "unit" ]; then grunt ci-checks - #grunt test:docgen grunt test:promises-aplus grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots + grunt test:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots elif [ $JOB = "e2e" ]; then export GRUNT_TARGET="test:protractor" if [ $JQVERSION = "jquery" ]; then