Merge pull request #14042 from edx/aj/TNL-5774-flaky-test
Aj/tnl 5774 flaky test
This commit is contained in:
@@ -3,7 +3,6 @@ Problem Page.
|
||||
"""
|
||||
from bok_choy.page_object import PageObject
|
||||
from common.test.acceptance.pages.common.utils import click_css
|
||||
from common.test.acceptance.tests.helpers import is_focused_on_element
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
|
||||
@@ -219,7 +218,16 @@ class ProblemPage(PageObject):
|
||||
"""
|
||||
Check for focus problem meta.
|
||||
"""
|
||||
return is_focused_on_element(self.browser, '.problem-header')
|
||||
return self.q(css='.problem-header').focused
|
||||
|
||||
def wait_for_focus_on_problem_meta(self):
|
||||
"""
|
||||
Waits for focus on Problem Meta section
|
||||
"""
|
||||
self.wait_for(
|
||||
promise_check_func=self.is_focus_on_problem_meta,
|
||||
description='Waiting for focus on Problem Meta section'
|
||||
)
|
||||
|
||||
def is_submit_disabled(self):
|
||||
"""
|
||||
@@ -316,20 +324,32 @@ class ProblemPage(PageObject):
|
||||
'Waiting for the focus to be on the hint notification'
|
||||
)
|
||||
|
||||
def click_review_in_notification(self):
|
||||
def click_review_in_notification(self, notification_type):
|
||||
"""
|
||||
Click on the "Review" button within the visible notification.
|
||||
"""
|
||||
css_string = '.notification.notification-{notification_type} .review-btn'.format(
|
||||
notification_type=notification_type
|
||||
)
|
||||
|
||||
# The review button cannot be clicked on until it is tabbed to, so first tab to it.
|
||||
# Multiple tabs may be required depending on the content (for instance, hints with links).
|
||||
def tab_until_review_focused():
|
||||
""" Tab until the review button is focused """
|
||||
self.browser.switch_to_active_element().send_keys(Keys.TAB)
|
||||
return self.q(css='.notification .review-btn').focused
|
||||
if self.q(css=css_string).focused:
|
||||
self.scroll_to_element(css_string)
|
||||
return self.q(css=css_string).focused
|
||||
|
||||
self.wait_for(tab_until_review_focused, 'Waiting for the Review button to become focused')
|
||||
|
||||
click_css(self, '.notification .review-btn', require_notification=False)
|
||||
self.wait_for(
|
||||
tab_until_review_focused,
|
||||
'Waiting for the Review button to become focused'
|
||||
)
|
||||
self.wait_for_element_visibility(
|
||||
css_string,
|
||||
'Waiting for the button to be visible'
|
||||
)
|
||||
click_css(self, css_string, require_notification=False)
|
||||
|
||||
def get_hint_button_disabled_attr(self):
|
||||
""" Return the disabled attribute of all hint buttons (once hints are visible, there will be two). """
|
||||
|
||||
@@ -154,8 +154,8 @@ class ProblemHintTest(ProblemsTest, EventsTestMixin):
|
||||
self.assertEqual(['true', 'true'], problem_page.get_hint_button_disabled_attr())
|
||||
|
||||
# Now click on "Review" and make sure the focus goes to the correct place.
|
||||
problem_page.click_review_in_notification()
|
||||
self.assertTrue(problem_page.is_focus_on_problem_meta())
|
||||
problem_page.click_review_in_notification(notification_type='hint')
|
||||
problem_page.wait_for_focus_on_problem_meta()
|
||||
|
||||
# Check corresponding tracking events
|
||||
actual_events = self.wait_for_events(
|
||||
|
||||
@@ -7,7 +7,6 @@ import random
|
||||
import textwrap
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from flaky import flaky
|
||||
from nose import SkipTest
|
||||
from nose.plugins.attrib import attr
|
||||
from selenium.webdriver import ActionChains
|
||||
@@ -166,9 +165,8 @@ class ProblemTypeTestMixin(object):
|
||||
self.wait_for_status('correct')
|
||||
self.problem_page.wait_success_notification()
|
||||
# Check that clicking on "Review" goes to the problem meta location
|
||||
self.problem_page.click_review_in_notification()
|
||||
# TODO: determine why the focus is not being set
|
||||
# self.assertTrue(self.problem_page.is_focus_on_problem_meta())
|
||||
self.problem_page.click_review_in_notification(notification_type='submit')
|
||||
self.problem_page.wait_for_focus_on_problem_meta()
|
||||
|
||||
# Check for corresponding tracking event
|
||||
expected_events = [
|
||||
@@ -257,7 +255,7 @@ class ProblemTypeTestMixin(object):
|
||||
And I should see the problem title is focused
|
||||
"""
|
||||
self.problem_page.click_show()
|
||||
self.assertTrue(self.problem_page.is_focus_on_problem_meta())
|
||||
self.problem_page.wait_for_focus_on_problem_meta()
|
||||
|
||||
@attr(shard=7)
|
||||
def test_save_reaction(self):
|
||||
@@ -285,16 +283,14 @@ class ProblemTypeTestMixin(object):
|
||||
self.assertTrue(self.problem_page.is_save_button_enabled())
|
||||
self.problem_page.wait_for_save_notification()
|
||||
# Check that clicking on "Review" goes to the problem meta location
|
||||
self.problem_page.click_review_in_notification()
|
||||
# TODO: determine why the focus is not being set
|
||||
# self.assertTrue(self.problem_page.is_focus_on_problem_meta())
|
||||
self.problem_page.click_review_in_notification(notification_type='save')
|
||||
self.problem_page.wait_for_focus_on_problem_meta()
|
||||
|
||||
# Not all problems will detect the change and remove the save notification
|
||||
if self.can_update_save_notification:
|
||||
self.answer_problem(correctness='incorrect')
|
||||
self.assertFalse(self.problem_page.is_save_notification_visible())
|
||||
|
||||
@flaky # TNL-5774
|
||||
@attr(shard=7)
|
||||
def test_reset_clears_answer_and_focus(self):
|
||||
"""
|
||||
@@ -316,7 +312,7 @@ class ProblemTypeTestMixin(object):
|
||||
# clear the answers
|
||||
self.problem_page.click_reset()
|
||||
# Focus should change to meta
|
||||
self.assertTrue(self.problem_page.is_focus_on_problem_meta())
|
||||
self.problem_page.wait_for_focus_on_problem_meta()
|
||||
# Answer should be reset
|
||||
self.wait_for_status('unanswered')
|
||||
|
||||
@@ -493,7 +489,7 @@ class CheckboxProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
self.problem_page.click_show()
|
||||
self.assertTrue(self.problem_page.is_solution_tag_present())
|
||||
self.assertTrue(self.problem_page.is_correct_choice_highlighted(correct_choices=[1, 3]))
|
||||
self.assertTrue(self.problem_page.is_focus_on_problem_meta())
|
||||
self.problem_page.wait_for_focus_on_problem_meta()
|
||||
|
||||
|
||||
class MultipleChoiceProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
@@ -706,8 +702,8 @@ class NumericalProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
self.problem_page.click_submit()
|
||||
self.problem_page.wait_for_gentle_alert_notification()
|
||||
# Check that clicking on "Review" goes to the problem meta location
|
||||
self.problem_page.click_review_in_notification()
|
||||
self.assertTrue(self.problem_page.is_focus_on_problem_meta())
|
||||
self.problem_page.click_review_in_notification(notification_type='gentle-alert')
|
||||
self.problem_page.wait_for_focus_on_problem_meta()
|
||||
|
||||
|
||||
class FormulaProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
|
||||
Reference in New Issue
Block a user