Skip to content

Commit

Permalink
Merge pull request #29 from lognormal/e2e-templates
Browse files Browse the repository at this point in the history
E2E using templates.  Added 02-snippet, 03-load-order and 04-page-params E2E tests.
  • Loading branch information
nicjansma committed Mar 8, 2015
2 parents 7daacf4 + 8b91ed7 commit eca6094
Show file tree
Hide file tree
Showing 46 changed files with 777 additions and 364 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
.gitignore
*.gz
*.swp
/boomerang-*.js
Default_Boomerang.xml
boomerang-build.*
BoomerangUpdate
[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]-[A-Z0-9]*.js
./[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]-[A-Z0-9]*.js
*.diff
.project
.settings/
tests/vendor/
tests/coverage/
tests/results/*
tests/pages/*
node_modules/
build/
tests/server/env.json
npm-debug.log
25 changes: 19 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@ var path = require("path");
var fse = require("fs-extra");

module.exports = function (grunt) {
//
// paths
//
var testsDir = path.join(__dirname, "tests");
var pluginsDir = path.join(__dirname, "plugins");

// boomerang.js and plugins/*.js order
var src = [ "boomerang.js" ];
var plugins = grunt.file.readJSON("plugins.json");
src.push(plugins.plugins);
src.push("plugins/zzz_last_plugin.js");
src.push(path.join(pluginsDir, "zzz_last_plugin.js"));

// ensure env.json exists
var envFile = path.resolve(path.join(__dirname, "tests", "server", "env.json"));
var envFile = path.resolve(path.join(testsDir, "server", "env.json"));
if (!fs.existsSync(envFile)) {
var envFileSample = path.resolve(path.join(__dirname, "tests", "server", "env.json.sample"));
var envFileSample = path.resolve(path.join(testsDir, "server", "env.json.sample"));
console.info("Creating env.json from defaults");
fse.copySync(envFileSample, envFile);
}

//
// Config
//
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
buildDate: Math.round(Date.now() / 1000),
Expand All @@ -45,7 +54,7 @@ module.exports = function (grunt) {
"tests/unit/*.js",
"tests/e2e/*.js",
"tests/server/*.js",
"tests/pages/**/*.js"
"tests/page-templates/**/*.js"
]
},
"string-replace": {
Expand Down Expand Up @@ -206,7 +215,6 @@ module.exports = function (grunt) {
"tests/vendor/mocha/mocha.js",
"tests/vendor/node-assert/assert.js",
"tests/vendor/assertive-chai/assertive-chai.js",
"tests/vendor/lodash/lodash.js",
"tests/unit/*.js",
"tests/build/*.js"
]
Expand Down Expand Up @@ -279,11 +287,15 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.loadNpmTasks("grunt-protractor-runner");
grunt.loadNpmTasks("grunt-protractor-webdriver");
grunt.loadNpmTasks("grunt-template");

// custom tasks
grunt.registerTask("pages-builder", "Builds our HTML tests/pages", require(path.join(testsDir, "builder")));

grunt.registerTask("lint", "eslint");
grunt.registerTask("build", ["concat", "string-replace", "uglify", "compress", "copy:latest", "filesize"]);

grunt.registerTask("test", ["test:unit", "test:e2e"]);
grunt.registerTask("test", ["test:build", "test:unit", "test:e2e"]);
grunt.registerTask("test:unit", ["build", "karma:unit"]);
grunt.registerTask("test:e2e", ["test:e2e:phantomjs"]);
grunt.registerTask("test:e2e:chrome", ["test:e2e:chrome"]);
Expand All @@ -300,6 +312,7 @@ module.exports = function (grunt) {
grunt.registerTask("test:e2e:phantomjs", ["build", "connect:test", "protractor_webdriver", "protractor:phantomjs"]);
grunt.registerTask("test:e2e:chrome", ["build", "connect:test", "protractor_webdriver", "protractor:chrome"]);

grunt.registerTask("test:build", ["pages-builder"]);
grunt.registerTask("webserver:build", ["build", "copy:webserver"]);

grunt.registerTask("default", ["lint", "test"]);
Expand Down
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,38 @@
"test": "tests"
},
"devDependencies": {
"async": "^0.9.0",
"bower": "*",
"chai": "^1.10.0",
"express": "^4.11.1",
"fs-extra": "^0.15.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-copy": "^0.7.0",
"grunt-contrib-uglify": "^0.6.0",
"grunt-eslint": "^1.1.0",
"grunt-filesize": "0.0.7",
"grunt-karma": "^0.9.0",
"grunt-protractor-runner": "^1.2.1",
"grunt-protractor-webdriver": "^0.2.0",
"grunt-string-replace": "^1.0.0",
"grunt-template": "^0.2.3",
"jasmine-reporters": "^1.0.0",
"karma-chrome-launcher": "^0.1.5",
"karma-coverage": "^0.2.6",
"karma-mocha": "^0.1.9",
"karma-phantomjs-launcher": "^0.1.4",
"karma-ie-launcher": "^0.1.5",
"karma-firefox-launcher": "^0.1.4",
"karma-ie-launcher": "^0.1.5",
"karma-mocha": "^0.1.9",
"karma-opera-launcher": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-safari-launcher": "^0.1.1",
"grunt-contrib-copy": "^0.7.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-filesize": "0.0.7",
"grunt-contrib-connect": "^0.9.0",
"grunt-protractor-runner": "^1.2.1",
"protractor": "1.3.1",
"grunt-protractor-webdriver": "^0.2.0",
"phantomjs": "^1.9.13",
"karma-tap-reporter": "0.0.3",
"jasmine-reporters": "^1.0.0",
"express": "^4.11.1",
"fs-extra": "^0.15.0",
"chai": "^1.10.0"
"phantomjs": "^1.9.13",
"protractor": "1.3.1"
},
"scripts": {
"test": "grunt test",
Expand Down
7 changes: 7 additions & 0 deletions tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
end_of_line = lf
insert_final_newline = true

[*.js]
indent_style = space
indent_spaces = 4
33 changes: 27 additions & 6 deletions tests/boomerang-test-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
//
(function(window) {

BOOMR = BOOMR || {};
// set our namespace
var BOOMR = window.BOOMR = window.BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};
if (BOOMR.plugins.TestFramework) {
return;
Expand All @@ -17,18 +18,23 @@
fired_page_ready: false,
fired_onbeacon: false,
fired_before_unload: false,
fired_before_beacon: false,
lastBeaconData: false,
beacons: [],
page_ready: function() {
this.fired_page_ready = true;
},
before_beacon: function(data) {
this.fired_before_beacon = true;
this.lastBeaconData = _.clone(data);
},
onbeacon: function(data) {
this.beacons.push(_.clone(data));
this.fired_onbeacon = true;
},
lastBeacon: function() {
if (this.beacons.length === 0) {
return false;
}

return this.beacons[this.beacons.length - 1];
},
before_unload: function() {
this.fired_before_unload = true;
},
Expand All @@ -50,7 +56,7 @@
return true;
}
};
})();
})(window);

//
// BOOMR_test
Expand Down Expand Up @@ -225,6 +231,21 @@
done();
};

t.validateBeaconWasSent = function(done) {
var tf = BOOMR.plugins.TestFramework;

// ensure we fired a beacon ('onbeacon')
assert.isTrue(tf.fired_onbeacon);

// ensure the data was sent to 'onbeacon'
assert.isObject(tf.lastBeacon());

// ensure the beacon has basic properties
assert.isString(tf.lastBeacon().v);

done();
}

window.BOOMR_test = t;

}(window));
Loading

0 comments on commit eca6094

Please sign in to comment.