From 5fe1832b4dffb2342c7510d06f59847f185b9f5f Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Fri, 10 Oct 2014 12:29:16 -0400 Subject: [PATCH 01/14] chore(protractor): rename docs e2e test suite with `-docs` suffix Due to the need to create a non-docs set of E2E tests, these are being moved. The old grunt commands will eventually be replaced with an alias which invokes both the simple E2E tests as well as the docs E2E tests. --- Gruntfile.js | 13 +++++++------ jenkins_build.sh | 2 +- lib/grunt/plugins.js | 2 +- scripts/travis/build.sh | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index fab8e27e743e..7c6fb49d0c12 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -101,7 +101,7 @@ module.exports = function(grunt) { }, - protractor: { + 'protractor-docs': { normal: 'protractor-conf.js', travis: 'protractor-travis-conf.js', jenkins: 'protractor-jenkins-conf.js' @@ -318,16 +318,17 @@ module.exports = function(grunt) { //alias tasks - grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor']); + grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor-docs']); 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: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:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']); - grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']); - grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']); + grunt.registerTask('test:protractor-docs', 'Run the end to end docs tests with Protractor and keep a test server running in the background', + ['webdriver', 'connect:testserver', 'protractor-docs:normal']); + grunt.registerTask('test:travis-protractor-docs', 'Run the end to end docs tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor-docs:travis']); + grunt.registerTask('test:ci-protractor-docs', 'Run the end to end docs tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor-docs:jenkins']); + grunt.registerTask('test:docs-e2e', 'Alias for test:protractor', ['test:protractor-docs']); grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']); grunt.registerTask('minify', ['bower','clean', 'build', 'minall']); diff --git a/jenkins_build.sh b/jenkins_build.sh index ea94a9d1a873..d8414d4ea119 100755 --- a/jenkins_build.sh +++ b/jenkins_build.sh @@ -28,7 +28,7 @@ mkdir -p test_out grunt test:unit --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color # END TO END TESTS # -grunt test:ci-protractor +grunt test:ci-protractor-docs # DOCS APP TESTS # grunt test:docs --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color diff --git a/lib/grunt/plugins.js b/lib/grunt/plugins.js index cbf32cf360c7..7fe22d6752c7 100644 --- a/lib/grunt/plugins.js +++ b/lib/grunt/plugins.js @@ -57,7 +57,7 @@ module.exports = function(grunt) { util.updateWebdriver.call(util, this.async()); }); - grunt.registerMultiTask('protractor', 'Run Protractor integration tests', function() { + grunt.registerMultiTask('protractor-docs', 'Run Protractor integration tests', function() { util.startProtractor.call(util, this.data, this.async()); }); diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 658c146eb072..aa972f772c04 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -9,13 +9,13 @@ if [ $JOB = "unit" ]; then grunt test:promises-aplus grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots - grunt test:travis-protractor --specs "docs/app/e2e/**/*.scenario.js" + grunt test:travis-protractor-docs --specs "docs/app/e2e/**/*.scenario.js" elif [ $JOB = "e2e" ]; then export TARGET_SPECS="build/docs/ptore2e/**/default_test.js" if [ $TEST_TARGET = "jquery" ]; then TARGET_SPECS="build/docs/ptore2e/**/jquery_test.js" fi - grunt test:travis-protractor --specs "$TARGET_SPECS" + grunt test:travis-protractor-docs --specs "$TARGET_SPECS" else echo "Unknown job type. Please set JOB=unit or JOB=e2e-*." fi From edd23468a64607aeb51dece65ac66c7d1b6b98be Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 13:54:45 -0400 Subject: [PATCH 02/14] chore(package.json): add cheerio dependency It's tinier than jsdom, and seems to work okay for generating the fixtures. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ecc7d1a57fd9..5298f8c5327e 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,8 @@ "semver": "~4.0.3", "shelljs": "~0.3.0", "sorted-object": "^1.0.0", - "stringmap": "^0.2.2" + "stringmap": "^0.2.2", + "cheerio": "^0.17.0" }, "licenses": [ { From ebb55a8f0ce8390be6f13a47ad2373222eab6024 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 13:58:24 -0400 Subject: [PATCH 03/14] WIP: implement e2e test harness This is a work in progress, still trying to make the server do everything it should do. --- Gruntfile.js | 3 ++ test/e2e/templates/test.html | 23 +++++++++++ test/e2e/tests/sample/index.html | 5 +++ test/e2e/tests/sample/sample.json | 3 ++ test/e2e/tools/.jshintrc | 3 ++ test/e2e/tools/fixture.js | 68 +++++++++++++++++++++++++++++++ test/e2e/tools/index.js | 5 +++ test/e2e/tools/middleware.js | 32 +++++++++++++++ test/e2e/tools/util.js | 15 +++++++ 9 files changed, 157 insertions(+) create mode 100644 test/e2e/templates/test.html create mode 100644 test/e2e/tests/sample/index.html create mode 100644 test/e2e/tests/sample/sample.json create mode 100644 test/e2e/tools/.jshintrc create mode 100644 test/e2e/tools/fixture.js create mode 100644 test/e2e/tools/index.js create mode 100644 test/e2e/tools/middleware.js create mode 100644 test/e2e/tools/util.js diff --git a/Gruntfile.js b/Gruntfile.js index 7c6fb49d0c12..62c0f1a0720d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,6 +4,7 @@ var files = require('./angularFiles').files; var util = require('./lib/grunt/utils.js'); var versionInfo = require('./lib/versions/version-info'); var path = require('path'); +var e2e = require('./test/e2e/tools'); module.exports = function(grunt) { //grunt plugins @@ -50,6 +51,7 @@ module.exports = function(grunt) { return [ util.conditionalCsp(), util.rewrite(), + e2e.middleware(), connect.favicon('images/favicon.ico'), connect.static(base), connect.directory(base) @@ -75,6 +77,7 @@ module.exports = function(grunt) { next(); }, + e2e.middleware(), util.conditionalCsp(), connect.favicon('images/favicon.ico'), connect.static(base) diff --git a/test/e2e/templates/test.html b/test/e2e/templates/test.html new file mode 100644 index 000000000000..2eec4e7ce621 --- /dev/null +++ b/test/e2e/templates/test.html @@ -0,0 +1,23 @@ + +{% if eq(test.ngAppTag, "html") %} + +{% else %} + +{% endif %} + + {% if scripts.jQuery %} + + {% endif %} + {% for script in test.scripts %} + + {% endfor %} + {{ test.head }} + + {% if test.ngAppTag === "body" %} + + {% else %} + + {% endif %} + {% test.body %} + + diff --git a/test/e2e/tests/sample/index.html b/test/e2e/tests/sample/index.html new file mode 100644 index 000000000000..e24f0cb07461 --- /dev/null +++ b/test/e2e/tests/sample/index.html @@ -0,0 +1,5 @@ + + +

Hello!

+ + diff --git a/test/e2e/tests/sample/sample.json b/test/e2e/tests/sample/sample.json new file mode 100644 index 000000000000..374693e21324 --- /dev/null +++ b/test/e2e/tests/sample/sample.json @@ -0,0 +1,3 @@ +{ + "good": true +} \ No newline at end of file diff --git a/test/e2e/tools/.jshintrc b/test/e2e/tools/.jshintrc new file mode 100644 index 000000000000..6cf513eebee9 --- /dev/null +++ b/test/e2e/tools/.jshintrc @@ -0,0 +1,3 @@ +{ + "node": true +} \ No newline at end of file diff --git a/test/e2e/tools/fixture.js b/test/e2e/tools/fixture.js new file mode 100644 index 000000000000..8a1723328f0e --- /dev/null +++ b/test/e2e/tools/fixture.js @@ -0,0 +1,68 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var $ = require('cheerio'); + +var root = path.resolve(__dirname, '..'); +var tests = path.resolve(root, 'tests'); + +var projectRoot = path.resolve(__dirname, '../../..'); +var build = path.resolve(projectRoot, 'build'); + +function rewriteAngularSrc(src, query) { + if (query) { + if (query.build) { + return query.build + '/' + src; + } else if (query.cdn) { + return '//ajax.googleapis.com/ajax/libs/angularjs/' + query.cdn + '/' + src; + } + } + return '/build/' + src; +} + +function generateFixture(test, query) { + var indexFile = path.resolve(tests, test, 'index.html'); + var text = fs.readFileSync(indexFile, 'utf8'); + + var $$ = $.load(text); + + var firstScript = null; + var jquery = null; + var angular = null; + $$('script').each(function(i, script) { + var src = $(script).attr('src'); + if (src === 'jquery.js' && jquery === null) jquery = script; + else if (src === 'angular.js' && angular === null) angular = script; + if (firstScript === null) firstScript = script; + if (src) { + if (fs.statSync(path.resolve(build, src))) { + $(script).attr('src', rewriteAngularSrc(src, query)); + } + } + }); + + if (jquery && (!('jquery' in query) || (/^(0|no|false|off|n)$/i).test(query.jquery))) { + $(jquery).remove(); + } else if (query.jquery) { + if (!jquery) { + jquery = $.load('')[0]; + if (firstScript) { + $(firstScript).prepend(jquery); + } else { + $($$).first().before(jquery); + } + } + if (!/^\d+\.\d+.*$/.test(query.jquery)) { + $(jquery).attr('src', '/bower_components/jquery/dist/jquery.js'); + } else { + $(jquery).attr('src', '//ajax.googleapis.com/ajax/libs/jquery/' + query.jquery + '/jquery.js'); + } + } + + return $$.html(); +} + +module.exports = { + generate: generateFixture +}; diff --git a/test/e2e/tools/index.js b/test/e2e/tools/index.js new file mode 100644 index 000000000000..45f3d1284291 --- /dev/null +++ b/test/e2e/tools/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + middleware: require('./middleware') +}; diff --git a/test/e2e/tools/middleware.js b/test/e2e/tools/middleware.js new file mode 100644 index 000000000000..2437057f8343 --- /dev/null +++ b/test/e2e/tools/middleware.js @@ -0,0 +1,32 @@ +'use strict'; + +var url = require('url'); +var util = require('./util'); +var fixture = require('./fixture'); + +module.exports = middlewareFactory; + +function middlewareFactory(base) { + base = base || '/e2e'; + while (base.length && base[base.length-1] === '/') base = base.slice(0, base.length-1); + var fixture_regexp = new RegExp('^' + base + '/tests/([a-zA-Z0-9_-]+)(/(index.html)?)?$'); + + return function(req, res, next) { + var match; + if ((match = fixture_regexp.exec(req.url))) { + if (util.testExists(match[1])) { + try { + var query = url.parse(req.url, true).query; + res.write(fixture.generate(match[1], query)); + res.end(); + } catch (e) { + return next(e); + } + } else { + return next(new Error('Test ' + match[1] + ' not found.')); + } + } else { + return next(); + } + }; +} diff --git a/test/e2e/tools/util.js b/test/e2e/tools/util.js new file mode 100644 index 000000000000..c4a01bc4a8cf --- /dev/null +++ b/test/e2e/tools/util.js @@ -0,0 +1,15 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var url = require('url'); + +var root = path.resolve(__dirname, '..'); +var tests = path.resolve(root, 'tests'); + +module.exports = { + testExists: function(testname) { + testname = path.resolve(tests, testname); + return fs.statSync(testname).isDirectory(); + } +}; From a0db029d48f9602770a203098d1cf83d8a3622cb Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 14:23:49 -0400 Subject: [PATCH 04/14] WIP: also serve static files from test directories --- test/e2e/tools/middleware.js | 16 ++++++++++++++-- test/e2e/tools/util.js | 11 +++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/test/e2e/tools/middleware.js b/test/e2e/tools/middleware.js index 2437057f8343..904e22e0e14f 100644 --- a/test/e2e/tools/middleware.js +++ b/test/e2e/tools/middleware.js @@ -10,10 +10,16 @@ function middlewareFactory(base) { base = base || '/e2e'; while (base.length && base[base.length-1] === '/') base = base.slice(0, base.length-1); var fixture_regexp = new RegExp('^' + base + '/tests/([a-zA-Z0-9_-]+)(/(index.html)?)?$'); + var static_regexp = new RegExp('^' + base + '/tests/([a-zA-Z0-9_-]+)(/.*)$'); return function(req, res, next) { var match; - if ((match = fixture_regexp.exec(req.url))) { + var basicUrl = req.url; + var idx = basicUrl.indexOf('?'); + if (idx >= 0) { + basicUrl = basicUrl.slice(0, idx); + } + if ((match = fixture_regexp.exec(basicUrl))) { if (util.testExists(match[1])) { try { var query = url.parse(req.url, true).query; @@ -23,8 +29,14 @@ function middlewareFactory(base) { return next(e); } } else { - return next(new Error('Test ' + match[1] + ' not found.')); + return next('Test ' + match[1] + ' not found.'); + } + } else if ((match = static_regexp.exec(basicUrl))) { + var rewritten = util.rewriteTestFile(match[1], match[2]); + if (rewritten !== false) { + req.url = rewritten; } + next(); } else { return next(); } diff --git a/test/e2e/tools/util.js b/test/e2e/tools/util.js index c4a01bc4a8cf..6d5d6cf8f0c8 100644 --- a/test/e2e/tools/util.js +++ b/test/e2e/tools/util.js @@ -11,5 +11,16 @@ module.exports = { testExists: function(testname) { testname = path.resolve(tests, testname); return fs.statSync(testname).isDirectory(); + }, + + rewriteTestFile: function(testname, testfile) { + var i = 0; + while (testfile[i] === '/') ++i; + testfile = testfile.slice(i); + var stat = fs.statSync(path.resolve(tests, testname, testfile)); + if (stat && stat.isFile() || stat.isDirectory()) { + return ['/test/e2e/tests', testname, testfile].join('/'); + } + return false; } }; From d71f56d23db99e5454f28edb30bc255e92d131fb Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 14:29:43 -0400 Subject: [PATCH 05/14] WIP: statSync can throw. --- test/e2e/tests/sample/index.html | 6 ++++- test/e2e/tests/sample/sample.json | 3 --- test/e2e/tests/sample/script.js | 4 +++ test/e2e/tools/fixture.js | 4 ++- test/e2e/tools/util.js | 43 +++++++++++++++++++++---------- 5 files changed, 41 insertions(+), 19 deletions(-) delete mode 100644 test/e2e/tests/sample/sample.json create mode 100644 test/e2e/tests/sample/script.js diff --git a/test/e2e/tests/sample/index.html b/test/e2e/tests/sample/index.html index e24f0cb07461..45e8747fa931 100644 --- a/test/e2e/tests/sample/index.html +++ b/test/e2e/tests/sample/index.html @@ -1,5 +1,9 @@ -

Hello!

+
+

{{text}}

+
+ + diff --git a/test/e2e/tests/sample/sample.json b/test/e2e/tests/sample/sample.json deleted file mode 100644 index 374693e21324..000000000000 --- a/test/e2e/tests/sample/sample.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "good": true -} \ No newline at end of file diff --git a/test/e2e/tests/sample/script.js b/test/e2e/tests/sample/script.js new file mode 100644 index 000000000000..2d625bb4f19c --- /dev/null +++ b/test/e2e/tests/sample/script.js @@ -0,0 +1,4 @@ +angular.module("test", []). + controller("TestCtrl", function($scope) { + $scope.text = "Hello, world!"; + }); diff --git a/test/e2e/tools/fixture.js b/test/e2e/tools/fixture.js index 8a1723328f0e..f5c3182ccfcb 100644 --- a/test/e2e/tools/fixture.js +++ b/test/e2e/tools/fixture.js @@ -3,6 +3,7 @@ var fs = require('fs'); var path = require('path'); var $ = require('cheerio'); +var util = require('./util'); var root = path.resolve(__dirname, '..'); var tests = path.resolve(root, 'tests'); @@ -36,7 +37,8 @@ function generateFixture(test, query) { else if (src === 'angular.js' && angular === null) angular = script; if (firstScript === null) firstScript = script; if (src) { - if (fs.statSync(path.resolve(build, src))) { + var s = util.stat(path.resolve(build, src)); + if (s && s.isFile()) { $(script).attr('src', rewriteAngularSrc(src, query)); } } diff --git a/test/e2e/tools/util.js b/test/e2e/tools/util.js index 6d5d6cf8f0c8..f807ae7ef65a 100644 --- a/test/e2e/tools/util.js +++ b/test/e2e/tools/util.js @@ -7,20 +7,35 @@ var url = require('url'); var root = path.resolve(__dirname, '..'); var tests = path.resolve(root, 'tests'); -module.exports = { - testExists: function(testname) { - testname = path.resolve(tests, testname); - return fs.statSync(testname).isDirectory(); - }, - - rewriteTestFile: function(testname, testfile) { - var i = 0; - while (testfile[i] === '/') ++i; - testfile = testfile.slice(i); - var stat = fs.statSync(path.resolve(tests, testname, testfile)); - if (stat && stat.isFile() || stat.isDirectory()) { - return ['/test/e2e/tests', testname, testfile].join('/'); +function stat(path) { + try { + return fs.statSync(path); + } catch (e) { + // Ignore ENOENT. + if (e.code !== 'ENOENT') { + throw e; } - return false; } +} + +function testExists(testname) { + var s = stat(path.resolve(tests, testname)); + return s && s.isDirectory(); +} + +function rewriteTestFile(testname, testfile) { + var i = 0; + while (testfile[i] === '/') ++i; + testfile = testfile.slice(i); + var s = stat(path.resolve(tests, testname, testfile)); + if (s && s.isFile() || s.isDirectory()) { + return ['/test/e2e/tests', testname, testfile].join('/'); + } + return false; +} + +module.exports = { + stat: stat, + testExists: testExists, + rewriteTestFile: rewriteTestFile }; From 74e7401f40a513e960652a008a8951e9d3f2e10f Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 14:54:05 -0400 Subject: [PATCH 06/14] WIP: fix conditional insertion of jquery --- test/e2e/tools/fixture.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/test/e2e/tools/fixture.js b/test/e2e/tools/fixture.js index f5c3182ccfcb..39f4d0f84ea0 100644 --- a/test/e2e/tools/fixture.js +++ b/test/e2e/tools/fixture.js @@ -46,19 +46,30 @@ function generateFixture(test, query) { if (jquery && (!('jquery' in query) || (/^(0|no|false|off|n)$/i).test(query.jquery))) { $(jquery).remove(); - } else if (query.jquery) { - if (!jquery) { - jquery = $.load('')[0]; - if (firstScript) { - $(firstScript).prepend(jquery); - } else { - $($$).first().before(jquery); + } else if ('jquery' in query) { + if ((/^(0|no|false|off|n)$/i).test(query.jquery)) { + if (jquery) { + $(jquery).remove(); } - } - if (!/^\d+\.\d+.*$/.test(query.jquery)) { - $(jquery).attr('src', '/bower_components/jquery/dist/jquery.js'); } else { - $(jquery).attr('src', '//ajax.googleapis.com/ajax/libs/jquery/' + query.jquery + '/jquery.js'); + if (!jquery) { + jquery = $.load('')('script')[0]; + if (firstScript) { + $(firstScript).before(jquery); + } else { + var head = $$('head'); + if (head.length) { + head.prepend(jquery); + } else { + $$.root().first().before(jquery); + } + } + } + if (!/^\d+\.\d+.*$/.test(query.jquery)) { + $(jquery).attr('src', '/bower_components/jquery/dist/jquery.js'); + } else { + $(jquery).attr('src', '//ajax.googleapis.com/ajax/libs/jquery/' + query.jquery + '/jquery.js'); + } } } From b6660eb17fb289217bb85e47f6a0caf5bd67e546 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 14:58:14 -0400 Subject: [PATCH 07/14] WIP: move fixtures into fixtures directory --- test/e2e/{tests => fixtures}/sample/index.html | 0 test/e2e/{tests => fixtures}/sample/script.js | 0 test/e2e/tools/fixture.js | 4 ++-- test/e2e/tools/middleware.js | 6 +++--- test/e2e/tools/util.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) rename test/e2e/{tests => fixtures}/sample/index.html (100%) rename test/e2e/{tests => fixtures}/sample/script.js (100%) diff --git a/test/e2e/tests/sample/index.html b/test/e2e/fixtures/sample/index.html similarity index 100% rename from test/e2e/tests/sample/index.html rename to test/e2e/fixtures/sample/index.html diff --git a/test/e2e/tests/sample/script.js b/test/e2e/fixtures/sample/script.js similarity index 100% rename from test/e2e/tests/sample/script.js rename to test/e2e/fixtures/sample/script.js diff --git a/test/e2e/tools/fixture.js b/test/e2e/tools/fixture.js index 39f4d0f84ea0..accf84beda38 100644 --- a/test/e2e/tools/fixture.js +++ b/test/e2e/tools/fixture.js @@ -6,7 +6,7 @@ var $ = require('cheerio'); var util = require('./util'); var root = path.resolve(__dirname, '..'); -var tests = path.resolve(root, 'tests'); +var fixtures = path.resolve(root, 'fixtures'); var projectRoot = path.resolve(__dirname, '../../..'); var build = path.resolve(projectRoot, 'build'); @@ -23,7 +23,7 @@ function rewriteAngularSrc(src, query) { } function generateFixture(test, query) { - var indexFile = path.resolve(tests, test, 'index.html'); + var indexFile = path.resolve(fixtures, test, 'index.html'); var text = fs.readFileSync(indexFile, 'utf8'); var $$ = $.load(text); diff --git a/test/e2e/tools/middleware.js b/test/e2e/tools/middleware.js index 904e22e0e14f..39e88a176bab 100644 --- a/test/e2e/tools/middleware.js +++ b/test/e2e/tools/middleware.js @@ -9,8 +9,8 @@ module.exports = middlewareFactory; function middlewareFactory(base) { base = base || '/e2e'; while (base.length && base[base.length-1] === '/') base = base.slice(0, base.length-1); - var fixture_regexp = new RegExp('^' + base + '/tests/([a-zA-Z0-9_-]+)(/(index.html)?)?$'); - var static_regexp = new RegExp('^' + base + '/tests/([a-zA-Z0-9_-]+)(/.*)$'); + var fixture_regexp = new RegExp('^' + base + '/fixtures/([a-zA-Z0-9_-]+)(/(index.html)?)?$'); + var static_regexp = new RegExp('^' + base + '/fixtures/([a-zA-Z0-9_-]+)(/.*)$'); return function(req, res, next) { var match; @@ -29,7 +29,7 @@ function middlewareFactory(base) { return next(e); } } else { - return next('Test ' + match[1] + ' not found.'); + return next('Fixture ' + match[1] + ' not found.'); } } else if ((match = static_regexp.exec(basicUrl))) { var rewritten = util.rewriteTestFile(match[1], match[2]); diff --git a/test/e2e/tools/util.js b/test/e2e/tools/util.js index f807ae7ef65a..9018baebf5d6 100644 --- a/test/e2e/tools/util.js +++ b/test/e2e/tools/util.js @@ -5,7 +5,7 @@ var path = require('path'); var url = require('url'); var root = path.resolve(__dirname, '..'); -var tests = path.resolve(root, 'tests'); +var tests = path.resolve(root, 'fixtures'); function stat(path) { try { @@ -29,7 +29,7 @@ function rewriteTestFile(testname, testfile) { testfile = testfile.slice(i); var s = stat(path.resolve(tests, testname, testfile)); if (s && s.isFile() || s.isDirectory()) { - return ['/test/e2e/tests', testname, testfile].join('/'); + return ['/test/e2e/fixtures', testname, testfile].join('/'); } return false; } From 2d8a442eb74e596c3035d5220496882ab388347d Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 15:02:00 -0400 Subject: [PATCH 08/14] WIP: add .jshintrc files for fixtures and tests directory --- test/e2e/fixtures/.jshintrc | 11 +++++++++++ test/e2e/tests/.jshintrc | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/e2e/fixtures/.jshintrc create mode 100644 test/e2e/tests/.jshintrc diff --git a/test/e2e/fixtures/.jshintrc b/test/e2e/fixtures/.jshintrc new file mode 100644 index 000000000000..6c3d5f06d51f --- /dev/null +++ b/test/e2e/fixtures/.jshintrc @@ -0,0 +1,11 @@ +{ + "node": true, + "globals": { + "describe": false, + "ddescribe": false, + "xdescribe": false, + "it": false, + "xit": false, + "iit": false, + } +} diff --git a/test/e2e/tests/.jshintrc b/test/e2e/tests/.jshintrc new file mode 100644 index 000000000000..f3f63911e866 --- /dev/null +++ b/test/e2e/tests/.jshintrc @@ -0,0 +1,8 @@ +{ + "browser": true, + "globals": { + "angular": false, + "jQuery": false, + "$": false + } +} From e120f8814cbeadb4a7c99f306eafd448ff731ff1 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 15:24:47 -0400 Subject: [PATCH 09/14] WIP: add protractor grunt task + configs for running E2E specs --- Gruntfile.js | 7 ++++++ lib/grunt/plugins.js | 6 +++++- protractor-e2e-jenkins.conf.js | 39 ++++++++++++++++++++++++++++++++++ protractor-e2e-travis.conf.js | 39 ++++++++++++++++++++++++++++++++++ protractor-e2e.conf.js | 15 +++++++++++++ protractor-jenkins-conf.js | 2 +- 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 protractor-e2e-jenkins.conf.js create mode 100644 protractor-e2e-travis.conf.js create mode 100644 protractor-e2e.conf.js diff --git a/Gruntfile.js b/Gruntfile.js index 62c0f1a0720d..6572755b2407 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -111,6 +111,13 @@ module.exports = function(grunt) { }, + protractor: { + normal: 'protractor-e2e.conf.js', + travis: 'protractor-e2e-travis.conf.js', + jenkins: 'protractor-e2e-jenkins.conf.js' + }, + + clean: { build: ['build'], tmp: ['tmp'] diff --git a/lib/grunt/plugins.js b/lib/grunt/plugins.js index 7fe22d6752c7..65f49fdd93ce 100644 --- a/lib/grunt/plugins.js +++ b/lib/grunt/plugins.js @@ -57,7 +57,11 @@ module.exports = function(grunt) { util.updateWebdriver.call(util, this.async()); }); - grunt.registerMultiTask('protractor-docs', 'Run Protractor integration tests', function() { + grunt.registerMultiTask('protractor-docs', 'Run Protractor Docs integration tests', function() { + util.startProtractor.call(util, this.data, this.async()); + }); + + grunt.registerMultiTask('protractor', 'Run Protractor E2E tests', function() { util.startProtractor.call(util, this.data, this.async()); }); diff --git a/protractor-e2e-jenkins.conf.js b/protractor-e2e-jenkins.conf.js new file mode 100644 index 000000000000..539b5d5a8a86 --- /dev/null +++ b/protractor-e2e-jenkins.conf.js @@ -0,0 +1,39 @@ +'use strict'; + +exports.config = { + allScriptsTimeout: 11000, + + specs: [ + 'test/e2e/tests/**/*.js' + ], + + capabilities: { + 'browserName': 'chrome' + }, + + baseUrl: 'http://localhost:8000/e2e/', + + framework: 'jasmine', + + onPrepare: function() { + /* global angular: false, browser: false, jasmine: false */ + + // Disable animations so e2e tests run more quickly + var disableNgAnimate = function() { + angular.module('disableNgAnimate', []).run(['$animate', function($animate) { + $animate.enabled(false); + }]); + }; + + browser.addMockModule('disableNgAnimate', disableNgAnimate); + + require('jasmine-reporters'); + jasmine.getEnv().addReporter( + new jasmine.JUnitXmlReporter('test_out/e2e-' + exports.config.capabilities.browserName + '-', true, true)); + }, + + jasmineNodeOpts: { + defaultTimeoutInterval: 30000, + showColors: false + } +}; diff --git a/protractor-e2e-travis.conf.js b/protractor-e2e-travis.conf.js new file mode 100644 index 000000000000..75843527bb33 --- /dev/null +++ b/protractor-e2e-travis.conf.js @@ -0,0 +1,39 @@ +'use strict'; + +var config = require('./protractor-shared-conf').config; + +config.sauceUser = process.env.SAUCE_USERNAME; +config.sauceKey = process.env.SAUCE_ACCESS_KEY; + +config.multiCapabilities = [{ + 'browserName': 'chrome', + 'platform': 'OS X 10.9', + 'name': 'Angular E2E', + 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, + 'build': process.env.TRAVIS_BUILD_NUMBER, + 'version': '34' +}, { + 'browserName': 'firefox', + 'name': 'Angular E2E', + 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, + 'build': process.env.TRAVIS_BUILD_NUMBER, + 'version': '28' +}, { + browserName: 'safari', + 'platform': 'OS X 10.9', + 'version': '7', + 'name': 'Angular E2E', + 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, + 'build': process.env.TRAVIS_BUILD_NUMBER +}]; + +config.specs = [ + 'test/e2e/tests/**/*.js' +]; + +config.baseUrl = 'http://localhost:8000/e2e/'; + +config.allScriptsTimeout = 30000; +config.getPageTimeout = 30000; + +exports.config = config; diff --git a/protractor-e2e.conf.js b/protractor-e2e.conf.js new file mode 100644 index 000000000000..df7b47de807a --- /dev/null +++ b/protractor-e2e.conf.js @@ -0,0 +1,15 @@ +'use strict'; + +var config = require('./protractor-shared-conf').config; + +config.specs = [ + 'test/e2e/tests/**/*.js' +]; + +config.baseUrl = 'http://localhost:8000/e2e/'; + +config.capabilities = { + browserName: 'chrome', +}; + +exports.config = config; diff --git a/protractor-jenkins-conf.js b/protractor-jenkins-conf.js index 64b67a2644ae..2ac402ec8225 100644 --- a/protractor-jenkins-conf.js +++ b/protractor-jenkins-conf.js @@ -30,7 +30,7 @@ exports.config = { require('jasmine-reporters'); jasmine.getEnv().addReporter( - new jasmine.JUnitXmlReporter('test_out/e2e-' + exports.config.capabilities.browserName + '-', true, true)); + new jasmine.JUnitXmlReporter('test_out/docs-e2e-' + exports.config.capabilities.browserName + '-', true, true)); }, jasmineNodeOpts: { From 061f1783aa87e664e1553dc3e7c8bdcd409bf0c8 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 15:56:14 -0400 Subject: [PATCH 10/14] WIP: add sample tests --- protractor-e2e-jenkins.conf.js | 5 +++-- protractor-e2e-travis.conf.js | 5 +++-- protractor-e2e.conf.js | 5 +++-- test/e2e/tests/helpers/main.js | 19 +++++++++++++++++++ test/e2e/tests/sampleSpec.js | 12 ++++++++++++ 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 test/e2e/tests/helpers/main.js create mode 100644 test/e2e/tests/sampleSpec.js diff --git a/protractor-e2e-jenkins.conf.js b/protractor-e2e-jenkins.conf.js index 539b5d5a8a86..1551a11be116 100644 --- a/protractor-e2e-jenkins.conf.js +++ b/protractor-e2e-jenkins.conf.js @@ -4,14 +4,15 @@ exports.config = { allScriptsTimeout: 11000, specs: [ - 'test/e2e/tests/**/*.js' + 'test/e2e/tests/helpers/**/*.js', + 'test/e2e/tests/**/*Spec.js' ], capabilities: { 'browserName': 'chrome' }, - baseUrl: 'http://localhost:8000/e2e/', + baseUrl: 'http://localhost:8000/', framework: 'jasmine', diff --git a/protractor-e2e-travis.conf.js b/protractor-e2e-travis.conf.js index 75843527bb33..12254eaf4ff6 100644 --- a/protractor-e2e-travis.conf.js +++ b/protractor-e2e-travis.conf.js @@ -28,10 +28,11 @@ config.multiCapabilities = [{ }]; config.specs = [ - 'test/e2e/tests/**/*.js' + 'test/e2e/tests/helpers/**/*.js', + 'test/e2e/tests/**/*Spec.js' ]; -config.baseUrl = 'http://localhost:8000/e2e/'; +config.baseUrl = 'http://localhost:8000/'; config.allScriptsTimeout = 30000; config.getPageTimeout = 30000; diff --git a/protractor-e2e.conf.js b/protractor-e2e.conf.js index df7b47de807a..a3718ec072a1 100644 --- a/protractor-e2e.conf.js +++ b/protractor-e2e.conf.js @@ -3,10 +3,11 @@ var config = require('./protractor-shared-conf').config; config.specs = [ - 'test/e2e/tests/**/*.js' + 'test/e2e/tests/helpers/**/*.js', + 'test/e2e/tests/**/*Spec.js' ]; -config.baseUrl = 'http://localhost:8000/e2e/'; +config.baseUrl = 'http://localhost:8000/'; config.capabilities = { browserName: 'chrome', diff --git a/test/e2e/tests/helpers/main.js b/test/e2e/tests/helpers/main.js new file mode 100644 index 000000000000..fcbdca9ad0ce --- /dev/null +++ b/test/e2e/tests/helpers/main.js @@ -0,0 +1,19 @@ +var helper = { + andWaitForAngular: function() { + browser.waitForAngular(); + }, + loadFixture: function(fixture) { + var i = 0; + while (fixture[i] === '/') ++i; + fixture = fixture.slice(i); + if (!/\/(index\.html)?$/.test(fixture)) { + fixture += '/'; + } + + browser.get('/e2e/fixtures/' + fixture); + return helper; + } +}; + +global.test = helper; +global.loadFixture = helper.loadFixture; diff --git a/test/e2e/tests/sampleSpec.js b/test/e2e/tests/sampleSpec.js new file mode 100644 index 000000000000..07cdec659e7e --- /dev/null +++ b/test/e2e/tests/sampleSpec.js @@ -0,0 +1,12 @@ +// Sample E2E test: +// +describe('Sample', function() { + beforeEach(function() { + loadFixture("sample").andWaitForAngular(); + }); + + it('should have the interpolated text', function() { + expect(element(by.binding('text')).getText()) + .toBe('Hello, world!'); + }); +}); From 9e68babf030c69f05ce92604807bf8c1f732325c Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 15:58:39 -0400 Subject: [PATCH 11/14] WIP: fix .jshintrc files and add test:e2e task for the basic e2e tests --- Gruntfile.js | 2 ++ test/e2e/fixtures/.jshintrc | 11 ++++------- test/e2e/tests/.jshintrc | 11 +++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6572755b2407..e9813479b0ce 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -334,6 +334,8 @@ module.exports = function(grunt) { 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:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']); + grunt.registerTask('test:e2e', 'Run E2E tests with Protractor with a test server running in the background', + ['webdriver', 'connect:testserver', 'protractor:normal']); grunt.registerTask('test:protractor-docs', 'Run the end to end docs tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor-docs:normal']); grunt.registerTask('test:travis-protractor-docs', 'Run the end to end docs tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor-docs:travis']); diff --git a/test/e2e/fixtures/.jshintrc b/test/e2e/fixtures/.jshintrc index 6c3d5f06d51f..f3f63911e866 100644 --- a/test/e2e/fixtures/.jshintrc +++ b/test/e2e/fixtures/.jshintrc @@ -1,11 +1,8 @@ { - "node": true, + "browser": true, "globals": { - "describe": false, - "ddescribe": false, - "xdescribe": false, - "it": false, - "xit": false, - "iit": false, + "angular": false, + "jQuery": false, + "$": false } } diff --git a/test/e2e/tests/.jshintrc b/test/e2e/tests/.jshintrc index f3f63911e866..9ddc0db3923a 100644 --- a/test/e2e/tests/.jshintrc +++ b/test/e2e/tests/.jshintrc @@ -1,8 +1,11 @@ { - "browser": true, + "node": true, "globals": { - "angular": false, - "jQuery": false, - "$": false + "describe": false, + "ddescribe": false, + "xdescribe": false, + "it": false, + "xit": false, + "iit": false } } From c9f18d09922b8a9369633ef5543fc68252198cf5 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 16:08:53 -0400 Subject: [PATCH 12/14] WIP: try to run both jquery and non-jquery E2E tests on Travis --- scripts/travis/build.sh | 6 ++++++ test/e2e/tests/helpers/main.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index aa972f772c04..5147e3bba4b2 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -11,6 +11,12 @@ if [ $JOB = "unit" ]; then grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots grunt test:travis-protractor-docs --specs "docs/app/e2e/**/*.scenario.js" elif [ $JOB = "e2e" ]; then + if [ $TEST_TARGET = "jquery" ]; then + export USE_JQUERY=1 + fi + + grunt test:travis-e2e + export TARGET_SPECS="build/docs/ptore2e/**/default_test.js" if [ $TEST_TARGET = "jquery" ]; then TARGET_SPECS="build/docs/ptore2e/**/jquery_test.js" diff --git a/test/e2e/tests/helpers/main.js b/test/e2e/tests/helpers/main.js index fcbdca9ad0ce..116271f9136f 100644 --- a/test/e2e/tests/helpers/main.js +++ b/test/e2e/tests/helpers/main.js @@ -10,6 +10,10 @@ var helper = { fixture += '/'; } + if (process.env.USE_JQUERY) { + fixture += '?jquery'; + } + browser.get('/e2e/fixtures/' + fixture); return helper; } From c69259ed9697c3106f24c974ef82bfff84f65037 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Wed, 15 Oct 2014 16:16:57 -0400 Subject: [PATCH 13/14] WIP: gruntfile u_u --- Gruntfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index e9813479b0ce..1c706f468a4c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -336,6 +336,10 @@ module.exports = function(grunt) { grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']); grunt.registerTask('test:e2e', 'Run E2E tests with Protractor with a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:normal']); + grunt.registerTask('test:travis-e2e', 'Run the E2E tests with protractor and keep a test server running in the background', + ['connect:testserver', 'protractor:travis']); + grunt.registerTask('test:ci-e2e', 'Run the E2E tests with protractor and keep a test server running in the background', + ['webdriver', 'connect:testserver', 'protractor:jenkins']); grunt.registerTask('test:protractor-docs', 'Run the end to end docs tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor-docs:normal']); grunt.registerTask('test:travis-protractor-docs', 'Run the end to end docs tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor-docs:travis']); From f4a8d1a95ab67cb8e6d4e12544379e0c15747a46 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Mon, 20 Oct 2014 10:45:08 -0400 Subject: [PATCH 14/14] Kill protractor-e2e configs --- Gruntfile.js | 28 ++++++------------------ jenkins_build.sh | 2 +- lib/grunt/plugins.js | 6 +---- protractor-conf.js | 1 + protractor-e2e-jenkins.conf.js | 40 ---------------------------------- protractor-e2e-travis.conf.js | 40 ---------------------------------- protractor-e2e.conf.js | 16 -------------- protractor-jenkins-conf.js | 1 + scripts/travis/build.sh | 6 ++--- test/e2e/tools/fixture.js | 2 ++ test/e2e/tools/util.js | 2 +- 11 files changed, 17 insertions(+), 127 deletions(-) delete mode 100644 protractor-e2e-jenkins.conf.js delete mode 100644 protractor-e2e-travis.conf.js delete mode 100644 protractor-e2e.conf.js diff --git a/Gruntfile.js b/Gruntfile.js index 1c706f468a4c..b4d9425bf0cb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -77,8 +77,8 @@ module.exports = function(grunt) { next(); }, - e2e.middleware(), util.conditionalCsp(), + e2e.middleware(), connect.favicon('images/favicon.ico'), connect.static(base) ]; @@ -104,20 +104,13 @@ module.exports = function(grunt) { }, - 'protractor-docs': { + protractor: { normal: 'protractor-conf.js', travis: 'protractor-travis-conf.js', jenkins: 'protractor-jenkins-conf.js' }, - protractor: { - normal: 'protractor-e2e.conf.js', - travis: 'protractor-e2e-travis.conf.js', - jenkins: 'protractor-e2e-jenkins.conf.js' - }, - - clean: { build: ['build'], tmp: ['tmp'] @@ -328,23 +321,16 @@ module.exports = function(grunt) { //alias tasks - grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor-docs']); + grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', '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:unit', 'Run unit, jQuery and Karma module tests with Karma', ['tests:jqlite', 'tests:jquery', 'tests:modules']); - grunt.registerTask('test:e2e', 'Run E2E tests with Protractor with a test server running in the background', - ['webdriver', 'connect:testserver', 'protractor:normal']); - grunt.registerTask('test:travis-e2e', 'Run the E2E tests with protractor and keep a test server running in the background', - ['connect:testserver', 'protractor:travis']); - grunt.registerTask('test:ci-e2e', 'Run the E2E tests with protractor and keep a test server running in the background', - ['webdriver', 'connect:testserver', 'protractor:jenkins']); - grunt.registerTask('test:protractor-docs', 'Run the end to end docs tests with Protractor and keep a test server running in the background', - ['webdriver', 'connect:testserver', 'protractor-docs:normal']); - grunt.registerTask('test:travis-protractor-docs', 'Run the end to end docs tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor-docs:travis']); - grunt.registerTask('test:ci-protractor-docs', 'Run the end to end docs tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor-docs:jenkins']); - grunt.registerTask('test:docs-e2e', 'Alias for test:protractor', ['test:protractor-docs']); + 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:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']); + grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']); + grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']); grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']); grunt.registerTask('minify', ['bower','clean', 'build', 'minall']); diff --git a/jenkins_build.sh b/jenkins_build.sh index d8414d4ea119..ea94a9d1a873 100755 --- a/jenkins_build.sh +++ b/jenkins_build.sh @@ -28,7 +28,7 @@ mkdir -p test_out grunt test:unit --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color # END TO END TESTS # -grunt test:ci-protractor-docs +grunt test:ci-protractor # DOCS APP TESTS # grunt test:docs --browsers $BROWSERS --reporters=dots,junit --no-colors --no-color diff --git a/lib/grunt/plugins.js b/lib/grunt/plugins.js index 65f49fdd93ce..208b109eaca5 100644 --- a/lib/grunt/plugins.js +++ b/lib/grunt/plugins.js @@ -57,11 +57,7 @@ module.exports = function(grunt) { util.updateWebdriver.call(util, this.async()); }); - grunt.registerMultiTask('protractor-docs', 'Run Protractor Docs integration tests', function() { - util.startProtractor.call(util, this.data, this.async()); - }); - - grunt.registerMultiTask('protractor', 'Run Protractor E2E tests', function() { + grunt.registerMultiTask('protractor', 'Run Protractor Docs integration tests', function() { util.startProtractor.call(util, this.data, this.async()); }); diff --git a/protractor-conf.js b/protractor-conf.js index 577d8b2b10ec..8fad56be8828 100644 --- a/protractor-conf.js +++ b/protractor-conf.js @@ -3,6 +3,7 @@ var config = require('./protractor-shared-conf').config; config.specs = [ + 'test/e2e/tests/**/*.js', 'build/docs/ptore2e/**/*.js', 'docs/app/e2e/**/*.scenario.js' ]; diff --git a/protractor-e2e-jenkins.conf.js b/protractor-e2e-jenkins.conf.js deleted file mode 100644 index 1551a11be116..000000000000 --- a/protractor-e2e-jenkins.conf.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -exports.config = { - allScriptsTimeout: 11000, - - specs: [ - 'test/e2e/tests/helpers/**/*.js', - 'test/e2e/tests/**/*Spec.js' - ], - - capabilities: { - 'browserName': 'chrome' - }, - - baseUrl: 'http://localhost:8000/', - - framework: 'jasmine', - - onPrepare: function() { - /* global angular: false, browser: false, jasmine: false */ - - // Disable animations so e2e tests run more quickly - var disableNgAnimate = function() { - angular.module('disableNgAnimate', []).run(['$animate', function($animate) { - $animate.enabled(false); - }]); - }; - - browser.addMockModule('disableNgAnimate', disableNgAnimate); - - require('jasmine-reporters'); - jasmine.getEnv().addReporter( - new jasmine.JUnitXmlReporter('test_out/e2e-' + exports.config.capabilities.browserName + '-', true, true)); - }, - - jasmineNodeOpts: { - defaultTimeoutInterval: 30000, - showColors: false - } -}; diff --git a/protractor-e2e-travis.conf.js b/protractor-e2e-travis.conf.js deleted file mode 100644 index 12254eaf4ff6..000000000000 --- a/protractor-e2e-travis.conf.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var config = require('./protractor-shared-conf').config; - -config.sauceUser = process.env.SAUCE_USERNAME; -config.sauceKey = process.env.SAUCE_ACCESS_KEY; - -config.multiCapabilities = [{ - 'browserName': 'chrome', - 'platform': 'OS X 10.9', - 'name': 'Angular E2E', - 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, - 'build': process.env.TRAVIS_BUILD_NUMBER, - 'version': '34' -}, { - 'browserName': 'firefox', - 'name': 'Angular E2E', - 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, - 'build': process.env.TRAVIS_BUILD_NUMBER, - 'version': '28' -}, { - browserName: 'safari', - 'platform': 'OS X 10.9', - 'version': '7', - 'name': 'Angular E2E', - 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER, - 'build': process.env.TRAVIS_BUILD_NUMBER -}]; - -config.specs = [ - 'test/e2e/tests/helpers/**/*.js', - 'test/e2e/tests/**/*Spec.js' -]; - -config.baseUrl = 'http://localhost:8000/'; - -config.allScriptsTimeout = 30000; -config.getPageTimeout = 30000; - -exports.config = config; diff --git a/protractor-e2e.conf.js b/protractor-e2e.conf.js deleted file mode 100644 index a3718ec072a1..000000000000 --- a/protractor-e2e.conf.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var config = require('./protractor-shared-conf').config; - -config.specs = [ - 'test/e2e/tests/helpers/**/*.js', - 'test/e2e/tests/**/*Spec.js' -]; - -config.baseUrl = 'http://localhost:8000/'; - -config.capabilities = { - browserName: 'chrome', -}; - -exports.config = config; diff --git a/protractor-jenkins-conf.js b/protractor-jenkins-conf.js index 2ac402ec8225..d1668e210a74 100644 --- a/protractor-jenkins-conf.js +++ b/protractor-jenkins-conf.js @@ -4,6 +4,7 @@ exports.config = { allScriptsTimeout: 11000, specs: [ + 'test/e2e/tests/**/*.js', 'build/docs/ptore2e/**/*.js', 'docs/app/e2e/*.scenario.js' ], diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 5147e3bba4b2..b4522cf43a38 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -15,13 +15,13 @@ elif [ $JOB = "e2e" ]; then export USE_JQUERY=1 fi - grunt test:travis-e2e - export TARGET_SPECS="build/docs/ptore2e/**/default_test.js" if [ $TEST_TARGET = "jquery" ]; then TARGET_SPECS="build/docs/ptore2e/**/jquery_test.js" fi - grunt test:travis-protractor-docs --specs "$TARGET_SPECS" + + export TARGET_SPECS="test/e2e/tests/**/*.js,$TARGET_SPECS" + grunt test:travis-protractor --specs "$TARGET_SPECS" else echo "Unknown job type. Please set JOB=unit or JOB=e2e-*." fi diff --git a/test/e2e/tools/fixture.js b/test/e2e/tools/fixture.js index accf84beda38..26723f032279 100644 --- a/test/e2e/tools/fixture.js +++ b/test/e2e/tools/fixture.js @@ -40,6 +40,8 @@ function generateFixture(test, query) { var s = util.stat(path.resolve(build, src)); if (s && s.isFile()) { $(script).attr('src', rewriteAngularSrc(src, query)); + } else { + $(script).attr('src', util.rewriteTestFile(test, src)); } } }); diff --git a/test/e2e/tools/util.js b/test/e2e/tools/util.js index 9018baebf5d6..313e9bda66db 100644 --- a/test/e2e/tools/util.js +++ b/test/e2e/tools/util.js @@ -28,7 +28,7 @@ function rewriteTestFile(testname, testfile) { while (testfile[i] === '/') ++i; testfile = testfile.slice(i); var s = stat(path.resolve(tests, testname, testfile)); - if (s && s.isFile() || s.isDirectory()) { + if (s && (s.isFile() || s.isDirectory())) { return ['/test/e2e/fixtures', testname, testfile].join('/'); } return false;