Add Lettuce tests for autoplay in Studio.

This commit is contained in:
Peter Fogg
2013-05-30 11:32:40 -04:00
committed by Peter Fogg
parent 5465bda5f3
commit 6eeb12ad1c
9 changed files with 73 additions and 9 deletions

View File

@@ -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'
)

View File

@@ -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)))

View File

@@ -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

View File

@@ -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')

View File

@@ -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

View File

@@ -82,14 +82,14 @@
% if has_markdown or type != "problem":
% if is_empty:
<li class="editor-md empty">
<a href="#" data-location="${location}">
<a href="#" data-location="${location}" id="${location}">
<span class="name"> ${name}</span>
</a>
</li>
% else:
<li class="editor-md">
<a href="#" data-location="${location}">
<a href="#" data-location="${location}" id="${location}">
<span class="name"> ${name}</span>
</a>
</li>
@@ -106,14 +106,14 @@
% if not has_markdown:
% if is_empty:
<li class="editor-manual empty">
<a href="#" data-location="${location}">
<a href="#" data-location="${location}" id="${location}">
<span class="name">${name}</span>
</a>
</li>
% else:
<li class="editor-manual">
<a href="#" data-location="${location}">
<a href="#" data-location="${location}" id="${location}">
<span class="name"> ${name}</span>
</a>

View File

@@ -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) =>

View File

@@ -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

View File

@@ -16,7 +16,7 @@
width="640" height="390"></embed>
</object>
%else:
<div id="video_${id}" class="video" data-streams="${streams}" data-show-captions="${show_captions}" data-start="${start}" data-end="${end}" data-caption-asset-path="${caption_asset_path}" data-in-cms="${settings.MITX_FEATURES.get('IN_CMS', False)}">
<div id="video_${id}" class="video" data-streams="${streams}" data-show-captions="${show_captions}" data-start="${start}" data-end="${end}" data-caption-asset-path="${caption_asset_path}" data-autoplay="${settings.MITX_FEATURES['AUTOPLAY_VIDEOS']}">
<div class="tc-wrapper">
<article class="video-wrapper">
<section class="video-player">