diff --git a/.travis.yml b/.travis.yml index b97b954663..26c2eab1a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,31 @@ python: - "3.4" - "3.5" - "3.6" + +matrix: + include: + - node_js: "lts/*" + language: node_js + python: "" + addons: + firefox: "45.0" + env: TEST_SUITE=js_unittests + - node_js: "lts/*" + language: node_js + python: "" + addons: + firefox: latest-esr + env: TEST_SUITE=js_unittests + +before_install: + - . src/ci_scripts/travis_before_install.sh + +before_script: + - . src/ci_scripts/travis_before_script.sh + script: - src/ci_scripts/travis.sh sqlite3 django$DJANGO_VERSION unittest + branches: - only: - - develop + only: + - develop diff --git a/src/.eslintrc b/src/.eslintrc index 2a15798a95..1e450ddbed 100644 --- a/src/.eslintrc +++ b/src/.eslintrc @@ -48,6 +48,7 @@ { "newIsCap": true, "capIsNew": true, + "capIsNewExceptions": ["URLify"], "properties": true } ], diff --git a/src/GruntFile.js b/src/GruntFile.js index 6c749c851d..66eacc6aeb 100644 --- a/src/GruntFile.js +++ b/src/GruntFile.js @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2017 CoNWeT Lab., Universidad Politécnica de Madrid + * Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L. * * This file is part of Wirecloud Platform. * @@ -156,14 +157,17 @@ module.exports = function (grunt) { options: { frameworks: ['jasmine'], reporters: ['progress', 'coverage'], - browsers: ['Chrome', 'Firefox'], + browsers: ['Firefox'], singleRun: true }, styledelements: { options: { coverageReporter: { - type : 'html', - dir : 'build/coverage/styledelements' + reporters: [ + {type: 'html', dir: 'build/coverage/styledelements', subdir: 'html'}, + {type: 'cobertura', dir: 'build/coverage/styledelements', subdir: 'xml'}, + {type: 'lcov', dir: 'build/coverage/styledelements', subdir: 'lcov'}, + ] }, files: dependencies.concat(styledElementsFiles).concat(['js_tests/styledelements/*Spec.js']), preprocessors: { @@ -174,8 +178,11 @@ module.exports = function (grunt) { wirecloud: { options: { coverageReporter: { - type : 'html', - dir : 'build/coverage/wirecloud' + reporters: [ + {type: 'html', dir: 'build/coverage/wirecloud', subdir: 'html'}, + {type: 'cobertura', dir: 'build/coverage/wirecloud', subdir: 'xml'}, + {type: 'lcov', dir: 'build/coverage/wirecloud', subdir: 'lcov'}, + ] }, files: dependencies.concat(styledElementsFiles).concat(wc_dependencies).concat(WirecloudFiles).concat(['js_tests/wirecloud/**/*Spec.js']), preprocessors: { @@ -224,6 +231,8 @@ module.exports = function (grunt) { 'karma' ]); + grunt.registerTask('ci', ['test']); + grunt.registerTask('default', [ 'test', 'uglify', diff --git a/src/ci_scripts/travis.sh b/src/ci_scripts/travis.sh index f009d5419b..081f6b9a72 100755 --- a/src/ci_scripts/travis.sh +++ b/src/ci_scripts/travis.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash +if [ "${TEST_SUITE}" == "js_unittests" ]; then + cd $TRAVIS_BUILD_DIR/src + grunt ci + exit +fi + + export WC_INSTANCE_NAME=test_instance [ -n "${IP_ADDR}" ] || IP_ADDR="localhost" diff --git a/src/ci_scripts/travis_before_install.sh b/src/ci_scripts/travis_before_install.sh new file mode 100755 index 0000000000..060c33fb39 --- /dev/null +++ b/src/ci_scripts/travis_before_install.sh @@ -0,0 +1,6 @@ +if [ "${TEST_SUITE}" == "js_unittests" ]; then + cd $TRAVIS_BUILD_DIR/src + npm install grunt-cli -g + npm install + cd $TRAVIS_BUILD_DIR +fi diff --git a/src/ci_scripts/travis_before_script.sh b/src/ci_scripts/travis_before_script.sh new file mode 100755 index 0000000000..6c603c4850 --- /dev/null +++ b/src/ci_scripts/travis_before_script.sh @@ -0,0 +1,5 @@ +if [ "${TEST_SUITE}" == "js_unittests" ]; then + export DISPLAY=:99.0 + sh -e /etc/init.d/xvfb start + sleep 3 # give xvfb some time to start +fi diff --git a/src/js_tests/styledelements/GUIBuilderSpec.js b/src/js_tests/styledelements/GUIBuilderSpec.js index 5b6af30a9a..4e0876f28a 100644 --- a/src/js_tests/styledelements/GUIBuilderSpec.js +++ b/src/js_tests/styledelements/GUIBuilderSpec.js @@ -205,24 +205,25 @@ check_template_context_type("function returning elements", function (options) { var element = document.createElement('div'); + element.textContent = 'a'; if (options != null && 'class' in options) { element.className = options.class; } return element; }, - '
', - '
' + '
a
', + '
a
' ); check_template_context_type("function returning styled elements", function (options) { - var element = new StyledElements.Button(); + var element = new StyledElements.Button({text: 'a'}); if (options != null && 'class' in options) { element.addClassName(options.class); } return element; }, - '
', - '
' + '
a
', + '
a
' ); check_template_context_type("function returning null", function (options) {return null;}); diff --git a/src/js_tests/wirecloud/TaskSpec.js b/src/js_tests/wirecloud/TaskSpec.js index fc0b03b4d1..0256f2b94f 100644 --- a/src/js_tests/wirecloud/TaskSpec.js +++ b/src/js_tests/wirecloud/TaskSpec.js @@ -726,11 +726,7 @@ }); it("title parameter is not required", () => { - var task_update, task_resolve; - var subtask = new Wirecloud.Task("subtask title", (resolve, reject, update) => { - task_update = update; - task_resolve = resolve; update(50); }); diff --git a/src/wirecloud/platform/static/js/wirecloud/Workspace.js b/src/wirecloud/platform/static/js/wirecloud/Workspace.js index 2a1dea3e21..7549f58cb5 100644 --- a/src/wirecloud/platform/static/js/wirecloud/Workspace.js +++ b/src/wirecloud/platform/static/js/wirecloud/Workspace.js @@ -19,7 +19,7 @@ * */ -/* globals encodeURIComponent, StyledElements, Wirecloud */ +/* globals encodeURIComponent, StyledElements, URLify, Wirecloud */ (function (ns, se, utils) { @@ -217,7 +217,7 @@ }); this.contextManager.modify({ - title: data.title != null && data.title.trim() != "" ? data.title : data.name, + title: data.title != null && data.title.trim() !== "" ? data.title : data.name, name: data.name, owner: data.owner, description: data.description, diff --git a/src/wirecloud/platform/static/js/wirecloud/core.js b/src/wirecloud/platform/static/js/wirecloud/core.js index 879ac93b2d..400ba97027 100644 --- a/src/wirecloud/platform/static/js/wirecloud/core.js +++ b/src/wirecloud/platform/static/js/wirecloud/core.js @@ -273,7 +273,7 @@ } else if ('owner' in workspace && 'name' in workspace) { url = Wirecloud.URLs.WORKSPACE_ENTRY_OWNER_NAME.evaluate({'owner': workspace.owner, 'name': workspace.name}); } else { - throw TypeError('use the id parameter or the owner/name pair of parameters'); + throw new TypeError('use the id parameter or the owner/name pair of parameters'); } return Wirecloud.io.makeRequest(url, { @@ -313,7 +313,7 @@ }, options); if (!('owner' in workspace && 'name' in workspace) && !('id' in workspace)) { - throw TypeError('use the id parameter or the owner/name pair of parameters'); + throw new TypeError('use the id parameter or the owner/name pair of parameters'); } if (!('owner' in workspace) || !('name' in workspace)) {