diff --git a/common/dist/scripts/habitrpg-shared.js b/common/dist/scripts/habitrpg-shared.js index 11527f84ca..7048604c3e 100644 --- a/common/dist/scripts/habitrpg-shared.js +++ b/common/dist/scripts/habitrpg-shared.js @@ -4872,7 +4872,11 @@ module.exports = { if ((locale == null) || (!module.exports.strings && !module.exports.translations[locale])) { 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.locale = locale; if (string) { @@ -4883,7 +4887,11 @@ module.exports = { return 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'; } } 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 { return _.template(stringNotFound, { string: stringName diff --git a/common/script/i18n.coffee b/common/script/i18n.coffee index 8b99175f5f..efd19c911a 100644 --- a/common/script/i18n.coffee +++ b/common/script/i18n.coffee @@ -1,6 +1,6 @@ _ = require 'lodash' -module.exports = +module.exports = strings: null, # Strings for one single language translations: {} # Strings for multiple languages {en: strings, de: strings, ...} t: (stringName) -> # Other parameters allowed are vars (Object) and locale (String) @@ -14,10 +14,16 @@ module.exports = locale = arguments[2] 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] - - clonedVars = _.clone(vars) or {}; - clonedVars.locale = locale; + + if module.exports.strings + string = module.exports.strings[stringName] + else + string = + module.exports.translations[locale] and + module.exports.translations[locale][stringName] + + clonedVars = _.clone(vars) or {} + clonedVars.locale = locale if string try @@ -25,8 +31,14 @@ module.exports = catch e 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.' 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 _.template(stringNotFound, {string: stringName}) catch e - 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.' \ No newline at end of file + 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.' diff --git a/karma.conf.js b/karma.conf.js index 83c9e0a776..0481d056bc 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -96,6 +96,8 @@ module.exports = function(config) { // - IE (only Windows) browsers: ['PhantomJS'], + // Enable mocha-style reporting, for better test visibility + reporters: ['mocha'], // Continuous Integration mode // if true, it capture browsers, run tests and exit diff --git a/package.json b/package.json index 5f9a9d42b4..64c576a05d 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "karma-html2js-preprocessor": "~0.1.0", "karma-jasmine": "~0.1.3", "karma-mocha": "0.1.3", + "karma-mocha-reporter": "^1.0.2", "karma-ng-html2js-preprocessor": "~0.1.0", "karma-phantomjs-launcher": "~0.1.0", "karma-requirejs": "~0.2.0", diff --git a/protractor.conf.js b/protractor.conf.js index 32999a2233..fef43baab8 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -19,6 +19,6 @@ exports.config = { // Options to be passed to Jasmine-node. jasmineNodeOpts: { showColors: true, - defaultTimeoutInterval: 30000 + defaultTimeoutInterval: 60000 } }; diff --git a/test/e2e/e2e.js b/test/e2e/e2e.js index 8bbdbe8a62..0f471df3d9 100644 --- a/test/e2e/e2e.js +++ b/test/e2e/e2e.js @@ -37,7 +37,7 @@ describe('front page', function() { var login = element(by.css("#login-tab input[value='Login']")); login.click(); var alertDialog = browser.switchTo().alert(); - expect(alertDialog.getText()).toMatch(/Username 'username' not found/); + expect(alertDialog.getText()).toMatch(/Username or password incorrect./); alertDialog.accept(); }); @@ -58,4 +58,4 @@ describe('front page', function() { expect(url).not.toMatch(/static\/front/); }); }); -}); \ No newline at end of file +}); diff --git a/test/run_tests.sh b/test/run_tests.sh index 43b395c833..d8bef87efe 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -8,7 +8,7 @@ TEST_SERVER_PORT=3001 grunt build:dev # Launch Node server and Selenium -echo "Recreating test database" +echo "= Recreating test database" mongo "$TEST_DB" --eval "db.dropDatabase()" 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=$! trap "kill $NODE_PID" EXIT +echo "= Running mocha specs" NODE_ENV=testing mocha || exit $? if [ -z "$TRAVIS" ]; then + echo "= Running protractor specs" NODE_ENV=testing ./node_modules/protractor/bin/protractor protractor.conf.js || exit $? fi +echo "= Running karma specs" NODE_ENV=testing grunt karma:continuous