Repair Broken Test Suite - Full Passing Tests

* Repair broken e2e test introduced in 8d03cfc (copywriting change was not
  reflected in the spec)

* Updated i18n.coffee code to be more cautious (it expected the 'en' locale
  would always be available, but provides appropriate error handling as-is).

* Extended timeout duration for protractor, as registration was slightly above
  30s.

* Added karma-mocha-reporter as a dev dependency to ensure test visibility.
This commit is contained in:
Kevin Gisi
2015-03-17 18:37:03 -04:00
parent 10ce0a622b
commit f41933b7a1
7 changed files with 39 additions and 13 deletions

View File

@@ -4872,7 +4872,11 @@ module.exports = {
if ((locale == null) || (!module.exports.strings && !module.exports.translations[locale])) { if ((locale == null) || (!module.exports.strings && !module.exports.translations[locale])) {
locale = 'en'; locale = 'en';
} }
string = !module.exports.strings ? module.exports.translations[locale][stringName] : module.exports.strings[stringName]; if (module.exports.strings) {
string = module.exports.strings[stringName];
} else {
string = module.exports.translations[locale] && module.exports.translations[locale][stringName];
}
clonedVars = _.clone(vars) || {}; clonedVars = _.clone(vars) || {};
clonedVars.locale = locale; clonedVars.locale = locale;
if (string) { if (string) {
@@ -4883,7 +4887,11 @@ module.exports = {
return 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'; return 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.';
} }
} else { } else {
stringNotFound = !module.exports.strings ? module.exports.translations[locale].stringNotFound : module.exports.strings.stringNotFound; if (module.exports.strings) {
stringNotFound = module.exports.strings.stringNotFound;
} else if (module.exports.translations[locale]) {
stringNotFound = module.exports.translations[locale] && module.exports.translations[locale].stringNotFound;
}
try { try {
return _.template(stringNotFound, { return _.template(stringNotFound, {
string: stringName string: stringName

View File

@@ -1,6 +1,6 @@
_ = require 'lodash' _ = require 'lodash'
module.exports = module.exports =
strings: null, # Strings for one single language strings: null, # Strings for one single language
translations: {} # Strings for multiple languages {en: strings, de: strings, ...} translations: {} # Strings for multiple languages {en: strings, de: strings, ...}
t: (stringName) -> # Other parameters allowed are vars (Object) and locale (String) t: (stringName) -> # Other parameters allowed are vars (Object) and locale (String)
@@ -14,10 +14,16 @@ module.exports =
locale = arguments[2] locale = arguments[2]
locale = 'en' if (!locale? or (!module.exports.strings and !module.exports.translations[locale])) locale = 'en' if (!locale? or (!module.exports.strings and !module.exports.translations[locale]))
string = if (!module.exports.strings) then module.exports.translations[locale][stringName] else module.exports.strings[stringName]
if module.exports.strings
clonedVars = _.clone(vars) or {}; string = module.exports.strings[stringName]
clonedVars.locale = locale; else
string =
module.exports.translations[locale] and
module.exports.translations[locale][stringName]
clonedVars = _.clone(vars) or {}
clonedVars.locale = locale
if string if string
try try
@@ -25,8 +31,14 @@ module.exports =
catch e catch e
'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.' 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'
else else
stringNotFound = if (!module.exports.strings) then module.exports.translations[locale].stringNotFound else module.exports.strings.stringNotFound if module.exports.strings
stringNotFound = module.exports.strings.stringNotFound
else if module.exports.translations[locale]
stringNotFound =
module.exports.translations[locale] and
module.exports.translations[locale].stringNotFound
try try
_.template(stringNotFound, {string: stringName}) _.template(stringNotFound, {string: stringName})
catch e catch e
'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.' 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'

View File

@@ -96,6 +96,8 @@ module.exports = function(config) {
// - IE (only Windows) // - IE (only Windows)
browsers: ['PhantomJS'], browsers: ['PhantomJS'],
// Enable mocha-style reporting, for better test visibility
reporters: ['mocha'],
// Continuous Integration mode // Continuous Integration mode
// if true, it capture browsers, run tests and exit // if true, it capture browsers, run tests and exit

View File

@@ -92,6 +92,7 @@
"karma-html2js-preprocessor": "~0.1.0", "karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3", "karma-jasmine": "~0.1.3",
"karma-mocha": "0.1.3", "karma-mocha": "0.1.3",
"karma-mocha-reporter": "^1.0.2",
"karma-ng-html2js-preprocessor": "~0.1.0", "karma-ng-html2js-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0", "karma-phantomjs-launcher": "~0.1.0",
"karma-requirejs": "~0.2.0", "karma-requirejs": "~0.2.0",

View File

@@ -19,6 +19,6 @@ exports.config = {
// Options to be passed to Jasmine-node. // Options to be passed to Jasmine-node.
jasmineNodeOpts: { jasmineNodeOpts: {
showColors: true, showColors: true,
defaultTimeoutInterval: 30000 defaultTimeoutInterval: 60000
} }
}; };

View File

@@ -37,7 +37,7 @@ describe('front page', function() {
var login = element(by.css("#login-tab input[value='Login']")); var login = element(by.css("#login-tab input[value='Login']"));
login.click(); login.click();
var alertDialog = browser.switchTo().alert(); var alertDialog = browser.switchTo().alert();
expect(alertDialog.getText()).toMatch(/Username 'username' not found/); expect(alertDialog.getText()).toMatch(/Username or password incorrect./);
alertDialog.accept(); alertDialog.accept();
}); });
@@ -58,4 +58,4 @@ describe('front page', function() {
expect(url).not.toMatch(/static\/front/); expect(url).not.toMatch(/static\/front/);
}); });
}); });
}); });

View File

@@ -8,7 +8,7 @@ TEST_SERVER_PORT=3001
grunt build:dev grunt build:dev
# Launch Node server and Selenium # Launch Node server and Selenium
echo "Recreating test database" echo "= Recreating test database"
mongo "$TEST_DB" --eval "db.dropDatabase()" mongo "$TEST_DB" --eval "db.dropDatabase()"
if [ -z "$TRAVIS" ]; then if [ -z "$TRAVIS" ]; then
@@ -34,10 +34,13 @@ NODE_DB_URI="$TEST_DB_URI" PORT=$TEST_SERVER_PORT node ./website/src/server.js >
NODE_PID=$! NODE_PID=$!
trap "kill $NODE_PID" EXIT trap "kill $NODE_PID" EXIT
echo "= Running mocha specs"
NODE_ENV=testing mocha || exit $? NODE_ENV=testing mocha || exit $?
if [ -z "$TRAVIS" ]; then if [ -z "$TRAVIS" ]; then
echo "= Running protractor specs"
NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $? NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $?
fi fi
echo "= Running karma specs"
NODE_ENV=testing grunt karma:continuous NODE_ENV=testing grunt karma:continuous