Commit 6752b90d by Albert St. Aubin

Removed flaky annotations and updated tests to correct flakiness

TNL-5774
parent ac2b5bcc
...@@ -3,7 +3,6 @@ Problem Page. ...@@ -3,7 +3,6 @@ Problem Page.
""" """
from bok_choy.page_object import PageObject from bok_choy.page_object import PageObject
from common.test.acceptance.pages.common.utils import click_css 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 from selenium.webdriver.common.keys import Keys
...@@ -219,7 +218,16 @@ class ProblemPage(PageObject): ...@@ -219,7 +218,16 @@ class ProblemPage(PageObject):
""" """
Check for focus problem meta. 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): def is_submit_disabled(self):
""" """
...@@ -316,20 +324,32 @@ class ProblemPage(PageObject): ...@@ -316,20 +324,32 @@ class ProblemPage(PageObject):
'Waiting for the focus to be on the hint notification' '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. 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. # 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). # Multiple tabs may be required depending on the content (for instance, hints with links).
def tab_until_review_focused(): def tab_until_review_focused():
""" Tab until the review button is focused """ """ Tab until the review button is focused """
self.browser.switch_to_active_element().send_keys(Keys.TAB) 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)
self.wait_for(tab_until_review_focused, 'Waiting for the Review button to become focused') return self.q(css=css_string).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): def get_hint_button_disabled_attr(self):
""" Return the disabled attribute of all hint buttons (once hints are visible, there will be two). """ """ Return the disabled attribute of all hint buttons (once hints are visible, there will be two). """
......
...@@ -154,8 +154,8 @@ class ProblemHintTest(ProblemsTest, EventsTestMixin): ...@@ -154,8 +154,8 @@ class ProblemHintTest(ProblemsTest, EventsTestMixin):
self.assertEqual(['true', 'true'], problem_page.get_hint_button_disabled_attr()) 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. # Now click on "Review" and make sure the focus goes to the correct place.
problem_page.click_review_in_notification() problem_page.click_review_in_notification(notification_type='hint')
self.assertTrue(problem_page.is_focus_on_problem_meta()) problem_page.wait_for_focus_on_problem_meta()
# Check corresponding tracking events # Check corresponding tracking events
actual_events = self.wait_for_events( actual_events = self.wait_for_events(
......
...@@ -7,7 +7,6 @@ import random ...@@ -7,7 +7,6 @@ import random
import textwrap import textwrap
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from flaky import flaky
from nose import SkipTest from nose import SkipTest
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from selenium.webdriver import ActionChains from selenium.webdriver import ActionChains
...@@ -166,9 +165,8 @@ class ProblemTypeTestMixin(object): ...@@ -166,9 +165,8 @@ class ProblemTypeTestMixin(object):
self.wait_for_status('correct') self.wait_for_status('correct')
self.problem_page.wait_success_notification() self.problem_page.wait_success_notification()
# Check that clicking on "Review" goes to the problem meta location # Check that clicking on "Review" goes to the problem meta location
self.problem_page.click_review_in_notification() self.problem_page.click_review_in_notification(notification_type='submit')
# TODO: determine why the focus is not being set self.problem_page.wait_for_focus_on_problem_meta()
# self.assertTrue(self.problem_page.is_focus_on_problem_meta())
# Check for corresponding tracking event # Check for corresponding tracking event
expected_events = [ expected_events = [
...@@ -257,7 +255,7 @@ class ProblemTypeTestMixin(object): ...@@ -257,7 +255,7 @@ class ProblemTypeTestMixin(object):
And I should see the problem title is focused And I should see the problem title is focused
""" """
self.problem_page.click_show() 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) @attr(shard=7)
def test_save_reaction(self): def test_save_reaction(self):
...@@ -285,16 +283,14 @@ class ProblemTypeTestMixin(object): ...@@ -285,16 +283,14 @@ class ProblemTypeTestMixin(object):
self.assertTrue(self.problem_page.is_save_button_enabled()) self.assertTrue(self.problem_page.is_save_button_enabled())
self.problem_page.wait_for_save_notification() self.problem_page.wait_for_save_notification()
# Check that clicking on "Review" goes to the problem meta location # Check that clicking on "Review" goes to the problem meta location
self.problem_page.click_review_in_notification() self.problem_page.click_review_in_notification(notification_type='save')
# TODO: determine why the focus is not being set self.problem_page.wait_for_focus_on_problem_meta()
# self.assertTrue(self.problem_page.is_focus_on_problem_meta())
# Not all problems will detect the change and remove the save notification # Not all problems will detect the change and remove the save notification
if self.can_update_save_notification: if self.can_update_save_notification:
self.answer_problem(correctness='incorrect') self.answer_problem(correctness='incorrect')
self.assertFalse(self.problem_page.is_save_notification_visible()) self.assertFalse(self.problem_page.is_save_notification_visible())
@flaky # TNL-5774
@attr(shard=7) @attr(shard=7)
def test_reset_clears_answer_and_focus(self): def test_reset_clears_answer_and_focus(self):
""" """
...@@ -316,7 +312,7 @@ class ProblemTypeTestMixin(object): ...@@ -316,7 +312,7 @@ class ProblemTypeTestMixin(object):
# clear the answers # clear the answers
self.problem_page.click_reset() self.problem_page.click_reset()
# Focus should change to meta # 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 # Answer should be reset
self.wait_for_status('unanswered') self.wait_for_status('unanswered')
...@@ -493,7 +489,7 @@ class CheckboxProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin): ...@@ -493,7 +489,7 @@ class CheckboxProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
self.problem_page.click_show() self.problem_page.click_show()
self.assertTrue(self.problem_page.is_solution_tag_present()) 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_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): class MultipleChoiceProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
...@@ -706,8 +702,8 @@ class NumericalProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin): ...@@ -706,8 +702,8 @@ class NumericalProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
self.problem_page.click_submit() self.problem_page.click_submit()
self.problem_page.wait_for_gentle_alert_notification() self.problem_page.wait_for_gentle_alert_notification()
# Check that clicking on "Review" goes to the problem meta location # Check that clicking on "Review" goes to the problem meta location
self.problem_page.click_review_in_notification() self.problem_page.click_review_in_notification(notification_type='gentle-alert')
self.assertTrue(self.problem_page.is_focus_on_problem_meta()) self.problem_page.wait_for_focus_on_problem_meta()
class FormulaProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin): class FormulaProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
......
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