Commit 1ae9e9bd by cahrens

Tests for opening action links.

parent 8ca6e324
...@@ -6,7 +6,16 @@ Feature: Course checklists ...@@ -6,7 +6,16 @@ Feature: Course checklists
Then I see the four default edX checklists Then I see the four default edX checklists
Scenario: A course author can mark tasks as complete Scenario: A course author can mark tasks as complete
Given I have opened a new course in Studio Given I have opened Checklists
When I select Checklists from the Tools menu
Then I can check and uncheck tasks in a checklist Then I can check and uncheck tasks in a checklist
And They are correctly selected after I reload the page And They are correctly selected after I reload the page
\ No newline at end of file
Scenario: A task can link to a location within Studio
Given I have opened Checklists
When I select a link to the course outline
Then I am brought to the course outline page
Scenario: A task can link to a location outside Studio
Given I have opened Checklists
When I select a link to help page
Then I am brought to the help page in a new window
\ No newline at end of file
...@@ -12,6 +12,12 @@ def i_select_checklists(step): ...@@ -12,6 +12,12 @@ def i_select_checklists(step):
css_click(link_css) css_click(link_css)
@step('I have opened Checklists$')
def i_have_opened_checklists(step):
step.given('I have opened a new course in Studio')
step.given('I select Checklists from the Tools menu')
@step('I see the four default edX checklists$') @step('I see the four default edX checklists$')
def i_see_default_checklists(step): def i_see_default_checklists(step):
checklists = css_find('.checklist-title') checklists = css_find('.checklist-title')
...@@ -45,6 +51,31 @@ def tasks_correctly_selected_after_reload(step): ...@@ -45,6 +51,31 @@ def tasks_correctly_selected_after_reload(step):
verifyChecklist2Status(1, 7, 14) verifyChecklist2Status(1, 7, 14)
@step('I select a link to the course outline$')
def i_select_a_link_to_the_course_outline(step):
clickActionLink(1, 0, 'Edit Course Outline')
@step('I am brought to the course outline page$')
def i_am_brought_to_course_outline(step):
assert_equal('Course Outline', css_find('.outline .title-1')[0].text)
assert_equal(1, len(world.browser.windows))
@step('I select a link to help page$')
def i_select_a_link_to_the_help_page(step):
clickActionLink(2, 0, 'Visit Studio Help')
@step('I am brought to the help page in a new window$')
def i_am_brought_to_help_page_in_new_window(step):
step.given('I see the four default edX checklists')
windows = world.browser.windows
assert_equal(2, len(windows))
world.browser.switch_to_window(windows[1])
assert_equal('http://help.edge.edx.org/', world.browser.url)
############### HELPER METHODS #################### ############### HELPER METHODS ####################
def verifyChecklist2Status(completed, total, percentage): def verifyChecklist2Status(completed, total, percentage):
def verify_count(driver): def verify_count(driver):
...@@ -61,4 +92,18 @@ def verifyChecklist2Status(completed, total, percentage): ...@@ -61,4 +92,18 @@ def verifyChecklist2Status(completed, total, percentage):
def toggleTask(checklist, task): def toggleTask(checklist, task):
css_click('#course-checklist' + str(checklist) +'-task' + str(task)) css_click('#course-checklist' + str(checklist) +'-task' + str(task))
\ No newline at end of file
def clickActionLink(checklist, task, actionText):
# toggle checklist item to make sure that the link button is showing
toggleTask(checklist, task)
action_link = css_find('#course-checklist' + str(checklist) + ' a')[task]
# text will be empty initially, wait for it to populate
def verify_action_link_text(driver):
return action_link.text == actionText
wait_for(verify_action_link_text)
action_link.click()
from contentstore import utils from contentstore import utils
import mock import mock
from django.test import TestCase from django.test import TestCase
from xmodule.modulestore.tests.factories import CourseFactory
from .utils import ModuleStoreTestCase
class LMSLinksTestCase(TestCase): class LMSLinksTestCase(TestCase):
...@@ -17,3 +19,28 @@ class LMSLinksTestCase(TestCase): ...@@ -17,3 +19,28 @@ class LMSLinksTestCase(TestCase):
self.assertEquals(link, "//localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us") self.assertEquals(link, "//localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us")
link = utils.get_lms_link_for_item(location, True) link = utils.get_lms_link_for_item(location, True)
self.assertEquals(link, "//preview.localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us") self.assertEquals(link, "//preview.localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us")
class UrlReverseTestCase(ModuleStoreTestCase):
def test_CoursePageNames(self):
course = CourseFactory.create(org='mitX', number='666', display_name='URL Reverse Course')
self.assertEquals('/manage_users/i4x://mitX/666/course/URL_Reverse_Course',
utils.get_url_reverse('ManageUsers', course))
self.assertEquals('/mitX/666/settings-details/URL_Reverse_Course',
utils.get_url_reverse('SettingsDetails', course))
self.assertEquals('/mitX/666/settings-grading/URL_Reverse_Course',
utils.get_url_reverse('SettingsGrading', course))
self.assertEquals('/mitX/666/course/URL_Reverse_Course',
utils.get_url_reverse('CourseOutline', course))
def test_unknown_passes_through(self):
course = CourseFactory.create(org='mitX', number='666', display_name='URL Reverse Course')
self.assertEquals('foobar',
utils.get_url_reverse('foobar', course))
self.assertEquals('https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about',
utils.get_url_reverse('https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about', course))
...@@ -161,10 +161,19 @@ def update_item(location, value): ...@@ -161,10 +161,19 @@ def update_item(location, value):
get_modulestore(location).update_item(location, value) get_modulestore(location).update_item(location, value)
def get_url_reverse(course_page_name, course): def get_url_reverse(course_page_name, course_module):
# TODO: document and write unit tests """
Returns the course URL link to the specified location. This value is suitable to use as an href link.
course_page_name should correspond to an attribute in CoursePageNames (for example, 'ManageUsers'
or 'SettingsDetails'), or else it will simply be returned. This method passes back unknown values of
course_page_names so that it can also be used for absolute (known) URLs.
course_module is used to obtain the location, org, course, and name properties for a course, if
course_page_name corresponds to an attribute in CoursePageNames.
"""
url_name = getattr(CoursePageNames, course_page_name, None) url_name = getattr(CoursePageNames, course_page_name, None)
ctx_loc = course.location ctx_loc = course_module.location
if CoursePageNames.ManageUsers == url_name: if CoursePageNames.ManageUsers == url_name:
return reverse(url_name, kwargs={"location": ctx_loc}) return reverse(url_name, kwargs={"location": ctx_loc})
......
...@@ -45,8 +45,11 @@ ...@@ -45,8 +45,11 @@
<% if (item['action_text'] !== '' && item['action_url'] !== '') { %> <% if (item['action_text'] !== '' && item['action_url'] !== '') { %>
<ul class="list-actions task-actions"> <ul class="list-actions task-actions">
<li> <li>
<a href="<%= item['action_url'] %>" rel="external" class="action action-primary" <a href="<%= item['action_url'] %>" class="action action-primary"
title="This link will open in a new browser window/tab"><%= item['action_text'] %></a> <% if (item['action_external']) { %>
rel="external" title="This link will open in a new browser window/tab"
<% } %>
><%= item['action_text'] %></a>
</li> </li>
</ul> </ul>
<% } %> <% } %>
......
...@@ -8,98 +8,116 @@ metadata: ...@@ -8,98 +8,116 @@ metadata:
"long_description": "Grant your collaborators permission to edit your course so you can work together.", "long_description": "Grant your collaborators permission to edit your course so you can work together.",
"is_checked": false, "is_checked": false,
"action_url": "ManageUsers", "action_url": "ManageUsers",
"action_text": "Edit Course Team"}, "action_text": "Edit Course Team",
"action_external": false},
{"short_description": "Set Important Dates for Your Course", {"short_description": "Set Important Dates for Your Course",
"long_description": "Establish your course's student enrollment and launch dates on the Schedule and Details page.", "long_description": "Establish your course's student enrollment and launch dates on the Schedule and Details page.",
"is_checked": false, "is_checked": false,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
"action_text": "Edit Course Details &amp; Schedule"}, "action_text": "Edit Course Details &amp; Schedule",
"action_external": false},
{"short_description": "Draft Your Course's Grading Policy", {"short_description": "Draft Your Course's Grading Policy",
"long_description": "Set up your assignment types and grading policy even if you haven't created all your assignments.", "long_description": "Set up your assignment types and grading policy even if you haven't created all your assignments.",
"is_checked": false, "is_checked": false,
"action_url": "SettingsGrading", "action_url": "SettingsGrading",
"action_text": "Edit Grading Settings"}, "action_text": "Edit Grading Settings",
"action_external": false},
{"short_description": "Explore the Other Studio Checklists", {"short_description": "Explore the Other Studio Checklists",
"long_description": "Discover other available course authoring tools, and find help when you need it.", "long_description": "Discover other available course authoring tools, and find help when you need it.",
"is_checked": false, "is_checked": false,
"action_url": "", "action_url": "",
"action_text": ""}] "action_text": "",
"action_external": false}]
}, },
{"short_description" : "Draft a Rough Course Outline", {"short_description" : "Draft a Rough Course Outline",
"items" : [{"short_description": "Create Your First Section and Subsection", "items" : [{"short_description": "Create Your First Section and Subsection",
"long_description": "Use your course outline to build your first Section and Subsection.", "long_description": "Use your course outline to build your first Section and Subsection.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}, "action_text": "Edit Course Outline",
"action_external": false},
{"short_description": "Set Section Release Dates", {"short_description": "Set Section Release Dates",
"long_description": "Specify the release dates for each Section in your course. Sections become visible to students on their release dates.", "long_description": "Specify the release dates for each Section in your course. Sections become visible to students on their release dates.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}, "action_text": "Edit Course Outline",
"action_external": false},
{"short_description": "Designate a Subsection as Graded", {"short_description": "Designate a Subsection as Graded",
"long_description": "Set a Subsection to be graded as a specific assignment type. Assignments within graded Subsections count toward a student's final grade.", "long_description": "Set a Subsection to be graded as a specific assignment type. Assignments within graded Subsections count toward a student's final grade.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}, "action_text": "Edit Course Outline",
"action_external": false},
{"short_description": "Reordering Course Content", {"short_description": "Reordering Course Content",
"long_description": "Use drag and drop to reorder the content in your course.", "long_description": "Use drag and drop to reorder the content in your course.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}, "action_text": "Edit Course Outline",
"action_external": false},
{"short_description": "Renaming Sections", {"short_description": "Renaming Sections",
"long_description": "Rename Sections by clicking the Section name from the Course Outline.", "long_description": "Rename Sections by clicking the Section name from the Course Outline.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}, "action_text": "Edit Course Outline",
"action_external": false},
{"short_description": "Deleting Course Content", {"short_description": "Deleting Course Content",
"long_description": "Delete Sections, Subsections, or Units you don't need anymore. Be careful, as there is no Undo function.", "long_description": "Delete Sections, Subsections, or Units you don't need anymore. Be careful, as there is no Undo function.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}, "action_text": "Edit Course Outline",
"action_external": false},
{"short_description": "Add an Instructor-Only Section to Your Outline", {"short_description": "Add an Instructor-Only Section to Your Outline",
"long_description": "Some course authors find using a section for unsorted, in-progress work useful. To do this, create a section and set the release date to the distant future.", "long_description": "Some course authors find using a section for unsorted, in-progress work useful. To do this, create a section and set the release date to the distant future.",
"is_checked": false, "is_checked": false,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline"}] "action_text": "Edit Course Outline",
"action_external": false}]
}, },
{"short_description" : "Explore edX's Support Tools", {"short_description" : "Explore edX's Support Tools",
"items" : [{"short_description": "Explore the Studio Help Forum", "items" : [{"short_description": "Explore the Studio Help Forum",
"long_description": "Access the Studio Help forum from the menu that appears when you click your user name in the top right corner of Studio.", "long_description": "Access the Studio Help forum from the menu that appears when you click your user name in the top right corner of Studio.",
"is_checked": false, "is_checked": false,
"action_url": "http://help.edge.edx.org/", "action_url": "http://help.edge.edx.org/",
"action_text": "Visit Studio Help"}, "action_text": "Visit Studio Help",
"action_external": true},
{"short_description": "Enroll in edX 101", {"short_description": "Enroll in edX 101",
"long_description": "Register for edX 101, edX's primer for course creation.", "long_description": "Register for edX 101, edX's primer for course creation.",
"is_checked": false, "is_checked": false,
"action_url": "https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about", "action_url": "https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about",
"action_text": "Register for edX 101"}, "action_text": "Register for edX 101",
"action_external": true},
{"short_description": "Download the Studio Documentation", {"short_description": "Download the Studio Documentation",
"long_description": "Download the searchable Studio reference documentation in PDF form.", "long_description": "Download the searchable Studio reference documentation in PDF form.",
"is_checked": false, "is_checked": false,
"action_url": "http://help.edge.edx.org/help/assets/8ccd409f979c8639dd463e126eb840dc67f09098/Getting_Started_with_Studio.pdf", "action_url": "http://help.edge.edx.org/help/assets/8ccd409f979c8639dd463e126eb840dc67f09098/Getting_Started_with_Studio.pdf",
"action_text": "Download Documentation"}] "action_text": "Download Documentation",
"action_external": true}]
}, },
{"short_description" : "Draft Your Course About Page", {"short_description" : "Draft Your Course About Page",
"items" : [{"short_description": "Draft a Course Description", "items" : [{"short_description": "Draft a Course Description",
"long_description": "Courses on edX have an About page that includes a course video, description, and more. Draft the text students will read before deciding to enroll in your course.", "long_description": "Courses on edX have an About page that includes a course video, description, and more. Draft the text students will read before deciding to enroll in your course.",
"is_checked": false, "is_checked": false,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
"action_text": "Edit Course Schedule &amp; Details"}, "action_text": "Edit Course Schedule &amp; Details",
"action_external": false},
{"short_description": "Add Staff Bios", {"short_description": "Add Staff Bios",
"long_description": "Showing prospective students who their instructor will be is helpful. Include staff bios on the course About page.", "long_description": "Showing prospective students who their instructor will be is helpful. Include staff bios on the course About page.",
"is_checked": false, "is_checked": false,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
"action_text": "Edit Course Schedule &amp; Details"}, "action_text": "Edit Course Schedule &amp; Details",
"action_external": false},
{"short_description": "Add Course FAQs", {"short_description": "Add Course FAQs",
"long_description": "Include a short list of frequently asked questions about your course.", "long_description": "Include a short list of frequently asked questions about your course.",
"is_checked": false, "is_checked": false,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
"action_text": "Edit Course Schedule &amp; Details"}, "action_text": "Edit Course Schedule &amp; Details",
"action_external": false},
{"short_description": "Add Course Prerequisites", {"short_description": "Add Course Prerequisites",
"long_description": "Let students know what knowledge and/or skills they should have before they enroll in your course.", "long_description": "Let students know what knowledge and/or skills they should have before they enroll in your course.",
"is_checked": false, "is_checked": false,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
"action_text": "Edit Course Schedule &amp; Details"}] "action_text": "Edit Course Schedule &amp; Details",
"action_external": false}]
} }
] ]
data: { 'textbooks' : [ ], 'wiki_slug' : null } data: { 'textbooks' : [ ], 'wiki_slug' : null }
......
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