Commit af6c5efb by Muhammad Ammar

Bok-Choy video tests batch4

parent 04376e08
...@@ -102,7 +102,6 @@ class CourseNavPage(PageObject): ...@@ -102,7 +102,6 @@ class CourseNavPage(PageObject):
self.q(css=subsection_css).first.click() self.q(css=subsection_css).first.click()
self._on_section_promise(section_title, subsection_title).fulfill() self._on_section_promise(section_title, subsection_title).fulfill()
def go_to_sequential(self, sequential_title): def go_to_sequential(self, sequential_title):
""" """
Within a section/subsection, navigate to the sequential with `sequential_title`. Within a section/subsection, navigate to the sequential with `sequential_title`.
......
...@@ -6,26 +6,6 @@ from bok_choy.web_app_test import WebAppTest ...@@ -6,26 +6,6 @@ from bok_choy.web_app_test import WebAppTest
from bok_choy.promise import EmptyPromise from bok_choy.promise import EmptyPromise
def wait_for_ajax(browser, try_limit=None, try_interval=0.5, timeout=60):
"""
Make sure that all ajax requests are finished.
:param try_limit (int or None): Number of attempts to make to satisfy the `Promise`. Can be `None` to
disable the limit.
:param try_interval (float): Number of seconds to wait between attempts.
:param timeout (float): Maximum number of seconds to wait for the `Promise` to be satisfied before timing out.
:param browser: selenium.webdriver, The Selenium-controlled browser that this page is loaded in.
"""
def _is_ajax_finished():
"""
Check if all the ajax call on current page completed.
:return:
"""
return browser.execute_script("return jQuery.active") == 0
EmptyPromise(_is_ajax_finished, "Finished waiting for ajax requests.", try_limit=try_limit,
try_interval=try_interval, timeout=timeout).fulfill()
def load_data_str(rel_path): def load_data_str(rel_path):
""" """
Load a file from the "data" directory as a string. Load a file from the "data" directory as a string.
......
...@@ -319,7 +319,7 @@ class YouTubeVideoTest(VideoBaseTest): ...@@ -319,7 +319,7 @@ class YouTubeVideoTest(VideoBaseTest):
# check if we can download transcript in "srt" format that has text "好 各位同学" # check if we can download transcript in "srt" format that has text "好 各位同学"
unicode_text = "好 各位同学".decode('utf-8') unicode_text = "好 各位同学".decode('utf-8')
self.video.downloaded_transcript_contains_text('srt', unicode_text) self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text))
def test_download_button_two_transcript_languages(self): def test_download_button_two_transcript_languages(self):
""" """
...@@ -343,10 +343,10 @@ class YouTubeVideoTest(VideoBaseTest): ...@@ -343,10 +343,10 @@ class YouTubeVideoTest(VideoBaseTest):
self.assertIn('Hi, welcome to Edx.', self.video.captions_text) self.assertIn('Hi, welcome to Edx.', self.video.captions_text)
# check if we can download transcript in "srt" format that has text "Hi, welcome to Edx." # check if we can download transcript in "srt" format that has text "Hi, welcome to Edx."
self.video.downloaded_transcript_contains_text('srt', 'Hi, welcome to Edx.') self.assertTrue(self.video.downloaded_transcript_contains_text('srt', 'Hi, welcome to Edx.'))
# select language with code "zh" # select language with code "zh"
self.video.select_language('zh') self.assertTrue(self.video.select_language('zh'))
# check if we see "好 各位同学" text in the captions # check if we see "好 各位同学" text in the captions
unicode_text = "好 各位同学".decode('utf-8') unicode_text = "好 各位同学".decode('utf-8')
...@@ -354,7 +354,7 @@ class YouTubeVideoTest(VideoBaseTest): ...@@ -354,7 +354,7 @@ class YouTubeVideoTest(VideoBaseTest):
# check if we can download transcript in "srt" format that has text "好 各位同学" # check if we can download transcript in "srt" format that has text "好 各位同学"
unicode_text = "好 各位同学".decode('utf-8') unicode_text = "好 各位同学".decode('utf-8')
self.video.downloaded_transcript_contains_text('srt', unicode_text) self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text))
def test_fullscreen_video_alignment_on_transcript_toggle(self): def test_fullscreen_video_alignment_on_transcript_toggle(self):
""" """
...@@ -437,6 +437,59 @@ class YouTubeVideoTest(VideoBaseTest): ...@@ -437,6 +437,59 @@ class YouTubeVideoTest(VideoBaseTest):
self.assertTrue(self.video.is_video_rendered('html5')) self.assertTrue(self.video.is_video_rendered('html5'))
def test_download_transcript_button_works_correctly(self):
"""
Scenario: Download Transcript button works correctly
Given the course has Video components A and B in "Youtube" mode
And Video component C in "HTML5" mode
And I have defined downloadable transcripts for the videos
Then I can download a transcript for Video A in "srt" format
And I can download a transcript for Video A in "txt" format
And I can download a transcript for Video B in "txt" format
And the Download Transcript menu does not exist for Video C
"""
data_a = {'sub': 'OEoXaMPEzfM', 'download_track': True}
youtube_a_metadata = self.metadata_for_mode('youtube', additional_data=data_a)
self.assets.append('subs_OEoXaMPEzfM.srt.sjson')
data_b = {'youtube_id_1_0': 'b7xgknqkQk8', 'sub': 'b7xgknqkQk8', 'download_track': True}
youtube_b_metadata = self.metadata_for_mode('youtube', additional_data=data_b)
self.assets.append('subs_b7xgknqkQk8.srt.sjson')
data_c = {'track': 'http://example.org/', 'download_track': True}
html5_c_metadata = self.metadata_for_mode('html5', additional_data=data_c)
self.verticals = [
[{'display_name': 'A', 'metadata': youtube_a_metadata}],
[{'display_name': 'B', 'metadata': youtube_b_metadata}],
[{'display_name': 'C', 'metadata': html5_c_metadata}]
]
# open the section with videos (open video "A")
self.navigate_to_video()
# check if we can download transcript in "srt" format that has text "00:00:00,270"
self.assertTrue(self.video.downloaded_transcript_contains_text('srt', '00:00:00,270'))
# select the transcript format "txt"
self.assertTrue(self.video.select_transcript_format('txt'))
# check if we can download transcript in "txt" format that has text "Hi, welcome to Edx."
self.assertTrue(self.video.downloaded_transcript_contains_text('txt', 'Hi, welcome to Edx.'))
# open video "B"
self.course_nav.go_to_sequential('B')
# check if we can download transcript in "txt" format that has text "Equal transcripts"
self.assertTrue(self.video.downloaded_transcript_contains_text('txt', 'Equal transcripts'))
# open video "C"
self.course_nav.go_to_sequential('C')
# menu "download_transcript" doesn't exist
self.assertFalse(self.video.is_menu_exist('download_transcript'))
class YouTubeHtml5VideoTest(VideoBaseTest): class YouTubeHtml5VideoTest(VideoBaseTest):
""" Test YouTube HTML5 Video Player """ """ Test YouTube HTML5 Video Player """
...@@ -517,7 +570,7 @@ class Html5VideoTest(VideoBaseTest): ...@@ -517,7 +570,7 @@ class Html5VideoTest(VideoBaseTest):
# check if we can download transcript in "srt" format that has text "好 各位同学" # check if we can download transcript in "srt" format that has text "好 各位同学"
unicode_text = "好 各位同学".decode('utf-8') unicode_text = "好 各位同学".decode('utf-8')
self.video.downloaded_transcript_contains_text('srt', unicode_text) self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text))
def test_download_button_two_transcript_languages(self): def test_download_button_two_transcript_languages(self):
""" """
...@@ -541,10 +594,10 @@ class Html5VideoTest(VideoBaseTest): ...@@ -541,10 +594,10 @@ class Html5VideoTest(VideoBaseTest):
self.assertIn('Hi, welcome to Edx.', self.video.captions_text) self.assertIn('Hi, welcome to Edx.', self.video.captions_text)
# check if we can download transcript in "srt" format that has text "Hi, welcome to Edx." # check if we can download transcript in "srt" format that has text "Hi, welcome to Edx."
self.video.downloaded_transcript_contains_text('srt', 'Hi, welcome to Edx.') self.assertTrue(self.video.downloaded_transcript_contains_text('srt', 'Hi, welcome to Edx.'))
# select language with code "zh" # select language with code "zh"
self.video.select_language('zh') self.assertTrue(self.video.select_language('zh'))
# check if we see "好 各位同学" text in the captions # check if we see "好 各位同学" text in the captions
unicode_text = "好 各位同学".decode('utf-8') unicode_text = "好 各位同学".decode('utf-8')
...@@ -553,7 +606,7 @@ class Html5VideoTest(VideoBaseTest): ...@@ -553,7 +606,7 @@ class Html5VideoTest(VideoBaseTest):
#Then I can download transcript in "srt" format that has text "好 各位同学" #Then I can download transcript in "srt" format that has text "好 各位同学"
unicode_text = "好 各位同学".decode('utf-8') unicode_text = "好 各位同学".decode('utf-8')
self.video.downloaded_transcript_contains_text('srt', unicode_text) self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text))
def test_full_screen_video_alignment_with_transcript_visible(self): def test_full_screen_video_alignment_with_transcript_visible(self):
""" """
......
...@@ -67,28 +67,6 @@ Feature: LMS.Video component ...@@ -67,28 +67,6 @@ Feature: LMS.Video component
And I select language with code "en" And I select language with code "en"
And I see "Hi, welcome to Edx." text in the captions And I see "Hi, welcome to Edx." text in the captions
# 5
Scenario: Download Transcript button works correctly in Video component
Given I am registered for the course "test_course"
And I have a "subs_OEoXaMPEzfM.srt.sjson" transcript file in assets
And it has a video "A" in "Youtube" mode in position "1" of sequential:
| sub | download_track |
| OEoXaMPEzfM | true |
And a video "B" in "Youtube" mode in position "2" of sequential:
| sub | download_track |
| OEoXaMPEzfM | true |
And a video "C" in "Youtube" mode in position "3" of sequential:
| track | download_track |
| http://example.org/ | true |
And I open the section with videos
Then I can download transcript in "srt" format that has text "00:00:00,270"
And I select the transcript format "txt"
Then I can download transcript in "txt" format that has text "Hi, welcome to Edx."
When I open video "B"
Then I can download transcript in "txt" format that has text "Hi, welcome to Edx."
When I open video "C"
Then menu "download_transcript" doesn't exist
# 9 # 9
# Scenario: Youtube video has correct transcript if fields for other speeds are filled # Scenario: Youtube video has correct transcript if fields for other speeds are filled
# Given I am registered for the course "test_course" # Given I am registered for the course "test_course"
......
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