Bug 1183884 - Change manual testing infrastructure. r=mikedeboer

This commit is contained in:
Andrei Oprea 2015-07-27 10:11:00 -04:00
parent d739b047ee
commit ebc24bf2de
14 changed files with 271 additions and 6 deletions

View File

@ -11,6 +11,9 @@ standalone/content/libs
standalone/node_modules
# Libs we don't need to check
test/shared/vendor
# Coverage files
test/coverage
test/node_modules
# These are generated react files that we don't need to check
content/js/contacts.js
content/js/conversation.js

View File

@ -1 +1,2 @@
.module-cache
test/coverage

View File

@ -56,6 +56,17 @@ You can also run it by hand in the browser/components/loop directory:
eslint --ext .js --ext .jsx --ext .jsm .
Test coverage
=============
Initial setup
cd test
npm install
To run
npm run build-coverage
It will create a `coverage` folder under test/
Front-End Unit Tests
====================
The unit tests for Loop reside in three directories:

View File

@ -7,6 +7,7 @@ if [ "$1" == "--help" ]; then
exit 0;
fi
# Causes script to abort immediately if error code is not checked.
set -e
# Main tests
@ -22,6 +23,16 @@ if [ -x "${LOOPDIR}/${ESLINT}" ]; then
echo 'eslint run finished.'
fi
# Build tests coverage.
MISSINGDEPSMSG="\nMake sure all dependencies are up to date by running
'npm install' inside the 'browser/components/loop/test/' directory.\n"
(
cd ${LOOPDIR}/test
if ! npm run-script build-coverage ; then
echo $MISSINGDEPSMSG && exit 1
fi
)
./mach xpcshell-test ${LOOPDIR}/
./mach marionette-test ${LOOPDIR}/manifest.ini

View File

