Commit 9d44417c by Ben McMorran Committed by cahrens

Add tests for course outline warning messages

Fix failing bokchoy tests
parent 2118453e
......@@ -14,8 +14,10 @@ if (visibilityState === 'staff_only') {
statusType = 'warning';
if (published && releasedToStudents) {
statusMessage = gettext('Unpublished changes to live content');
} else {
} else if (!published) {
statusMessage = gettext('Unpublished units will not be released');
} else {
statusMessage = gettext('Unpublished changes to content that will release in the future');
}
}
}
......
......@@ -139,14 +139,18 @@ class ContainerPage(PageObject):
confirm_prompt(self)
self.wait_for_ajax()
@property
def is_staff_locked(self):
""" Returns True if staff lock is currently enabled, False otherwise """
return 'icon-check' in self.q(css='a.action-staff-lock>i').attrs('class')
def toggle_staff_lock(self):
"""
Toggles "hide from students" which enables or disables a staff-only lock.
Returns True if the lock is now enabled, else False.
"""
class_attribute_values = self.q(css='a.action-staff-lock>i').attrs('class')
was_locked_initially = 'icon-check' in class_attribute_values
was_locked_initially = self.is_staff_locked
if not was_locked_initially:
self.q(css='a.action-staff-lock').first.click()
else:
......
......@@ -18,6 +18,7 @@ class CourseOutlineItem(object):
NAME_SELECTOR = '.xblock-title .xblock-field-value'
NAME_INPUT_SELECTOR = '.xblock-field-input'
NAME_FIELD_WRAPPER_SELECTOR = '.xblock-title .wrapper-xblock-field'
STATUS_MESSAGE_SELECTOR = '> div[class$="status"] .status-message'
def __repr__(self):
# CourseOutlineItem is also used as a mixin for CourseOutlinePage, which doesn't have a locator
......@@ -29,11 +30,16 @@ class CourseOutlineItem(object):
"""
Returns `selector`, but limited to this particular `CourseOutlineItem` context
"""
return '{}[data-locator="{}"] {}'.format(
self.BODY_SELECTOR,
self.locator,
selector
)
# If the item doesn't have a body selector or locator, then it can't be bounded
# This happens in the context of the CourseOutlinePage
if self.BODY_SELECTOR and hasattr(self, 'locator'):
return '{}[data-locator="{}"] {}'.format(
self.BODY_SELECTOR,
self.locator,
selector
)
else:
return selector
@property
def name(self):
......@@ -46,6 +52,20 @@ class CourseOutlineItem(object):
else:
return None
@property
def has_status_message(self):
"""
Returns True if the item has a status message, False otherwise.
"""
return self.q(css=self._bounded_selector(self.STATUS_MESSAGE_SELECTOR)).first.visible
@property
def status_message(self):
"""
Returns the status message of this item.
"""
return self.q(css=self._bounded_selector(self.STATUS_MESSAGE_SELECTOR)).text[0]
def edit_name(self):
"""
Puts the item's name into editable form.
......@@ -106,7 +126,7 @@ class CourseOutlineContainer(CourseOutlineItem):
"""
if not child_class:
child_class = self.CHILD_CLASS
return self.q(css=child_class.BODY_SELECTOR).map(
return self.q(css=self._bounded_selector(child_class.BODY_SELECTOR)).map(
lambda el: child_class(self.browser, el.get_attribute('data-locator'))).results
def child_at(self, index, child_class=None):
......
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