Beginning of Selenium test, updates to work with master.

This commit is contained in:
cahrens
2013-03-18 21:25:44 -04:00
parent 49ee903eda
commit dc89a4b3d5
6 changed files with 65 additions and 12 deletions

View File

@@ -0,0 +1,13 @@
Feature: Course checklists
Scenario: A course author sees checklists defined by edX
Given I have opened a new course in Studio
When I select Checklists from the Tools menu
Then I see the four default edX checklists
Scenario: A course author can mark tasks as complete
Given I have opened a new course in Studio
When I select Checklists from the Tools menu
Then I can select tasks in a checklist
And They are still selected after I reload the page

View File

@@ -0,0 +1,35 @@
from lettuce import world, step
from common import *
from terrain.steps import reload_the_page
############### ACTIONS ####################
@step('I select Checklists from the Tools menu$')
def i_select_checklists(step):
expand_icon_css = 'li.nav-course-tools i.icon-expand'
if world.browser.is_element_present_by_css(expand_icon_css):
css_click(expand_icon_css)
link_css = 'li.nav-course-tools-checklists a'
css_click(link_css)
@step('I see the four default edX checklists$')
def i_see_default_checklists(step):
checklists = css_find('.checklist-title')
assert_equal(4, len(checklists))
assert_true(checklists[0].text.endswith('Getting Started With Studio'))
assert_true(checklists[1].text.endswith('Draft a Rough Course Outline'))
assert_true(checklists[2].text.endswith("Explore edX\'s Support Tools"))
assert_true(checklists[3].text.endswith('Draft your Course Introduction'))
@step('I can select tasks in a checklist$')
def i_can_select_tasks(step):
# Use the 2nd checklist as a reference
assert_equal('0', css_find('#course-checklist1 .status-count').first.text)
assert_equal('7', css_find('#course-checklist1 .status-amount').first.text)
# TODO: check progress bar, select several items and check how things change
@step('They are still selected after I reload the page$')
def tasks_still_selected_after_reload(step):
reload_the_page(step)

View File

@@ -1299,12 +1299,11 @@ def get_checklists(request, org, course, name):
template_module = modulestore.get_item(new_course_template)
# If course was created before checklists were introduced, copy them over from the template.
key = "checklists"
if not key in course_module.metadata:
course_module.metadata[key] = template_module.metadata[key]
modulestore.update_metadata(location, course_module.metadata)
if not course_module.checklists:
course_module.checklists = template_module.checklists
modulestore.update_metadata(location, own_metadata(course_module))
checklists = course_module.metadata[key]
checklists = course_module.checklists
return render_to_response('checklists.html',
{
'context_course': course_module,
@@ -1318,17 +1317,16 @@ def update_checklist(request, org, course, name, checklist_index=None):
location = get_location_and_verify_access(request, org, course, name)
modulestore = get_modulestore(location)
course_module = modulestore.get_item(location)
key = "checklists"
real_method = get_request_method(request)
if checklist_index is not None and (real_method == 'POST' or real_method == 'PUT'):
modified_checklist = json.loads(request.body)
(course_module.metadata[key])[int(checklist_index)] = modified_checklist
modulestore.update_metadata(location, course_module.metadata)
course_module.checklists[int(checklist_index)] = modified_checklist
modulestore.update_metadata(location, own_metadata(course_module))
return HttpResponse(json.dumps(modified_checklist), mimetype="application/json")
elif request.method == 'GET':
# TODO: Would we ever get in this condition? Any point in having this code?
return HttpResponse(json.dumps(course_module.metadata[key]), mimetype="application/json")
return HttpResponse(json.dumps(course_module.checklists), mimetype="application/json")
@login_required

View File

@@ -10,7 +10,7 @@ class CourseMetadata(object):
For CRUD operations on metadata fields which do not have specific editors on the other pages including any user generated ones.
The objects have no predefined attrs but instead are obj encodings of the editable metadata.
'''
FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod']
FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod', 'checklists']
@classmethod
def fetch(cls, course_location):

View File

@@ -1,4 +1,11 @@
<section class="course-checklist" id="<%= 'course-checklist' + checklistIndex %>">
<% var allChecked = itemsChecked == items.length; %>
<section
<% if (allChecked) { %>
class="course-checklist is-completed"
<% } else { %>
class="course-checklist"
<% } %>
id="<%= 'course-checklist' + checklistIndex %>">
<% var widthPercentage = 'width:' + percentChecked + '%;'; %>
<span class="viz viz-checklist-status"><span class="viz value viz-checklist-status-value" style="<%= widthPercentage %>">
<span class="int"><%= percentChecked %></span>% of checklist completed</span></span>

View File

@@ -179,7 +179,7 @@ class CourseFields(object):
allow_anonymous_to_peers = Boolean(scope=Scope.settings, default=False)
advanced_modules = List(help="Beta modules used in your course", scope=Scope.settings)
has_children = True
checklists=List(scope=Scope.settings)
info_sidebar_name = String(scope=Scope.settings, default='Course Handouts')
# An extra property is used rather than the wiki_slug/number because