Commit c7713064 by Carson Gee

Reworked UI for clarity, removed reload, and added Bok-Choy tests

parent a660cd85
......@@ -31,6 +31,13 @@ class StaffPage(PageObject):
staff_debug_page.wait_for_page()
return staff_debug_page
def answer_problem(self):
"""
Answers the problem to give state that we can clean
"""
self.q(css='input.check').first.click()
self.wait_for_ajax()
class StaffDebugPage(PageObject):
"""
......@@ -43,6 +50,9 @@ class StaffDebugPage(PageObject):
return self.q(css='section.staff-modal').present
def _click_link(self, link_text):
"""
Clicks on an action link based on text
"""
for link in self.q(css='section.staff-modal a').execute():
if link.text == link_text:
return link.click()
......@@ -50,8 +60,22 @@ class StaffDebugPage(PageObject):
raise Exception('Could not find the {} link to click on.'.format(
link_text))
def reset_attempts(self):
self._click_link('Reset Attempts')
def reset_attempts(self, user=None):
"""
This clicks on the reset attempts link with an optionally
specified user.
"""
if user:
self.q(css='input[id^=sd_fu_]').first.fill(user)
self._click_link('Reset Student Attempts')
def delete_state(self, user=None):
"""
This delete's a student's state for the problem
"""
if user:
self.q(css='input[id^=sd_fu_]').fill(user)
self._click_link('Delete Student State')
@property
def idash_msg(self):
......
......@@ -15,6 +15,7 @@ class StaffDebugTest(UniqueCourseTest):
"""
Tests that verify the staff debug info.
"""
USERNAME = "STAFF_TESTER"
def setUp(self):
super(StaffDebugTest, self).setUp()
......@@ -48,14 +49,62 @@ class StaffDebugTest(UniqueCourseTest):
# Auto-auth register for the course.
# Do this as global staff so that you will see the Staff View
AutoAuthPage(self.browser, course_id=self.course_id, staff=True).visit()
AutoAuthPage(self.browser, username=self.USERNAME,
course_id=self.course_id, staff=True).visit()
def test_staff_debug(self):
def _goto_staff_page(self):
"""
Open staff page with assertion
"""
self.courseware_page.visit()
staff_page = StaffPage(self.browser)
self.assertEqual(staff_page.staff_status, 'Staff view')
return staff_page
def test_reset_attempts_empty(self):
"""
Test that we fail properly when there is no student state
"""
staff_debug_page = self._goto_staff_page().open_staff_debug_info()
staff_debug_page.reset_attempts()
msg = staff_debug_page.idash_msg[0]
self.assertIn((u"Found a single student. Found module. Couldn't "
"reset module state for {0}/").format(self.USERNAME),
msg)
def test_delete_state_empty(self):
"""
Test that we delete properly even when there isn't state to delete.
"""
staff_debug_page = self._goto_staff_page().open_staff_debug_info()
staff_debug_page.delete_state()
msg = staff_debug_page.idash_msg[0]
self.assertIn((u"Found a single student. Found module. "
"Deleted student module state for"), msg)
def test_reset_attempts_state(self):
"""
Successfully reset the student attempts
"""
staff_page = self._goto_staff_page()
staff_page.answer_problem()
staff_debug_page = staff_page.open_staff_debug_info()
staff_debug_page.reset_attempts()
msg = staff_debug_page.idash_msg[0]
self.assertIn((u"Found a single student. Found module. Module "
"state successfully reset!"), msg)
msg = staff_debug_page.idash_msg
self.assertEqual('foo', msg) # Not sure what is supposed to happen
def test_student_state_state(self):
"""
Successfully delete the student state with an answer
"""
staff_page = self._goto_staff_page()
staff_page.answer_problem()
staff_debug_page = staff_page.open_staff_debug_info()
staff_debug_page.delete_state()
msg = staff_debug_page.idash_msg[0]
self.assertIn((u"Found a single student. Found module. "
"Deleted student module state for"), msg)
......@@ -82,7 +82,10 @@ var StaffDebug = (function(){
data: pdata,
success: function(data){
var msg = $("#idash_msg", data);
$( "#result_"+locname ).html( msg );
$("#result_" + locname).html( msg );
},
error: function(request, status, error) {
$("#result_" + locname).html('<p id="idash_msg"><font color="red">${_('Something has gone wrong with this request. The server replied with a status of: ')}' + error + '</font></p>')
},
dataType: 'html'
});
......@@ -96,25 +99,24 @@ var StaffDebug = (function(){
do_idash_action(locname, "Delete student state for module");
}
reload = function(locname){
var url = geturl('jump_to_id/' + locname);
window.location.replace(url);
}
return {reset: reset,
reload: reload,
sdelete: sdelete,
do_idash_action: do_idash_action
}
})();
</script>
[ <a href='javascript:StaffDebug.reset("${location.name}")'>${_('Reset Attempts')}</a> |
<a href='javascript:StaffDebug.reload("${location.name}")'>${_('Reload Page')}</a> |
<a href='javascript:StaffDebug.sdelete("${location.name}")'>${_('Delete State')}</a>
<hr />
<h3>Actions</h3>
<div>
<label for="sd_fu_${location.name}">For User:</label>
<input type="text" id="sd_fu_${location.name}" placeholder="${user.username}"/>
</div>
<div>
[ <a href='javascript:StaffDebug.reset("${location.name}")'>${_('Reset Student Attempts')}</a> |
<a href='javascript:StaffDebug.sdelete("${location.name}")'>${_('Delete Student State')}</a>
]
<span style="float:right">For user:<input type="text" id="sd_fu_${location.name}" /></span>
<div id="result_${location.name}"/>
</div>
<div id="result_${location.name}"/>
<div class="staff_info" style="display:block">
is_released = ${is_released}
......
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