@ -78,6 +78,7 @@ describe("loop.conversation", function() {
});
describe("#init", function() {
var OTRestore;
beforeEach(function() {
sandbox.stub(React, "render");
sandbox.stub(document.mozL10n, "initialize");
@ -93,13 +94,14 @@ describe("loop.conversation", function() {
pathname: "/"
});
OTRestore = window.OT;
window.OT = {
overrideGuidStorage: sinon.stub()
};
});
afterEach(function() {
delete window.OT;
window.OT = OTRestore;
});
it("should initialize L10n", function() {

View File

@ -0,0 +1,67 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-env node */
module.exports = function(config) {
"use strict";
return {
// Base path that will be used to resolve all patterns (eg. files, exclude).
basePath: "../../",
// List of files / patterns to load in the browser.
files: [],
// List of files to exclude.
exclude: [
],
// Frameworks to use.
// Available frameworks: https://npmjs.org/browse/keyword/karma-adapter .
frameworks: ["mocha"],
// Test results reporter to use.
// Possible values: "dots", "progress".
// Available reporters: https://npmjs.org/browse/keyword/karma-reporter .
reporters: ["progress", "coverage"],
coverageReporter: {
type: "html",
dir: "test/coverage/"
},
// Web server port.
port: 9876,
// Enable / disable colors in the output (reporters and logs).
colors: true,
// Level of logging.
// Possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG.
logLevel: config.LOG_INFO,
// Enable / disable watching file and executing tests whenever any file changes.
autoWatch: false,
// Start these browsers
// Available browser launchers: https://npmjs.org/browse/keyword/karma-launcher .
browsers: ["Firefox"],
// Continuous Integration mode.
// If true, Karma captures browsers, runs the tests and exits.
singleRun: true,
// Capture console output.
client: {
captureConsole: true
},
plugins: [
"karma-coverage",
"karma-mocha",
"karma-firefox-launcher"
]
};
};

View File

@ -0,0 +1,61 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-env node */
module.exports = function(config) {
"use strict";
var baseConfig = require("./karma.conf.base.js")(config);
// List of files / patterns to load in the browser.
baseConfig.files = baseConfig.files.concat([
"content/libs/l10n.js",
"content/shared/libs/react-0.12.2.js",
"content/shared/libs/jquery-2.1.4.js",
"content/shared/libs/lodash-3.9.3.js",
"content/shared/libs/backbone-1.2.1.js",
"test/shared/vendor/*.js",
"test/karma/stubs.js", // Stub out DOM event listener due to races.
"content/shared/js/utils.js",
"content/shared/js/models.js",
"content/shared/js/mixins.js",
"content/shared/js/websocket.js",
"content/shared/js/actions.js",
"content/shared/js/otSdkDriver.js",
"content/shared/js/validate.js",
"content/shared/js/dispatcher.js",
"content/shared/js/store.js",
"content/shared/js/conversationStore.js",
"content/shared/js/roomStates.js",
"content/shared/js/fxOSActiveRoomStore.js",
"content/shared/js/activeRoomStore.js",
"content/shared/js/views.js",
"content/shared/js/textChatStore.js",
"content/shared/js/textChatView.js",
"content/js/feedbackViews.js",
"content/js/client.js",
"content/js/conversationAppStore.js",
"content/js/roomStore.js",
"content/js/roomViews.js",
"content/js/conversationViews.js",
"content/js/conversation.js",
"test/desktop-local/*.js"
]);
// List of files to exclude.
baseConfig.exclude = baseConfig.exclude.concat([
"test/desktop-local/panel_test.js",
"test/desktop-local/contacts_test.js"
]);
// Preprocess matching files before serving them to the browser.
// Available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor .
baseConfig.preprocessors = {
"content/js/*.js": ["coverage"]
};
baseConfig.coverageReporter.dir = "test/coverage/desktop";
config.set(baseConfig);
};

View File

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-env node */
module.exports = function(config) {
"use strict";
var baseConfig = require("./karma.conf.base.js")(config);
// List of files / patterns to load in the browser.
baseConfig.files = baseConfig.files.concat([
"standalone/content/libs/l10n-gaia-02ca67948fe8.js",
"content/shared/libs/jquery-2.1.4.js",
"content/shared/libs/lodash-3.9.3.js",
"content/shared/libs/backbone-1.2.1.js",
"content/shared/libs/react-0.12.2.js",
"content/shared/libs/sdk.js",
"test/shared/vendor/*.js",
"content/shared/js/utils.js",
"content/shared/js/store.js",
"content/shared/js/models.js",
"content/shared/js/mixins.js",
"content/shared/js/crypto.js",
"content/shared/js/websocket.js",
"content/shared/js/validate.js",
"content/shared/js/actions.js",
"content/shared/js/dispatcher.js",
"content/shared/js/otSdkDriver.js",
"content/shared/js/roomStates.js",
"content/shared/js/fxOSActiveRoomStore.js",
"content/shared/js/activeRoomStore.js",
"content/shared/js/conversationStore.js",
"content/shared/js/views.js",
"content/shared/js/textChatStore.js",
"content/shared/js/textChatView.js",
"standalone/content/js/multiplexGum.js",
"standalone/content/js/standaloneAppStore.js",
"standalone/content/js/standaloneClient.js",
"standalone/content/js/standaloneMozLoop.js",
"standalone/content/js/fxOSMarketplace.js",
"standalone/content/js/standaloneRoomViews.js",
"standalone/content/js/standaloneMetricsStore.js",
"standalone/content/js/webapp.js",
"test/shared/*.js",
"test/standalone/*.js"
]);
// Preprocess matching files before serving them to the browser.
// Available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor .
baseConfig.preprocessors = {
"content/shared/js/*.js": ["coverage"],
"standalone/content/js/*.js": ["coverage"]
};
baseConfig.coverageReporter.dir = "test/coverage/shared_standalone";
config.set(baseConfig);
};

View File

@ -0,0 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Used for desktop coverage tests because triggering methods on
// DOMContentLoaded proved to lead to race conditions.
sinon.stub(document, "addEventListener");
console.log("[stubs.js] addEventListener stubbed to prevent race conditions");

View File

@ -0,0 +1,21 @@
{
"name": "FirefoxHello",
"version": "0.0.1",
"description": "Firefox Hello test coverage",
"main": "index.js",
"directories": {
"test": "test"
},
"devDependencies": {
"istanbul": "^0.3.17",
"karma": "^0.12.37",
"karma-coverage": "^0.4.2",
"karma-firefox-launcher": "^0.1.6",
"karma-mocha": "^0.2.0"
},
"scripts": {
"build-coverage-shared": "./node_modules/.bin/karma start karma/karma.coverage.shared_standalone.js",
"build-coverage-desktop": "./node_modules/.bin/karma start karma/karma.coverage.desktop.js",
"build-coverage": "npm run build-coverage-desktop && npm run build-coverage-shared"
}
}

View File

@ -11,8 +11,8 @@ describe("loop.store.ActiveRoomStore", function () {
var FAILURE_DETAILS = loop.shared.utils.FAILURE_DETAILS;
var SCREEN_SHARE_STATES = loop.shared.utils.SCREEN_SHARE_STATES;
var ROOM_INFO_FAILURES = loop.shared.utils.ROOM_INFO_FAILURES;
var sandbox, dispatcher, store, fakeMozLoop, fakeSdkDriver;
var fakeMultiplexGum;
var sandbox, dispatcher, store, fakeMozLoop, fakeSdkDriver, fakeMultiplexGum;
var standaloneMediaRestore;
beforeEach(function() {
sandbox = sinon.sandbox.create();
@ -52,9 +52,10 @@ describe("loop.store.ActiveRoomStore", function () {
};
fakeMultiplexGum = {
reset: sandbox.spy()
reset: sandbox.spy()
};
standaloneMediaRestore = loop.standaloneMedia;
loop.standaloneMedia = {
multiplexGum: fakeMultiplexGum
};
@ -67,6 +68,7 @@ describe("loop.store.ActiveRoomStore", function () {
afterEach(function() {
sandbox.restore();
loop.standaloneMedia = standaloneMediaRestore;
});
describe("#constructor", function() {

View File

@ -431,7 +431,8 @@ describe("loop.shared.mixins", function() {
doNotDisturb: true,
getAudioBlob: sinon.spy(function(name, callback) {
callback(null, new Blob([new ArrayBuffer(10)], {type: "audio/ogg"}));
})
}),
getLoopPref: sandbox.stub()
};
fakeAudio = {

View File

@ -17,6 +17,13 @@ describe("Validator", function() {
function Y(){}
describe("#validate", function() {
function mozRTCSessionDescription() {}
var mozRTC;
beforeEach(function() {
mozRTC = new mozRTCSessionDescription();
});
it("should check for a single required dependency when no option passed",
function() {
expect(create({x: Number}, {}))
@ -67,7 +74,7 @@ describe("Validator", function() {
});
it("should check for a native constructor dependency", function() {
expect(create({foo: mozRTCSessionDescription}, {foo: "x"}))
expect(create({foo: mozRTC}, {foo: "x"}))
.to.Throw(TypeError,
/invalid dependency: foo; expected mozRTCSessionDescription/);
});

View File

@ -47,11 +47,22 @@ describe("loop.webapp", function() {
});
describe("#init", function() {
var loopConfigRestore;
beforeEach(function() {
sandbox.stub(React, "render");
loopConfigRestore = loop.config;
loop.config = {
feedbackApiUrl: "http://fake.invalid",
serverUrl: "http://fake.invalid"
};
sandbox.stub(loop.Dispatcher.prototype, "dispatch");
});
afterEach(function() {
loop.config = loopConfigRestore;
});
it("should create the WebappRootView", function() {
loop.webapp.init();