Skip to content

Commit

Permalink
Bug #7/#9, Add RSS & JSON parsing to tests [iet:2703841]
Browse files Browse the repository at this point in the history
* JSON parser - oEmbed API response
* RSS parser - OU Podcasts feed
* Also, tweaks to Webdriver.IO tests
  • Loading branch information
nfreear committed Feb 11, 2015
1 parent 3fd80af commit 06c2cf3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 12 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TESTS = test/ou-p*.js
OUT = _out/
BIN = _bin/

JAR = selenium-server-standalone-2.44.0.jar
JAR = selenium-server-standalone-2.43.1.jar



Expand All @@ -51,6 +51,9 @@ test-api:
test-one:
$(MOCHA)=http://iet-embed-acct.open.ac.uk --grep=embed test/ou-player-test.js

test-podcast:
$(MOCHA)=http://iet-embed-acct.open.ac.uk,debug test/*-podcast-*.js

test-proxy:
$(MOCHA)=http://iet-embed-acct.open.ac.uk test/*-proxy-*.js

Expand All @@ -59,7 +62,7 @@ test-debug:


selenium-install:
wget -P $(BIN) http://selenium-release.storage.googleapis.com/2.44/$(JAR)
wget -P $(BIN) http://selenium-release.storage.googleapis.com/2.43/$(JAR)
wget -P $(BIN) http://chromedriver.storage.googleapis.com/2.14/chromedriver_mac32.zip
cd $(BIN); unzip -o chromedriver_mac32.zip
# TODO: fix 'node_modules/browserevent/lib/browserevent.js' : line 35 - ''./extensions/chrome.crx'
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# ou-media-player-test

[![Build status][travis-img]][travis] [![Code Climate][climate-img]][climate]
[![Issues][issues-img]][issues] ![][reposs]

Remote unit tests for OU Media Player, at The Open University.

* <https://mediaplayer.open.ac.uk>

Note: this repository is an interim solution. Naturally, we want the tests in the same code-base as the Player.

Built on: [mocha], [chai] and [chai-http].
Built on: [mocha], [chai], [chai-http] and [webdriver.io].


## Requirements
Expand Down Expand Up @@ -43,8 +44,11 @@ If you're behind a proxy then you may need to add this to your `~/.gitconfig` fi
[mocha]: http://mochajs.org/
[chai]: http://chaijs.com/
[chai-http]: https://github.com/chaijs/chai-http
[webdriver.io]: http://webdriver.io/
[travis]: https://travis-ci.org/nfreear/ou-media-player-test
[travis-img]: https://api.travis-ci.org/nfreear/ou-media-player-test.svg?branch=master "Build status"
[climate]: https://codeclimate.com/github/nfreear/ou-media-player-test
[climate-img]: https://codeclimate.com/github/nfreear/ou-media-player-test/badges/gpa.svg

[issues]: https://github.com/nfreear/ou-media-player-test/issues
[issues-img]: https://img.shields.io/github/issues/nfreear/ou-media-player-test.svg
[reposs]: https://reposs.herokuapp.com/?path=nfreear/ou-media-player-test
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"devDependencies": {
"minimist": "*",
"request": "*",
"parse-rss": "*",
"superagent-proxy": "*",
"temporal": "*",
"mocha": "*",
Expand Down
1 change: 1 addition & 0 deletions test/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var R = global.R = require('./test-config');

global.request = require('request');
global.rss_parser = require("parse-rss")

/*! Attach ES6 Shim.
*/
Expand Down
9 changes: 8 additions & 1 deletion test/ou-player-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ describe("Test OU Media Player - API, generated Javascript etc.", function () {

page("/oembed?format=json&callback=CB&url=" + R.podcast +
"/pod/student-experiences/db6cc60d6b").end(function (err, res) {
var doc = res && res.text;
var doc = res && res.text
// Parse JSON [Bug: #7]
, json = doc && doc.replace(/^CB\(/, '').replace(/\)$/, '')
, obj = json && JSON.parse(json);
//log("oEmbed JSON: " + doc);

expect(err).to.be.null;
Expand All @@ -32,6 +35,10 @@ describe("Test OU Media Player - API, generated Javascript etc.", function () {
doc.should.contain('"version":"1.0"');
doc.should.contain('"html":"<iframe ');

expect(obj.version).to.equal("1.0");
expect(obj.type).to.equal("video");
expect(obj.html).to.contain("<iframe");

delay(done);
});
});
Expand Down
9 changes: 7 additions & 2 deletions test/ou-player-static-js-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ describe("Test OU Media Player - static json & javascript etc.", function () {
it("#page: should contain version.json", function (done) {

page("/version.json").end(function (err, res) {
var doc = res && res.text;
log("version.JSON: " + doc);
var doc = res && res.text
// Parse JSON [Bug: #7]
, obj = doc && JSON.parse(doc);
log("version.JSON: " + obj);

expect(err).to.be.null;
expect(res).to.not.be.null;
Expand All @@ -17,6 +19,9 @@ describe("Test OU Media Player - static json & javascript etc.", function () {
doc.should.match(/^\{\"/);
doc.should.contain('"commit":');

expect(obj).to.have.property("describe");
expect(obj.describe).to.match(/^v\d\.\d+\-\d+\-g\w{7}$/);

delay(done);
});
});
Expand Down
22 changes: 20 additions & 2 deletions test/ou-podcast-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ describe("Test OU Podcasts - RSS feed API, etc.", function () {
it("#page: should contain an rss feed & return a 200 status", function (done) {

request(R.podcast + "/feeds/student-experiences/player.xml",
function (error, res, doc) {
function (err, res, doc) {
log(' > Path: ' + res.request.href); //res.req.path, res);

expect(error).to.be.null;
expect(err).to.be.null;
res.statusCode.should.equal(200);
//res.should.be.xml;
res.headers["content-type"].should.contain("application/xml");
Expand All @@ -38,4 +38,22 @@ describe("Test OU Podcasts - RSS feed API, etc.", function () {
});
});


it("#page: should be a valid rss feed (parser)", function (done) {

// Parse RSS feed [Bug: #7]
rss_parser(R.podcast + "/feeds/student-experiences/player.xml", function (err, rss) {
var meta = rss[0].meta;
//console.log("RSS: ", rss);

expect(err).to.be.null;
//rss.statusCode.should.equal(200);
expect(meta.title).to.contain("The Student Experience");
expect(rss[0].title).to.contain("Student views of the OU");

delay(done);
});

});

});
11 changes: 8 additions & 3 deletions test/selenium/ou-player-webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ describe('My webdriverio tests', function () {
client
.url(R.base + "/embed/pod/student-experiences/db6cc60d6b")
.getTitle(function (err, title) {
//assert.equal(undefined, err);
expect(err).to.be.undefined;
//assert.strictEqual(title,'GitHub · Build software better, together.');
expect(title).to.equal('The Student Experience: Student views of the OU | OU player');
})
.waitForExist(play_btn, 2000, function () {

console.log('> Element exists:', play_btn);
console.log('> Element exists (play-pause button):', play_btn);

client
.addEventListener('play', 'video#player1', function (ev) {
.element('video#player1', function (err, res) {
expect(err).to.be.null; //.undefined;
expect(res.state).to.equal('success');

console.log('> Element exists (<video>):', res);
})
.addEventListener('play', '#player1', function (ev) {
console.log('> Event:', ev.type);
})
.addEventListener('pause', 'video#player1', function (ev) {
Expand Down

0 comments on commit 06c2cf3

Please sign in to comment.