Commit e5f00e62 by Matt Drayer

Bok Choy test now passes

parent dce62ed6
......@@ -17,25 +17,45 @@ class SettingsPage(CoursePage):
def is_browser_on_page(self):
return self.q(css='body.view-settings').present
def get_elements(self, css_selector):
self.wait_for_element_presence(
css_selector,
'Elements matching "{}" selector are present'.format(css_selector)
)
results = self.q(css=css_selector)
return results
def get_element(self, css_selector):
results = self.get_elements(css_selector=css_selector)
return results[0] if results else None
@property
def pre_requisite_course(self):
def pre_requisite_course_options(self):
"""
Returns the pre-requisite course drop down field.
Returns the pre-requisite course drop down field options.
"""
return self.q(css='#pre-requisite-course')
return self.get_elements('#pre-requisite-course')
@property
def entrance_exam_field(self):
"""
Returns the enable entrance exam checkbox.
"""
return self.q(css='#entrance-exam-enabled').execute()
return self.get_element('#entrance-exam-enabled')
@property
def alert_confirmation_title(self):
"""
Returns the alert confirmation element, which contains text
such as 'Your changes have been saved.'
"""
return self.get_element('#alert-confirmation-title')
def require_entrance_exam(self, required=True):
"""
Set the entrance exam requirement via the checkbox.
"""
checkbox = self.entrance_exam_field[0]
checkbox = self.entrance_exam_field
selected = checkbox.is_selected()
if required and not selected:
checkbox.click()
......@@ -47,7 +67,7 @@ class SettingsPage(CoursePage):
checkbox.click()
self.wait_for_element_invisibility(
'#entrance-exam-minimum-score-pct',
'Entrance exam minimum score percent is visible'
'Entrance exam minimum score percent is invisible'
)
def save_changes(self, wait_for_confirmation=True):
......@@ -58,11 +78,16 @@ class SettingsPage(CoursePage):
if wait_for_confirmation:
EmptyPromise(
lambda: self.q(css='#alert-confirmation-title').present,
'Waiting for save confirmation...'
'Save is confirmed'
).fulfill()
def refresh_page(self):
def refresh_page(self, wait_for_confirmation=True):
"""
Reload the page.
"""
self.browser.refresh()
if wait_for_confirmation:
EmptyPromise(
lambda: self.q(css='body.view-settings').present,
'Page is refreshed'
).fulfill()
......@@ -819,7 +819,7 @@ class PreRequisiteCourseTest(UniqueCourseTest):
"""
set pre-requisite course
"""
select_option_by_value(self.settings_page.pre_requisite_course, self.pre_requisite_course_id)
select_option_by_value(self.settings_page.pre_requisite_course_options, self.pre_requisite_course_id)
self.settings_page.save_changes()
......@@ -954,7 +954,7 @@ class EntranceExamTest(UniqueCourseTest):
self.settings_page.visit()
self.settings_page.wait_for_page()
self.assertTrue(self.settings_page.is_browser_on_page())
self.settings_page.entrance_exam_field[0].click()
self.settings_page.entrance_exam_field.click()
self.settings_page.save_changes()
# Logout and login as a student.
......
......@@ -38,9 +38,8 @@ class SettingsMilestonesTest(StudioCourseTest):
Test to make sure page has pre-requisite course field if milestones app is enabled.
"""
self.assertTrue(self.settings_detail.pre_requisite_course.present)
self.assertTrue(self.settings_detail.pre_requisite_course_options)
@skip("Flaky: 01/16/2015")
def test_prerequisite_course_save_successfully(self):
"""
Scenario: Selecting course from Pre-Requisite course drop down save the selected course as pre-requisite
......@@ -65,28 +64,63 @@ class SettingsMilestonesTest(StudioCourseTest):
)
pre_requisite_course_id = unicode(pre_requisite_course_key)
# refreshing the page after creating a course fixture, in order reload the pre requisite course drop down.
# Refresh the page to load the new course fixture and populate the prrequisite course dropdown
# Then select the prerequisite course and save the changes
self.settings_detail.refresh_page()
select_option_by_value(
browser_query=self.settings_detail.pre_requisite_course,
browser_query=self.settings_detail.pre_requisite_course_options,
value=pre_requisite_course_id
)
# trigger the save changes button.
self.settings_detail.save_changes()
self.assertEqual(
'Your changes have been saved.',
self.settings_detail.alert_confirmation_title.text
)
self.assertTrue('Your changes have been saved.' in self.settings_detail.browser.page_source)
# Refresh the page again to confirm the prerequisite course selection is properly reflected
self.settings_detail.refresh_page()
self.assertTrue(is_option_value_selected(browser_query=self.settings_detail.pre_requisite_course,
value=pre_requisite_course_id))
self.assertTrue(is_option_value_selected(
browser_query=self.settings_detail.pre_requisite_course_options,
value=pre_requisite_course_id
))
# Set the prerequisite course back to None and save the changes
select_option_by_value(
browser_query=self.settings_detail.pre_requisite_course_options,
value=''
)
self.settings_detail.save_changes()
self.assertEqual(
'Your changes have been saved.',
self.settings_detail.alert_confirmation_title.text
)
# now reset/update the pre requisite course to none
select_option_by_value(browser_query=self.settings_detail.pre_requisite_course, value='')
# Refresh the page again to confirm the None selection is properly reflected
self.settings_detail.refresh_page()
self.assertTrue(is_option_value_selected(
browser_query=self.settings_detail.pre_requisite_course_options,
value=''
))
# trigger the save changes button.
# Re-pick the prerequisite course and confirm no errors are thrown (covers a discovered bug)
select_option_by_value(
browser_query=self.settings_detail.pre_requisite_course_options,
value=pre_requisite_course_id
)
self.settings_detail.save_changes()
self.assertTrue('Your changes have been saved.' in self.settings_detail.browser.page_source)
self.assertTrue(is_option_value_selected(browser_query=self.settings_detail.pre_requisite_course, value=''))
self.assertEqual(
'Your changes have been saved.',
self.settings_detail.alert_confirmation_title.text
)
# Refresh the page again to confirm the prerequisite course selection is properly reflected
self.settings_detail.refresh_page()
dropdown_status = is_option_value_selected(
browser_query=self.settings_detail.pre_requisite_course_options,
value=pre_requisite_course_id
)
self.assertTrue(dropdown_status)
def test_page_has_enable_entrance_exam_field(self):
"""
......
......@@ -34,5 +34,5 @@ git+https://github.com/mitocw/django-cas.git@60a5b8e5a62e63e0d5d224a87f0b489201a
-e git+https://github.com/edx/i18n-tools.git@56f048af9b6868613c14aeae760548834c495011#egg=i18n-tools
-e git+https://github.com/edx/edx-oauth2-provider.git@0.4.0#egg=oauth2-provider
-e git+https://github.com/edx/edx-val.git@ba00a5f2e0571e9a3f37d293a98efe4cbca850d5#egg=edx-val
-e git+https://github.com/edx/edx-milestones.git@4dfe78a2aae9559ccc979746d13a9b67f0ec311e#egg=edx-milestones
-e git+https://github.com/pmitros/RecommenderXBlock.git@9b07e807c89ba5761827d0387177f71aa57ef056#egg=recommender-xblock
-e git+https://github.com/edx/edx-milestones.git@547f2250ee49e73ce8d7ff4e78ecf1b049892510#egg=edx-milestones
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