From dfd369b9e992672e0df351aae870c356dfdcc7cf Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 30 Apr 2013 14:09:17 -0400 Subject: [PATCH 1/5] Make ordering of js bundles during jasmine tests consistant --- cms/envs/common.py | 8 ++++---- cms/envs/jasmine.py | 2 +- lms/envs/common.py | 21 ++++++++++++++++----- lms/envs/jasmine.py | 4 ++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 680d19ca34..8effc773e0 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -206,6 +206,8 @@ PIPELINE_CSS = { }, } +# test_order: Determines the position of this chunk of javascript on +# the jasmine test page PIPELINE_JS = { 'main': { 'source_filenames': sorted( @@ -213,6 +215,7 @@ PIPELINE_JS = { rooted_glob(PROJECT_ROOT / 'static/', 'coffee/src/**/*.js') ) + ['js/hesitate.js', 'js/base.js'], 'output_filename': 'js/cms-application.js', + 'test_order': 0 }, 'module-js': { 'source_filenames': ( @@ -220,11 +223,8 @@ PIPELINE_JS = { rooted_glob(COMMON_ROOT / 'static/', 'xmodule/modules/js/*.js') ), 'output_filename': 'js/cms-modules.js', + 'test_order': 1 }, - 'spec': { - 'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.js')), - 'output_filename': 'js/cms-spec.js' - } } PIPELINE_CSS_COMPRESSOR = None diff --git a/cms/envs/jasmine.py b/cms/envs/jasmine.py index ac28f8fc9a..70b5b217ef 100644 --- a/cms/envs/jasmine.py +++ b/cms/envs/jasmine.py @@ -20,7 +20,7 @@ PIPELINE_JS['js-test-source'] = { 'source_filenames': sum([ pipeline_group['source_filenames'] for group_name, pipeline_group - in PIPELINE_JS.items() + 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' diff --git a/lms/envs/common.py b/lms/envs/common.py index 1fe6978ac2..32a213f06e 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -440,6 +440,9 @@ PIPELINE_CSS = { }, } + +# test_order: Determines the position of this chunk of javascript on +# the jasmine test page PIPELINE_JS = { 'application': { @@ -455,31 +458,39 @@ PIPELINE_JS = { 'js/sticky_filter.js', 'js/query-params.js', ], - 'output_filename': 'js/lms-application.js' + 'output_filename': 'js/lms-application.js', + + 'test_order': 1, }, 'courseware': { 'source_filenames': courseware_js, - 'output_filename': 'js/lms-courseware.js' + 'output_filename': 'js/lms-courseware.js', + 'test_order': 2, }, 'main_vendor': { 'source_filenames': main_vendor_js, 'output_filename': 'js/lms-main_vendor.js', + 'test_order': 0, }, 'module-js': { 'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'), 'output_filename': 'js/lms-modules.js', + 'test_order': 3, }, 'discussion': { 'source_filenames': discussion_js, - 'output_filename': 'js/discussion.js' + 'output_filename': 'js/discussion.js', + 'test_order': 4, }, 'staff_grading': { 'source_filenames': staff_grading_js, - 'output_filename': 'js/staff_grading.js' + 'output_filename': 'js/staff_grading.js', + 'test_order': 5, }, 'open_ended': { 'source_filenames': open_ended_js, - 'output_filename': 'js/open_ended.js' + 'output_filename': 'js/open_ended.js', + 'test_order': 6, } } diff --git a/lms/envs/jasmine.py b/lms/envs/jasmine.py index 8551d80504..f3f20e7fbc 100644 --- a/lms/envs/jasmine.py +++ b/lms/envs/jasmine.py @@ -20,14 +20,14 @@ PIPELINE_JS['js-test-source'] = { 'source_filenames': sum([ pipeline_group['source_filenames'] for group_name, pipeline_group - in PIPELINE_JS.items() + in sorted(PIPELINE_JS.items(), key=lambda item: item[1].get('test_order', 1e100)) if group_name != 'spec' ], []), 'output_filename': 'js/lms-test-source.js' } PIPELINE_JS['spec'] = { - 'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.coffee')), + 'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.js')), 'output_filename': 'js/lms-spec.js' } From 771937b3da02ea29dee63a43701cee5412ce0b0f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 30 Apr 2013 14:09:42 -0400 Subject: [PATCH 2/5] Remove duplicate libraries used while jasmine testing the LMS (as they are also defined in vendor) --- lms/static/coffee/files.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/lms/static/coffee/files.json b/lms/static/coffee/files.json index 0efe488dd9..d9d7087efe 100644 --- a/lms/static/coffee/files.json +++ b/lms/static/coffee/files.json @@ -1,8 +1,5 @@ { "js_files": [ - "/static/js/vendor/RequireJS.js", - "/static/js/vendor/jquery.min.js", - "/static/js/vendor/jquery-ui.min.js", "/static/js/vendor/jquery.leanModal.min.js", "/static/js/vendor/flot/jquery.flot.js" ] From 76599863e6b73990368a2f5c0c9aba43678e6331 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 30 Apr 2013 14:09:58 -0400 Subject: [PATCH 3/5] Compile all coffee and sass before running jasmine tests --- rakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rakefile b/rakefile index 2b9cb9fd57..459ecca3f3 100644 --- a/rakefile +++ b/rakefile @@ -301,6 +301,7 @@ end desc "Open jasmine tests for #{system} in your default browser" task "browse_jasmine_#{system}" do + compile_assets() django_for_jasmine(system, true) do |jasmine_url| Launchy.open(jasmine_url) puts "Press ENTER to terminate".red @@ -310,6 +311,7 @@ end desc "Use phantomjs to run jasmine tests for #{system} from the console" task "phantomjs_jasmine_#{system}" do + compile_assets() phantomjs = ENV['PHANTOMJS_PATH'] || 'phantomjs' django_for_jasmine(system, false) do |jasmine_url| sh("#{phantomjs} common/test/phantom-jasmine/lib/run_jasmine_test.coffee #{jasmine_url}") From aa4e29d2f1ac51c402957644c9c93c5ac4158c78 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Tue, 30 Apr 2013 15:21:23 -0400 Subject: [PATCH 4/5] Add leanModal vendor src to files.json for cms jasmine tests. Also .gitignore compiled js from coffee specs --- cms/static/coffee/files.json | 3 ++- common/static/coffee/spec/.gitignore | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 common/static/coffee/spec/.gitignore diff --git a/cms/static/coffee/files.json b/cms/static/coffee/files.json index e7a66b5bc0..c2e1a8acf6 100644 --- a/cms/static/coffee/files.json +++ b/cms/static/coffee/files.json @@ -7,6 +7,7 @@ "js/vendor/jquery.cookie.js", "js/vendor/json2.js", "js/vendor/underscore-min.js", - "js/vendor/backbone-min.js" + "js/vendor/backbone-min.js", + "js/vendor/jquery.leanModal.min.js" ] } diff --git a/common/static/coffee/spec/.gitignore b/common/static/coffee/spec/.gitignore new file mode 100644 index 0000000000..a6c7c2852d --- /dev/null +++ b/common/static/coffee/spec/.gitignore @@ -0,0 +1 @@ +*.js From 7f93443dfb898a6ff9d529e38a2bfc74412ccdf5 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Wed, 1 May 2013 10:53:58 -0400 Subject: [PATCH 5/5] Make the test_root/db directory and add a .gitignore for the db files that will be created there. --- test_root/db/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 test_root/db/.gitignore diff --git a/test_root/db/.gitignore b/test_root/db/.gitignore new file mode 100644 index 0000000000..98e6ef67fa --- /dev/null +++ b/test_root/db/.gitignore @@ -0,0 +1 @@ +*.db