Commit e95ee994 by polesye

Add acceptance test instead of broken js unit test.

parent 7121db0a
...@@ -69,3 +69,11 @@ Feature: CMS.Video Component ...@@ -69,3 +69,11 @@ Feature: CMS.Video Component
# Then Captions become "invisible" after 3 seconds # Then Captions become "invisible" after 3 seconds
# And I hover over button "volume" # And I hover over button "volume"
# Then Captions are "invisible" # Then Captions are "invisible"
# 10
#Scenario: When enter key is pressed on a caption shows an outline around it
# Given I have created a Video component with subtitles
# And Make sure captions are opened
# Then I focus on caption line with data-index 0
# Then I press "enter" button on caption line with data-index 0
# And I see caption line with data-index 0 has class "focused"
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
from lettuce import world, step from lettuce import world, step
from xmodule.modulestore import Location from xmodule.modulestore import Location
from contentstore.utils import get_modulestore from contentstore.utils import get_modulestore
from selenium.webdriver.common.keys import Keys
BUTTONS = { BUTTONS = {
'CC': '.hide-subtitles', 'CC': '.hide-subtitles',
...@@ -154,3 +155,25 @@ def check_captions_visibility_state(_step, visibility_state, timeout): ...@@ -154,3 +155,25 @@ def check_captions_visibility_state(_step, visibility_state, timeout):
assert world.css_visible('.subtitles') assert world.css_visible('.subtitles')
else: else:
assert not world.css_visible('.subtitles') assert not world.css_visible('.subtitles')
def find_caption_line_by_data_index(index):
SELECTOR = ".subtitles > li[data-index='{index}']".format(index=index)
return world.css_find(SELECTOR).first
@step('I focus on caption line with data-index (\d+)$')
def focus_on_caption_line(_step, index):
find_caption_line_by_data_index(int(index.strip()))._element.send_keys(Keys.TAB)
@step('I press "enter" button on caption line with data-index (\d+)$')
def focus_on_caption_line(_step, index):
find_caption_line_by_data_index(int(index.strip()))._element.send_keys(Keys.ENTER)
@step('I see caption line with data-index (\d+) has class "([^"]*)"$')
def caption_line_has_class(_step, index, className):
SELECTOR = ".subtitles > li[data-index='{index}']".format(index=int(index.strip()))
world.css_has_class(SELECTOR, className.strip())
...@@ -756,44 +756,6 @@ ...@@ -756,44 +756,6 @@
expect(videoCaption.autoScrolling).toBe(true); expect(videoCaption.autoScrolling).toBe(true);
}); });
}); });
describe('when enter key is pressed on a caption', function () {
var assertCaptions = function (expectations) {
waitsFor(function () {
return videoCaption.captions.length;
}, "Captions are not loaded.", WAIT_TIMEOUT);
runs(expectations);
},
initializeClick = function () {
var e,
subDataLiIdx__0 = $('.subtitles li[data-index=0]');
spyOn(videoCaption, 'seekPlayer').andCallThrough();
videoCaption.isMouseFocus = false;
subDataLiIdx__0.trigger(jQuery.Event('focus'));
e = jQuery.Event('keydown');
e.which = 13; // ENTER key
subDataLiIdx__0.trigger(e);
};
it('shows an outline around it' , function () {
assertCaptions(function() {
var subDataLiIdx__0 = $('.subtitles li[data-index=0]');
initializeClick();
expect(subDataLiIdx__0).toHaveClass('focused');
});
});
it('calls seekPlayer', function () {
assertCaptions(function() {
initializeClick();
expect(videoCaption.seekPlayer).toHaveBeenCalled();
});
});
});
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment