Commit ca8bfa84 by Anton Stupak

Merge pull request #6941 from edx/anton/fix-flaky-tests

TNL-454: Fix flaky bok-choy tests.
parents dfaae534 4b551b53
...@@ -356,10 +356,6 @@ class VideoPage(PageObject): ...@@ -356,10 +356,6 @@ class VideoPage(PageObject):
self.q(css=button_selector).first.click() self.q(css=button_selector).first.click()
button_states = {'play': 'playing', 'pause': 'pause'}
if button in button_states:
self.wait_for_state(button_states[button])
self.wait_for_ajax() self.wait_for_ajax()
def _get_element_dimensions(self, selector): def _get_element_dimensions(self, selector):
...@@ -677,7 +673,7 @@ class VideoPage(PageObject): ...@@ -677,7 +673,7 @@ class VideoPage(PageObject):
elif 'is-ended' in current_state: elif 'is-ended' in current_state:
return 'finished' return 'finished'
def _wait_for(self, check_func, desc, result=False, timeout=200): def _wait_for(self, check_func, desc, result=False, timeout=200, try_interval=0.2):
""" """
Calls the method provided as an argument until the Promise satisfied or BrokenPromise Calls the method provided as an argument until the Promise satisfied or BrokenPromise
...@@ -689,9 +685,9 @@ class VideoPage(PageObject): ...@@ -689,9 +685,9 @@ class VideoPage(PageObject):
""" """
if result: if result:
return Promise(check_func, desc, timeout=timeout).fulfill() return Promise(check_func, desc, timeout=timeout, try_interval=try_interval).fulfill()
else: else:
return EmptyPromise(check_func, desc, timeout=timeout).fulfill() return EmptyPromise(check_func, desc, timeout=timeout, try_interval=try_interval).fulfill()
def wait_for_state(self, state): def wait_for_state(self, state):
""" """
......
...@@ -181,6 +181,7 @@ class CMSVideoTest(CMSVideoBaseTest): ...@@ -181,6 +181,7 @@ class CMSVideoTest(CMSVideoBaseTest):
self.assertTrue(self.video.is_button_shown('play')) self.assertTrue(self.video.is_button_shown('play'))
self.video.click_player_button('play') self.video.click_player_button('play')
self.video.wait_for_state('playing')
self.assertTrue(self.video.is_button_shown('pause')) self.assertTrue(self.video.is_button_shown('pause'))
def test_youtube_stub_blocks_youtube_api(self): def test_youtube_stub_blocks_youtube_api(self):
......
...@@ -3,7 +3,6 @@ Acceptance tests for Video Times(Start, End and Finish) functionality. ...@@ -3,7 +3,6 @@ Acceptance tests for Video Times(Start, End and Finish) functionality.
""" """
from .test_video_module import VideoBaseTest from .test_video_module import VideoBaseTest
from unittest import skip
class VideoTimesTest(VideoBaseTest): class VideoTimesTest(VideoBaseTest):
...@@ -33,17 +32,16 @@ class VideoTimesTest(VideoBaseTest): ...@@ -33,17 +32,16 @@ class VideoTimesTest(VideoBaseTest):
self.assertGreaterEqual(int(self.video.position.split(':')[1]), 10) self.assertGreaterEqual(int(self.video.position.split(':')[1]), 10)
@skip("Intermittently fails 1 Oct 2014")
def test_video_end_time_with_default_start_time(self): def test_video_end_time_with_default_start_time(self):
""" """
Scenario: End time works for Youtube video if starts playing from beginning. Scenario: End time works for Youtube video if starts playing from beginning.
Given we have a video in "Youtube" mode with end time set to 00:00:02 Given we have a video in "Youtube" mode with end time set to 00:00:05
And I click video button "play" And I click video button "play"
And I wait until video stop playing And I wait until video stop playing
Then I see video slider at "0:02" position Then I see video slider at "0:05" position
""" """
data = {'end_time': '00:00:02'} data = {'end_time': '00:00:05'}
self.metadata = self.metadata_for_mode('youtube', additional_data=data) self.metadata = self.metadata_for_mode('youtube', additional_data=data)
# go to video # go to video
...@@ -54,7 +52,7 @@ class VideoTimesTest(VideoBaseTest): ...@@ -54,7 +52,7 @@ class VideoTimesTest(VideoBaseTest):
# wait until video stop playing # wait until video stop playing
self.video.wait_for_state('pause') self.video.wait_for_state('pause')
self.assertEqual(self.video.position, '0:02') self.assertIn(self.video.position, ('0:05', '0:06'))
def test_video_end_time_wo_default_start_time(self): def test_video_end_time_wo_default_start_time(self):
""" """
...@@ -79,20 +77,19 @@ class VideoTimesTest(VideoBaseTest): ...@@ -79,20 +77,19 @@ class VideoTimesTest(VideoBaseTest):
# wait until video stop playing # wait until video stop playing
self.video.wait_for_state('pause') self.video.wait_for_state('pause')
self.assertEqual(self.video.position, '1:00') self.assertIn(self.video.position, ('1:00', '1:01'))
@skip("Intermittently fails 23 Sept 2014")
def test_video_start_time_and_end_time(self): def test_video_start_time_and_end_time(self):
""" """
Scenario: Start time and end time work together for Youtube video. Scenario: Start time and end time work together for Youtube video.
Given we a video in "Youtube" mode with start time set to 00:00:10 and end_time set to 00:00:12 Given we a video in "Youtube" mode with start time set to 00:00:10 and end_time set to 00:00:15
And I see video slider at "0:10" position And I see video slider at "0:10" position
And I click video button "play" And I click video button "play"
Then I wait until video stop playing Then I wait until video stop playing
Then I see video slider at "0:12" position Then I see video slider at "0:15" position
""" """
data = {'start_time': '00:00:10', 'end_time': '00:00:12'} data = {'start_time': '00:00:10', 'end_time': '00:00:15'}
self.metadata = self.metadata_for_mode('youtube', additional_data=data) self.metadata = self.metadata_for_mode('youtube', additional_data=data)
# go to video # go to video
...@@ -105,13 +102,12 @@ class VideoTimesTest(VideoBaseTest): ...@@ -105,13 +102,12 @@ class VideoTimesTest(VideoBaseTest):
# wait until video stop playing # wait until video stop playing
self.video.wait_for_state('pause') self.video.wait_for_state('pause')
self.assertEqual(self.video.position, '0:12') self.assertIn(self.video.position, ('0:15', '0:16'))
@skip("Intermittently fails 03 June 2014")
def test_video_end_time_and_finish_time(self): def test_video_end_time_and_finish_time(self):
""" """
Scenario: Youtube video works after pausing at end time and then plays again from End Time to the end. Scenario: Youtube video works after pausing at end time and then plays again from End Time to the end.
Given we have a video in "Youtube" mode with start time set to 00:02:14 and end_time set to 00:02:15 Given we have a video in "Youtube" mode with start time set to 00:02:10 and end_time set to 00:02:15
And I click video button "play" And I click video button "play"
And I wait until video stop playing And I wait until video stop playing
Then I see video slider at "2:15" position Then I see video slider at "2:15" position
...@@ -119,7 +115,7 @@ class VideoTimesTest(VideoBaseTest): ...@@ -119,7 +115,7 @@ class VideoTimesTest(VideoBaseTest):
And I wait until video stop playing And I wait until video stop playing
Then I see video slider at "2:20" position Then I see video slider at "2:20" position
""" """
data = {'start_time': '00:02:14', 'end_time': '00:02:15'} data = {'start_time': '00:02:10', 'end_time': '00:02:15'}
self.metadata = self.metadata_for_mode('youtube', additional_data=data) self.metadata = self.metadata_for_mode('youtube', additional_data=data)
# go to video # go to video
...@@ -130,7 +126,7 @@ class VideoTimesTest(VideoBaseTest): ...@@ -130,7 +126,7 @@ class VideoTimesTest(VideoBaseTest):
# wait until video stop playing # wait until video stop playing
self.video.wait_for_state('pause') self.video.wait_for_state('pause')
self.assertEqual(self.video.position, '2:15') self.assertIn(self.video.position, ('2:15', '2:16'))
self.video.click_player_button('play') self.video.click_player_button('play')
...@@ -142,14 +138,14 @@ class VideoTimesTest(VideoBaseTest): ...@@ -142,14 +138,14 @@ class VideoTimesTest(VideoBaseTest):
def test_video_end_time_with_seek(self): def test_video_end_time_with_seek(self):
""" """
Scenario: End Time works for Youtube Video if starts playing before Start Time. Scenario: End Time works for Youtube Video if starts playing before Start Time.
Given we have a video in "Youtube" mode with end-time at 0:32 and start-time at 0:30 Given we have a video in "Youtube" mode with end-time at 0:35 and start-time at 0:30
And I seek video to "0:28" position And I seek video to "0:28" position
And I click video button "play" And I click video button "play"
And I wait until video stop playing And I wait until video stop playing
Then I see video slider at "0:32" position Then I see video slider at "0:35" position
""" """
data = {'start_time': '00:00:30', 'end_time': '00:00:32'} data = {'start_time': '00:00:30', 'end_time': '00:00:35'}
self.metadata = self.metadata_for_mode('youtube', additional_data=data) self.metadata = self.metadata_for_mode('youtube', additional_data=data)
# go to video # go to video
...@@ -162,7 +158,7 @@ class VideoTimesTest(VideoBaseTest): ...@@ -162,7 +158,7 @@ class VideoTimesTest(VideoBaseTest):
# wait until video stop playing # wait until video stop playing
self.video.wait_for_state('pause') self.video.wait_for_state('pause')
self.assertEqual(self.video.position, '0:32') self.assertIn(self.video.position, ('0:35', '0:36'))
def test_video_finish_time_with_seek(self): def test_video_finish_time_with_seek(self):
""" """
......
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