From 6eeb12ad1c61eb5a8a35b03a3d00bc245a0c84ed Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Thu, 30 May 2013 11:32:40 -0400 Subject: [PATCH] Add Lettuce tests for autoplay in Studio. --- .../contentstore/features/common.py | 9 ++++++ .../features/component_settings_editor.py | 32 +++++++++++++++++++ .../contentstore/features/video.feature | 6 ++++ cms/djangoapps/contentstore/features/video.py | 14 ++++++++ cms/envs/common.py | 4 +-- cms/templates/unit.html | 8 ++--- .../js/src/video/display/video_player.coffee | 2 +- lms/envs/common.py | 5 ++- lms/templates/video.html | 2 +- 9 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 cms/djangoapps/contentstore/features/component_settings_editor.py create mode 100644 cms/djangoapps/contentstore/features/video.feature create mode 100644 cms/djangoapps/contentstore/features/video.py diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index afb38c3f9e..95938242ca 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -154,3 +154,12 @@ def set_date_and_time(date_css, desired_date, time_css, desired_time): e = world.css_find(time_css).first e._element.send_keys(Keys.TAB) time.sleep(float(1)) + + +@step('I have created a Video component$') +def i_created_a_video_component(step): + world.create_component_instance( + step, '.large-video-icon', + 'i4x://edx/templates/video/default', + '.xmodule_VideoModule' + ) diff --git a/cms/djangoapps/contentstore/features/component_settings_editor.py b/cms/djangoapps/contentstore/features/component_settings_editor.py new file mode 100644 index 0000000000..0a4e761fbd --- /dev/null +++ b/cms/djangoapps/contentstore/features/component_settings_editor.py @@ -0,0 +1,32 @@ +#pylint: disable=C0111 +#pylint: disable=W0621 + +from lettuce import world +from nose.tools import assert_equal + +import time + + +@world.absorb +def create_component_instance(step, component_button_css, instance_id, expected_css): + click_new_component_button(step, component_button_css) + click_component_from_menu(instance_id, expected_css) + + +@world.absorb +def click_new_component_button(step, component_button_css): + step.given('I have opened a new course section in Studio') + step.given('I have added a new subsection') + step.given('I expand the first section') + world.css_click('a.new-unit-item') + world.css_click(component_button_css) + + +@world.absorb +def click_component_from_menu(instance_id, expected_css): + new_instance = world.browser.find_by_id(instance_id) + assert_equal(1, len(new_instance)) + # TODO: why is this sleep necessary? + time.sleep(float(1)) + new_instance[0].click() + assert_equal(1, len(world.css_find(expected_css))) diff --git a/cms/djangoapps/contentstore/features/video.feature b/cms/djangoapps/contentstore/features/video.feature new file mode 100644 index 0000000000..31fb01814c --- /dev/null +++ b/cms/djangoapps/contentstore/features/video.feature @@ -0,0 +1,6 @@ +Feature: Video Component + As a course author, I want to be able to view my created videos in Studio. + + Scenario: Autoplay is disabled in Studio + Given I have created a Video component + Then when I view it it does not autoplay \ No newline at end of file diff --git a/cms/djangoapps/contentstore/features/video.py b/cms/djangoapps/contentstore/features/video.py new file mode 100644 index 0000000000..2e5ab0f6ed --- /dev/null +++ b/cms/djangoapps/contentstore/features/video.py @@ -0,0 +1,14 @@ +#pylint: disable=C0111 +#pylint: disable=W0621 + +from lettuce import world, step +from common import * +from nose.tools import assert_equal + +############### ACTIONS #################### + + +@step('when I view it it does not autoplay') +def does_not_autoplay(step): + assert world.css_find('.video')[0]['data-autoplay'] == 'False' + assert world.css_find('.video_control')[0].has_class('play') diff --git a/cms/envs/common.py b/cms/envs/common.py index 3f322b5001..6a1f1bf0af 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -42,8 +42,8 @@ MITX_FEATURES = { # Enable URL that shows information about the status of various services 'ENABLE_SERVICE_STATUS': False, - # We're in the CMS. - 'IN_CMS': True + # Don't autoplay videos for course authors + 'AUTOPLAY_VIDEOS': False } ENABLE_JASMINE = False diff --git a/cms/templates/unit.html b/cms/templates/unit.html index cb34f42a09..f6540fa1e5 100644 --- a/cms/templates/unit.html +++ b/cms/templates/unit.html @@ -82,14 +82,14 @@ % if has_markdown or type != "problem": % if is_empty:
  • - + ${name}
  • % else:
  • - + ${name}
  • @@ -106,14 +106,14 @@ % if not has_markdown: % if is_empty:
  • - + ${name}
  • % else:
  • - + ${name} diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee index 47f822bd92..561ca07c8a 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee @@ -66,7 +66,7 @@ class @VideoPlayer extends Subview at: 'top center' onReady: (event) => - unless onTouchBasedDevice() or $('.video:first').data('in-cms') + unless onTouchBasedDevice() or $('.video:first').data('autoplay') == 'False' $('.video-load-complete:first').data('video').player.play() onStateChange: (event) => diff --git a/lms/envs/common.py b/lms/envs/common.py index e7bc9519d9..f75dcf8804 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -113,7 +113,10 @@ MITX_FEATURES = { 'ENABLE_SERVICE_STATUS': False, # Toggle to indicate use of a custom theme - 'USE_CUSTOM_THEME': False + 'USE_CUSTOM_THEME': False, + + # Do autoplay videos for students + 'AUTOPLAY_VIDEOS': True } # Used for A/B testing diff --git a/lms/templates/video.html b/lms/templates/video.html index 0bbcf046cd..2a864b2f18 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -16,7 +16,7 @@ width="640" height="390"> %else: -
    +