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): ...@@ -31,6 +31,13 @@ class StaffPage(PageObject):
staff_debug_page.wait_for_page() staff_debug_page.wait_for_page()
return staff_debug_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): class StaffDebugPage(PageObject):
""" """
...@@ -43,6 +50,9 @@ class StaffDebugPage(PageObject): ...@@ -43,6 +50,9 @@ class StaffDebugPage(PageObject):
return self.q(css='section.staff-modal').present return self.q(css='section.staff-modal').present
def _click_link(self, link_text): 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(): for link in self.q(css='section.staff-modal a').execute():
if link.text == link_text: if link.text == link_text:
return link.click() return link.click()
...@@ -50,8 +60,22 @@ class StaffDebugPage(PageObject): ...@@ -50,8 +60,22 @@ class StaffDebugPage(PageObject):
raise Exception('Could not find the {} link to click on.'.format( raise Exception('Could not find the {} link to click on.'.format(
link_text)) link_text))
def reset_attempts(self): def reset_attempts(self, user=None):
self._click_link('Reset Attempts') """
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 @property
def idash_msg(self): def idash_msg(self):
......
...@@ -15,6 +15,7 @@ class StaffDebugTest(UniqueCourseTest): ...@@ -15,6 +15,7 @@ class StaffDebugTest(UniqueCourseTest):
""" """
Tests that verify the staff debug info. Tests that verify the staff debug info.
""" """
USERNAME = "STAFF_TESTER"
def setUp(self): def setUp(self):
super(StaffDebugTest, self).setUp() super(StaffDebugTest, self).setUp()
...@@ -48,14 +49,62 @@ class StaffDebugTest(UniqueCourseTest): ...@@ -48,14 +49,62 @@ class StaffDebugTest(UniqueCourseTest):
# Auto-auth register for the course. # Auto-auth register for the course.
# Do this as global staff so that you will see the Staff View # 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() self.courseware_page.visit()
staff_page = StaffPage(self.browser) staff_page = StaffPage(self.browser)
self.assertEqual(staff_page.staff_status, 'Staff view') 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 = staff_page.open_staff_debug_info()
staff_debug_page.reset_attempts() 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 def test_student_state_state(self):
self.assertEqual('foo', msg) # Not sure what is supposed to happen """
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(){ ...@@ -82,7 +82,10 @@ var StaffDebug = (function(){
data: pdata, data: pdata,
success: function(data){ success: function(data){
var msg = $("#idash_msg", 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' dataType: 'html'
}); });
...@@ -96,25 +99,24 @@ var StaffDebug = (function(){ ...@@ -96,25 +99,24 @@ var StaffDebug = (function(){
do_idash_action(locname, "Delete student state for module"); 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, return {reset: reset,
reload: reload,
sdelete: sdelete, sdelete: sdelete,
do_idash_action: do_idash_action do_idash_action: do_idash_action
} }
})(); })();
</script> </script>
<hr />
[ <a href='javascript:StaffDebug.reset("${location.name}")'>${_('Reset Attempts')}</a> | <h3>Actions</h3>
<a href='javascript:StaffDebug.reload("${location.name}")'>${_('Reload Page')}</a> | <div>
<a href='javascript:StaffDebug.sdelete("${location.name}")'>${_('Delete State')}</a> <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>
<div id="result_${location.name}"/> <div id="result_${location.name}"/>
<div class="staff_info" style="display:block"> <div class="staff_info" style="display:block">
is_released = ${is_released} 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