Skip to content

Commit

Permalink
chore(testing): run end to end tests on firefox and safari as well as…
Browse files Browse the repository at this point in the history
… chrome

Update the Travis and Jenkins configs to run protractor tests on Safari and Firefox as well,
and make the Travis tests run output XML and turn off color.

Fix tests which were failing in Firefox due to clear() not working as expected.

Fix tests which were failing in Safari due to SafariDriver not understanding the minus key,
and disable tests which SafariDriver has no support for.
  • Loading branch information
juliemr authored and IgorMinar committed Feb 5, 2014
1 parent e7face4 commit 0e85ca9
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ module.exports = function(grunt) {


runprotractor: {
normal: 'protractor-conf.js'
normal: 'protractor-conf.js',
jenkins: 'protractor-jenkins-conf.js'
},


Expand Down Expand Up @@ -291,6 +292,7 @@ module.exports = function(grunt) {
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', 'runprotractor:normal']);
grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'runprotractor:jenkins']);
grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']);
grunt.registerTask('test:docgen', ['jasmine_node']);
grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']);
Expand Down
4 changes: 4 additions & 0 deletions docs/content/guide/expression.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ prevent accidental access to the global state (a common source of subtle bugs).
</doc:source>
<doc:protractor>
it('should calculate expression in binding', function() {
if (browser.params.browser = 'safari') {
// Safari can't handle dialogs.
return;
};
element(by.css('[ng-click="greet()"]')).click();

var alertDialog = browser.switchTo().alert();
Expand Down
19 changes: 15 additions & 4 deletions docs/src/ngdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,14 +1113,25 @@ function scenarios(docs){
function writeProtractorTest(doc){
var lines = [];
lines.push('describe("' + doc.section + '/' + doc.id + '", function() {');
lines.push(' beforeEach(function() {');
lines.push(' browser.get("index-nocache.html#!/' + doc.section + '/' + doc.id + '");');
lines.push(' });');
lines.push(' describe("angular+jqLite", function() {')
lines.push(' beforeEach(function() {');
lines.push(' browser.get("index-nocache.html#!/' + doc.section + '/' + doc.id + '");');
lines.push(' });');
lines.push('');
doc.protractorTests.forEach(function(test){
lines.push(indentCode(trim(test), 2));
lines.push(indentCode(trim(test), 4));
lines.push('');
});
lines.push(' });');
lines.push(' describe("angular+jQuery", function() {')
lines.push(' beforeEach(function() {');
lines.push(' browser.get("index-jq-nocache.html#!/' + doc.section + '/' + doc.id + '");');
lines.push(' });');
doc.protractorTests.forEach(function(test){
lines.push(indentCode(trim(test), 4));
lines.push('');
});
lines.push(' });');
lines.push('});');
lines.push('');
return lines.join('\n');
Expand Down
12 changes: 5 additions & 7 deletions jenkins_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ then
BROWSERS="Chrome,Firefox,Opera,/Users/jenkins/bin/safari.sh,/Users/jenkins/bin/ie8.sh,/Users/jenkins/bin/ie9.sh"
fi

if [[ -z "$BROWSERS_E2E" ]]
then
BROWSERS_E2E="Chrome,Firefox,/Users/jenkins/bin/safari.sh"
fi


# CLEAN #
rm -f angular.min.js.gzip.size
rm -f angular.js.size
Expand All @@ -28,14 +22,18 @@ rm -f angular.js.size
npm install --color false
grunt ci-checks package --no-color

mkdir 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:protractor
grunt test:ci-protractor
grunt test:ci-protractor --browser safari
grunt test:ci-protractor --browser firefox

# Promises/A+ TESTS #
grunt test:promises-aplus --no-color
Expand Down
6 changes: 6 additions & 0 deletions lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module.exports = {
// Skip the webdriver-manager update on Travis, since the browsers will
// be provided remotely.
done();
return;
}
var p = spawn('node', ['node_modules/protractor/bin/webdriver-manager', 'update']);
p.stdout.pipe(process.stdout);
Expand All @@ -156,11 +157,16 @@ module.exports = {
var sauceKey = grunt.option('sauceKey');
var tunnelIdentifier = grunt.option('capabilities.tunnel-identifier');
var sauceBuild = grunt.option('capabilities.build');
var browser = grunt.option('browser');
var args = ['node_modules/protractor/bin/protractor', config];
if (sauceUser) args.push('--sauceUser=' + sauceUser);
if (sauceKey) args.push('--sauceKey=' + sauceKey);
if (tunnelIdentifier) args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier);
if (sauceBuild) args.push('--capabilities.build=' + sauceBuild);
if (browser) {
args.push('--browser=' + browser);
args.push('--params.browser=' + browser);
}


var p = spawn('node', args);
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"promises-aplus-tests": "~1.3.2",
"semver": "~2.1.0",
"lodash": "~2.1.0",
"browserstacktunnel-wrapper": "~1.1.1"
"browserstacktunnel-wrapper": "~1.1.1",
"grunt-jscs-checker": "~0.3.2",
"jasmine-reporters": "~0.2.1"
},
"licenses": [
{
Expand Down
36 changes: 36 additions & 0 deletions protractor-jenkins-conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
exports.config = {
allScriptsTimeout: 11000,

specs: [
'build/docs/ptore2e/**/*.js',
'test/e2e/docsAppE2E.js'
],

capabilities: {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000/build/docs/',

framework: 'jasmine',

onPrepare: function() {
// Disable animations so e2e tests run more quickly
var disableNgAnimate = function() {
angular.module('disableNgAnimate', []).run(function($animate) {
$animate.enabled(false);
});
};

browser.addMockModule('disableNgAnimate', disableNgAnimate);

require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('test_out/e2e-' + this.capabilities.browserName + '-', true, true));
},

jasmineNodeOpts: {
defaultTimeoutInterval: 30000,
showColors: false
}
};
7 changes: 5 additions & 2 deletions scripts/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ if [ $JOB = "unit" ]; then
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
elif [ $JOB = "e2e" ]; then
grunt test:protractor --sauceUser $SAUCE_USERNAME \
export SAUCE_OPTIONS="--sauceUser $SAUCE_USERNAME \
--sauceKey $SAUCE_ACCESS_KEY \
--capabilities.tunnel-identifier=$TRAVIS_JOB_NUMBER \
--capabilities.build=$TRAVIS_BUILD_NUMBER
--capabilities.build=$TRAVIS_BUILD_NUMBER"
grunt test:protractor $SAUCE_OPTIONS
grunt test:protractor $SAUCE_OPTIONS --browser=firefox
grunt test:protractor $SAUCE_OPTIONS --browser=safari
else
echo "Unknown job type. Please set JOB=unit or JOB=e2e."
fi
8 changes: 7 additions & 1 deletion src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,17 @@ var VALID_CLASS = 'ng-valid',
</file>
<file name="protractorTest.js">
it('should data-bind and become invalid', function() {
if (browser.params.browser = 'safari') {
// SafariDriver can't handle contenteditable.
return;
};
var contentEditable = element(by.css('.doc-example-live [contenteditable]'));
expect(contentEditable.getText()).toEqual('Change me!');
contentEditable.clear();
// Firefox driver doesn't trigger the proper events on 'clear', so do this hack
contentEditable.click();
contentEditable.sendKeys(protractor.Key.chord(protractor.Key.COMMAND, "a"));
contentEditable.sendKeys(protractor.Key.BACK_SPACE);
expect(contentEditable.getText()).toEqual('');
Expand Down
9 changes: 9 additions & 0 deletions src/ng/directive/ngInclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,21 @@
});
it('should load template2.html', function() {
if (browser.params.browser == 'firefox') {
// Firefox can't handle using selects
// See https://github.com/angular/protractor/issues/480
return;
}
templateSelect.click();
templateSelect.element.all(by.css('option')).get(2).click();
expect(includeElem.getText()).toMatch(/Content of template2.html/);
});
it('should change to blank', function() {
if (browser.params.browser == 'firefox') {
// Firefox can't handle using selects
return;
}
templateSelect.click();
templateSelect.element.all(by.css('option')).get(0).click();
expect(includeElem.isPresent()).toBe(false);
Expand Down
8 changes: 6 additions & 2 deletions src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('USD$1,234.56');
});
it('should update', function() {
if (browser.params.browser == 'safari') {
// Safari does not understand the minus key. See
// https://github.com/angular/protractor/issues/481
return;
}
element(by.model('amount')).clear();
element(by.model('amount')).sendKeys('-1234');
expect(element(by.id('currency-default')).getText()).toBe('($1,234.00)');
element(by.model('amount')).sendKeys('-1234'); expect(element(by.id('currency-default')).getText()).toBe('($1,234.00)');
expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('(USD$1,234.00)');
});
</doc:protractor>
Expand Down
1 change: 0 additions & 1 deletion test/e2e/docsAppE2E.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('docs.angularjs.org', function () {
browser.sleep(500);

var nameInput = element(by.input('user.name'));
nameInput.click();
nameInput.sendKeys('!!!');

var code = element(by.css('.doc-example-live tt'));
Expand Down

0 comments on commit 0e85ca9

Please sign in to comment.