From fe727309694b3450313d5dcd57a12860957ff9ac Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 26 Aug 2013 20:03:18 -0400 Subject: [PATCH] Integrate js-test-tool into testing infrastructure --- cms/envs/jasmine.py | 53 ------ cms/static/coffee/files.json | 20 --- cms/static/coffee/spec/helpers.coffee | 2 +- cms/static/js_test.yml | 96 ++++++++++ cms/static/xmodule_js | 1 + cms/urls.py | 4 - common/lib/xmodule/xmodule/js/common_static | 1 + .../js/fixtures}/test.mp4 | Bin .../js/fixtures}/test.ogv | Bin .../js/fixtures}/test.webm | Bin .../xmodule/js/fixtures/video_all.html | 8 +- .../xmodule/js/fixtures/video_html5.html | 8 +- common/lib/xmodule/xmodule/js/js_test.yml | 64 +++++++ .../js/spec/annotatable/display_spec.coffee | 2 +- .../xmodule/js/spec/capa/display_spec.coffee | 1 - .../lib/xmodule/xmodule/js/spec/helper.coffee | 2 +- .../xmodule/js/spec/html/edit_spec.coffee | 2 +- .../xmodule/js/spec/video/general_spec.js | 8 +- .../xmodule/js/spec/video/html5_video_spec.js | 7 +- .../xmodule/xmodule/js/spec/video/readme.md | 8 - .../js/spec/video/video_caption_spec.js | 14 +- .../js/spec/video/video_control_spec.js | 2 +- .../js/spec/video/video_player_spec.js | 2 +- .../spec/video/video_progress_slider_spec.js | 2 +- .../spec/video/video_quality_control_spec.js | 2 +- .../js/spec/video/video_speed_control_spec.js | 2 +- .../spec/video/video_volume_control_spec.js | 2 +- common/static/js/test/add_ajax_prefix.js | 5 + common/static/js_test.yml | 84 +++++++++ docs/internal/testing.md | 42 ++--- jenkins/test.sh | 7 + jenkins/test_acceptance.sh | 2 +- lms/envs/jasmine.py | 47 ----- lms/static/coffee/README.md | 5 +- lms/static/coffee/files.json | 6 - lms/static/coffee/spec/helper.coffee | 2 +- lms/static/js/Markdown.Editor.js | 2 +- lms/static/js_test.yml | 88 ++++++++++ lms/static/xmodule_js | 1 + lms/urls.py | 3 - package.json | 4 +- rakelib/deprecated.rake | 46 ++++- rakelib/jasmine.rake | 165 ------------------ rakelib/js_test.rake | 85 +++++++++ rakelib/tests.rake | 51 ++---- requirements/edx/base.txt | 1 - requirements/edx/github.txt | 1 + 47 files changed, 546 insertions(+), 414 deletions(-) delete mode 100644 cms/envs/jasmine.py delete mode 100644 cms/static/coffee/files.json create mode 100644 cms/static/js_test.yml create mode 120000 cms/static/xmodule_js create mode 120000 common/lib/xmodule/xmodule/js/common_static rename common/lib/xmodule/{test_files => xmodule/js/fixtures}/test.mp4 (100%) rename common/lib/xmodule/{test_files => xmodule/js/fixtures}/test.ogv (100%) rename common/lib/xmodule/{test_files => xmodule/js/fixtures}/test.webm (100%) create mode 100644 common/lib/xmodule/xmodule/js/js_test.yml delete mode 100644 common/lib/xmodule/xmodule/js/spec/video/readme.md create mode 100644 common/static/js/test/add_ajax_prefix.js create mode 100644 common/static/js_test.yml delete mode 100644 lms/envs/jasmine.py delete mode 100644 lms/static/coffee/files.json create mode 100644 lms/static/js_test.yml create mode 120000 lms/static/xmodule_js delete mode 100644 rakelib/jasmine.rake create mode 100644 rakelib/js_test.rake diff --git a/cms/envs/jasmine.py b/cms/envs/jasmine.py deleted file mode 100644 index a4b8292d71..0000000000 --- a/cms/envs/jasmine.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -This configuration is used for running jasmine tests -""" - -# We intentionally define lots of variables that aren't used, and -# want to import all variables from base settings files -# pylint: disable=W0401, W0614 - -from .test import * -from logsettings import get_logger_config - -ENABLE_JASMINE = True -DEBUG = True - -LOGGING = get_logger_config(TEST_ROOT / "log", - logging_env="dev", - tracking_filename="tracking.log", - dev_env=True, - debug=True, - local_loglevel='ERROR', - console_loglevel='ERROR') - -PIPELINE_JS['js-test-source'] = { - 'source_filenames': sum([ - pipeline_group['source_filenames'] - for group_name, pipeline_group - in sorted(PIPELINE_JS.items(), key=lambda item: item[1].get('test_order', 1e100)) - if group_name != 'spec' - ], []), - 'output_filename': 'js/cms-test-source.js' -} - -PIPELINE_JS['spec'] = { - 'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.js')), - 'output_filename': 'js/cms-spec.js' -} - -JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee' -JASMINE_REPORT_DIR = os.environ.get('JASMINE_REPORT_DIR', 'reports/cms/jasmine') - -TEMPLATE_CONTEXT_PROCESSORS += ('settings_context_processor.context_processors.settings',) -TEMPLATE_VISIBLE_SETTINGS = ('JASMINE_REPORT_DIR', ) - -STATICFILES_DIRS.append(REPO_ROOT/'node_modules/phantom-jasmine/lib') -STATICFILES_DIRS.append(REPO_ROOT/'node_modules/jasmine-reporters/src') - -# Remove the localization middleware class because it requires the test database -# to be sync'd and migrated in order to run the jasmine tests interactively -# with a browser -MIDDLEWARE_CLASSES = tuple(e for e in MIDDLEWARE_CLASSES \ - if e != 'django.middleware.locale.LocaleMiddleware') - -INSTALLED_APPS += ('django_jasmine', 'settings_context_processor') diff --git a/cms/static/coffee/files.json b/cms/static/coffee/files.json deleted file mode 100644 index 3964bee455..0000000000 --- a/cms/static/coffee/files.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "static_files": [ - "../jsi18n/", - "js/vendor/RequireJS.js", - "js/vendor/jquery.min.js", - "js/vendor/jquery-ui.min.js", - "js/vendor/jquery.ui.draggable.js", - "js/vendor/jquery.cookie.js", - "js/vendor/json2.js", - "js/vendor/underscore-min.js", - "js/vendor/underscore.string.min.js", - "js/vendor/backbone-min.js", - "js/vendor/backbone-associations-min.js", - "js/vendor/jquery.leanModal.min.js", - "js/vendor/jquery.form.js", - "js/vendor/sinon-1.7.1.js", - "js/vendor/jasmine-stealth.js", - "js/test/i18n.js" - ] -} diff --git a/cms/static/coffee/spec/helpers.coffee b/cms/static/coffee/spec/helpers.coffee index 116983edf5..a03e2a0e56 100644 --- a/cms/static/coffee/spec/helpers.coffee +++ b/cms/static/coffee/spec/helpers.coffee @@ -1,4 +1,4 @@ -jasmine.getFixtures().fixturesPath = 'fixtures' +jasmine.getFixtures().fixturesPath += 'coffee/fixtures' # Stub jQuery.cookie @stubCookies = diff --git a/cms/static/js_test.yml b/cms/static/js_test.yml new file mode 100644 index 0000000000..cc4ee97d49 --- /dev/null +++ b/cms/static/js_test.yml @@ -0,0 +1,96 @@ +--- +# JavaScript test suite description +# +# +# To run all the tests and print results to the console: +# +# js-test-tool run TEST_SUITE --use-firefox +# +# where `TEST_SUITE` is this file. +# +# +# To run the tests in your default browser ("dev mode"): +# +# js-test-tool dev TEST_SUITE +# + +test_suite_name: cms + +test_runner: jasmine + +# Path prepended to source files in the coverage report (optional) +# For example, if the source path +# is "src/source.js" (relative to this YAML file) +# and the prepend path is "base/dir" +# then the coverage report will show +# "base/dir/src/source.js" +prepend_path: cms/static + +# Paths to library JavaScript files (optional) +lib_paths: + - xmodule_js/common_static/coffee/src/ajax_prefix.js + - xmodule_js/common_static/coffee/src/logger.js + - xmodule_js/common_static/js/vendor/RequireJS.js + - xmodule_js/common_static/js/vendor/json2.js + - xmodule_js/common_static/js/vendor/jquery.min.js + - xmodule_js/common_static/js/vendor/jquery-ui.min.js + - xmodule_js/common_static/js/vendor/jquery.cookie.js + - xmodule_js/common_static/js/vendor/jquery.qtip.min.js + - xmodule_js/common_static/js/vendor/swfobject/swfobject.js + - xmodule_js/common_static/js/vendor/jquery.ba-bbq.min.js + - xmodule_js/common_static/js/vendor/annotator.min.js + - xmodule_js/common_static/js/vendor/annotator.store.min.js + - xmodule_js/common_static/js/vendor/annotator.tags.min.js + - xmodule_js/common_static/js/vendor/underscore-min.js + - xmodule_js/common_static/js/vendor/underscore.string.min.js + - xmodule_js/common_static/js/vendor/backbone-min.js + - xmodule_js/common_static/js/vendor/backbone-associations-min.js + - xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker.js + - xmodule_js/common_static/js/vendor/jquery.leanModal.min.js + - xmodule_js/common_static/js/vendor/jquery.form.js + - xmodule_js/common_static/js/vendor/sinon-1.7.1.js + - xmodule_js/common_static/js/vendor/jasmine-jquery.js + - xmodule_js/common_static/js/vendor/jasmine-stealth.js + - xmodule_js/src/xmodule.js + - xmodule_js/src + - xmodule_js/common_static/js/test/add_ajax_prefix.js + +# Paths to source JavaScript files +src_paths: + - coffee/src + - js + +# Paths to spec (test) JavaScript files +spec_paths: + - coffee/spec/helpers.js + - coffee/spec + +# Paths to fixture files (optional) +# The fixture path will be set automatically when using jasmine-jquery. +# (https://github.com/velesin/jasmine-jquery) +# +# You can then access fixtures using paths relative to +# the test suite description: +# +# loadFixtures('path/to/fixture/fixture.html'); +# +fixture_paths: + - coffee/fixtures + +# Regular expressions used to exclude *.js files from +# appearing in the test runner page. +# Files are included by default, which means that they +# are loaded using a