48eb8b72 by jforbes Committed by David LaPalomento

Add a functional test that runs in SauceLabs. closes #323

1 parent 9c432427
......@@ -3,7 +3,6 @@ node_js:
- '0.10'
install:
- npm install -g grunt-cli && npm install
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then curl https://gist.githubusercontent.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash; fi
notifications:
hipchat:
rooms:
......@@ -16,3 +15,5 @@ env:
global:
- secure: dM7svnHPPu5IiUMeFWW5zg+iuWNpwt6SSDi3MmVvhSclNMRLesQoRB+7Qq5J/LiKhmjpv1/GlNVV0CTsHMRhZNwQ3fo38eEuTXv99aAflEITXwSEh/VntKViHbGFubn06EnVkJoH6MX3zJ6kbiwc2QdSQbywKzS6l6quUEpWpd0=
- secure: AnduYGXka5ft1x7V3SuVYqvlKLvJGhUaRNFdy4UDJr3ZVuwpQjE4TMDG8REmJIJvXfHbh4qY4N1cFSGnXkZ4bH21Xk0v9DLhsxbarKz+X2BvPgXs+Af9EQ6vLEy/5S1vMLxfT5+y+Ec5bVNGOsdUZby8Y21CRzSg6ADN9kwPGlE=
addons:
sauce_connect: true
......
......@@ -5,6 +5,7 @@ CHANGELOG
* @dmlap improved video duration calculation. ([view](https://github.com/videojs/videojs-contrib-hls/pull/321))
* Clamp seeks to the seekable range ([view](https://github.com/videojs/videojs-contrib-hls/pull/327))
* Use getComputedStyle for player dimensions when filtering variants ([view](https://github.com/videojs/videojs-contrib-hls/pull/326))
* Add a functional test that runs in SauceLabs ([view](https://github.com/videojs/videojs-contrib-hls/pull/323))
--------------------
......
......@@ -83,6 +83,12 @@ module.exports = function(grunt) {
port: 9999,
keepalive: true
}
},
test: {
options: {
hostname: '*',
port: 9999
}
}
},
open : {
......@@ -196,7 +202,53 @@ module.exports = function(grunt) {
autoWatch: false
}
},
protractor: {
options: {
configFile: 'test/functional/protractor.config.js'
},
chrome: {
options: {
args: {
capabilities: {
browserName: 'chrome'
}
}
}
},
firefox: {
options: {
args: {
capabilities: {
browserName: 'firefox'
}
}
}
},
safari: {
options: {
args: {
capabilities: {
browserName: 'safari'
}
}
}
},
ie: {
options: {
args: {
capabilities: {
browserName: 'internet explorer'
}
}
}
},
saucelabs:{}
}
});
// These plugins provide necessary tasks.
......@@ -212,6 +264,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-github-releaser');
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('chg');
......@@ -284,6 +337,7 @@ module.exports = function(grunt) {
grunt.task.run(['karma:phantomjs']);
} else if (process.env.TRAVIS) {
grunt.task.run(['karma:saucelabs']);
grunt.task.run(['connect:test', 'protractor:saucelabs']);
} else {
if (tasks.length === 0) {
tasks.push('chrome');
......@@ -291,9 +345,13 @@ module.exports = function(grunt) {
if (tasks.length === 1) {
tasks = tasks[0].split(',');
}
tasks = tasks.map(function(el) {
return 'karma:' + el;
});
tasks = tasks.reduce(function(acc, el) {
acc.push('karma:' + el);
if (/chrome|firefox|safari|ie/.test(el)) {
acc.push('protractor:' + el);
}
return acc;
}, ['connect:test']);
grunt.task.run(tasks);
}
......
......@@ -190,7 +190,7 @@ the web](http://www.html5rocks.com/en/tutorials/track/basics/).
### Testing
For testing, you can either run `npm test` or use `grunt` directly.
If you use `npm test`, it will only run the karma tests using chrome.
If you use `npm test`, it will only run the karma and end-to-end tests using chrome.
You can specify which browsers you want the tests to run via grunt's `test` task.
You can use either grunt-style arguments or comma separated arguments:
```
......@@ -201,10 +201,14 @@ Possible options are:
* `chromecanary`
* `phantomjs`
* `opera`
* `chrome`
* `safari`
* `firefox`
* `ie`
* `chrome`<sup>1</sup>
* `safari`<sup>1, 2</sup>
* `firefox`<sup>1</sup>
* `ie`<sup>1</sup>
_<sup>1</sup>supported end-to-end browsers_<br />
_<sup>2</sup>requires the [SafariDriver extension]( https://code.google.com/p/selenium/wiki/SafariDriver) to be installed_
## Hosting Considerations
Unlike a native HLS implementation, the HLS tech has to comply with
......
......@@ -19,7 +19,7 @@
],
"devDependencies": {
"chg": "^0.2.0",
"grunt": "~0.4.1",
"grunt": "^0.4.5",
"grunt-concurrent": "0.4.3",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.3.0",
......@@ -30,6 +30,7 @@
"grunt-github-releaser": "^0.1.17",
"grunt-karma": "~0.6.2",
"grunt-open": "0.2.3",
"grunt-protractor-runner": "git+https://github.com/forbesjo/grunt-protractor-runner.git#update-webdriver",
"grunt-shell": "0.6.1",
"grunt-version": "^1.0.0",
"karma": "~0.10.0",
......
/* global browser */
var config = {};
if (process.env.SAUCE_USERNAME) {
config.multiCapabilities = [{
browserName: 'chrome',
platform: 'Windows 8.1'
}, {
browserName: 'firefox',
platform: 'Windows 8.1'
}].map(function(caps) {
caps.name = process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH;
caps.build = process.env.TRAVIS_BUILD_NUMBER;
caps['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
caps.recordScreenshots = false;
return caps;
});
config.sauceUser = process.env.SAUCE_USERNAME;
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
config.maxSessions = 5;
config.maxDuration = 300;
}
config.baseUrl = 'http://localhost:9999/example.html';
config.specs = ['spec.js'];
config.framework = 'jasmine2';
config.onPrepare = function() {
browser.ignoreSynchronization = true;
};
config.jasmineNodeOpts = {
showColors: true,
defaultTimeoutInterval: 60000
};
exports.config = config;
/* global browser, $, describe, beforeEach, it, expect, player */
describe('Player', function() {
beforeEach(function() {
browser.get(browser.baseUrl);
});
it('should play', function() {
$('.vjs-big-play-button').click();
browser.executeAsyncScript(function(done) {
player.one('timeupdate', function() {
var result = !player.paused() &&
!player.ended() &&
player.error() === null;
done(result);
});
}).then(function(result) {
expect(result).toBe(true);
});
});
});