Commit c62cc23b by JonahStanley

Refactored Navigation Methods

parent ab5f71ea
...@@ -6,22 +6,21 @@ Feature: Navigate Course ...@@ -6,22 +6,21 @@ Feature: Navigate Course
Scenario: I can navigate to a section Scenario: I can navigate to a section
Given I am viewing a course with multiple sections Given I am viewing a course with multiple sections
When I click on section "2" When I click on section "2"
Then I see the content of section "2" Then I should see the content of section "2"
Scenario: I can navigate to subsections Scenario: I can navigate to subsections
Given I am viewing a section with multiple subsections Given I am viewing a section with multiple subsections
When I click on subsection "2" When I click on subsection "2"
Then I see the content of subsection "2" Then I should see the content of subsection "2"
Scenario: I can navigate to sequences Scenario: I can navigate to sequences
Given I am viewing a section with multiple sequences Given I am viewing a section with multiple sequences
When I click on sequence "2" When I click on sequence "2"
Then I see the content of sequence "2" Then I should see the content of sequence "2"
Scenario: I can go back to where I was after I log out and back in Scenario: I can go back to where I was after I log out and back in
Given I am viewing a course with multiple sections Given I am viewing a course with multiple sections
When I click on section "2" When I click on section "2"
And I visit the homepage And I return later
And I go to the section
Then I should see "You were most recently in Test Section2" somewhere on the page Then I should see "You were most recently in Test Section2" somewhere on the page
...@@ -13,28 +13,18 @@ TEST_COURSE_ORG = 'edx' ...@@ -13,28 +13,18 @@ TEST_COURSE_ORG = 'edx'
TEST_COURSE_NAME = 'Test Course' TEST_COURSE_NAME = 'Test Course'
TEST_SECTION_NAME = 'Test Section' TEST_SECTION_NAME = 'Test Section'
SUBSECTION_2_LOC = None SUBSECTION_2_LOC = None
COURSE_LOC = None
@step(u'I am viewing a course with multiple sections') @step(u'I am viewing a course with multiple sections')
def view_course_multiple_sections(step): def view_course_multiple_sections(step):
# First clear the modulestore so we don't try to recreate create_course()
# the same course twice
# This also ensures that the necessary templates are loaded
world.clear_courses()
# Create the course
# We always use the same org and display name,
# but vary the course identifier (e.g. 600x or 191x)
course = world.CourseFactory.create(org=TEST_COURSE_ORG,
number="model_course",
display_name=TEST_COURSE_NAME)
# Add a section to the course to contain problems # Add a section to the course to contain problems
section1 = world.ItemFactory.create(parent_location=course.location, section1 = world.ItemFactory.create(parent_location=COURSE_LOC,
display_name=TEST_SECTION_NAME+"1") display_name=TEST_SECTION_NAME+"1")
# Add a section to the course to contain problems # Add a section to the course to contain problems
section2 = world.ItemFactory.create(parent_location=course.location, section2 = world.ItemFactory.create(parent_location=COURSE_LOC,
display_name=TEST_SECTION_NAME+"2") display_name=TEST_SECTION_NAME+"2")
world.ItemFactory.create(parent_location=section1.location, world.ItemFactory.create(parent_location=section1.location,
...@@ -48,39 +38,15 @@ def view_course_multiple_sections(step): ...@@ -48,39 +38,15 @@ def view_course_multiple_sections(step):
add_problem_to_course_section('model_course', 'multiple choice', section=1) add_problem_to_course_section('model_course', 'multiple choice', section=1)
add_problem_to_course_section('model_course', 'drop down', section=2) add_problem_to_course_section('model_course', 'drop down', section=2)
# Create the user create_user_and_visit_course()
world.create_user('robot')
u = User.objects.get(username='robot')
# If the user is not already enrolled, enroll the user.
# TODO: change to factory
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id("model_course"))
world.log_in('robot', 'test')
chapter_name = (TEST_SECTION_NAME+"1").replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/model_course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url)
@step(u'I am viewing a section with multiple subsections') @step(u'I am viewing a section with multiple subsections')
def view_course_multiple_subsections(step): def view_course_multiple_subsections(step):
# First clear the modulestore so we don't try to recreate create_course()
# the same course twice
# This also ensures that the necessary templates are loaded
world.clear_courses()
# Create the course
# We always use the same org and display name,
# but vary the course identifier (e.g. 600x or 191x)
course = world.CourseFactory.create(org=TEST_COURSE_ORG,
number="model_course",
display_name=TEST_COURSE_NAME)
# Add a section to the course to contain problems # Add a section to the course to contain problems
section1 = world.ItemFactory.create(parent_location=course.location, section1 = world.ItemFactory.create(parent_location=COURSE_LOC,
display_name=TEST_SECTION_NAME+"1") display_name=TEST_SECTION_NAME+"1")
world.ItemFactory.create(parent_location=section1.location, world.ItemFactory.create(parent_location=section1.location,
...@@ -93,43 +59,17 @@ def view_course_multiple_subsections(step): ...@@ -93,43 +59,17 @@ def view_course_multiple_subsections(step):
global SUBSECTION_2_LOC global SUBSECTION_2_LOC
SUBSECTION_2_LOC = section2.location SUBSECTION_2_LOC = section2.location
add_problem_to_course_section('model_course', 'multiple choice', section=1) add_problem_to_course_section('model_course', 'multiple choice', section=1)
add_problem_to_course_section('model_course', 'drop down', section=1, subsection=2) add_problem_to_course_section('model_course', 'drop down', section=1, subsection=2)
# Create the user create_user_and_visit_course()
world.create_user('robot')
u = User.objects.get(username='robot')
# If the user is not already enrolled, enroll the user.
# TODO: change to factory
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id("model_course"))
world.log_in('robot', 'test')
chapter_name = (TEST_SECTION_NAME+"1").replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/model_course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url)
@step(u'I am viewing a section with multiple sequences') @step(u'I am viewing a section with multiple sequences')
def view_course_multiple_sequences(step): def view_course_multiple_sequences(step):
# First clear the modulestore so we don't try to recreate create_course()
# the same course twice
# This also ensures that the necessary templates are loaded
world.clear_courses()
# Create the course
# We always use the same org and display name,
# but vary the course identifier (e.g. 600x or 191x)
course = world.CourseFactory.create(org=TEST_COURSE_ORG,
number="model_course",
display_name=TEST_COURSE_NAME)
# Add a section to the course to contain problems # Add a section to the course to contain problems
section1 = world.ItemFactory.create(parent_location=course.location, section1 = world.ItemFactory.create(parent_location=COURSE_LOC,
display_name=TEST_SECTION_NAME+"1") display_name=TEST_SECTION_NAME+"1")
...@@ -140,52 +80,32 @@ def view_course_multiple_sequences(step): ...@@ -140,52 +80,32 @@ def view_course_multiple_sequences(step):
add_problem_to_course_section('model_course', 'multiple choice', section=1) add_problem_to_course_section('model_course', 'multiple choice', section=1)
add_problem_to_course_section('model_course', 'drop down', section=1) add_problem_to_course_section('model_course', 'drop down', section=1)
# Create the user create_user_and_visit_course()
world.create_user('robot')
u = User.objects.get(username='robot')
# If the user is not already enrolled, enroll the user.
# TODO: change to factory
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id("model_course"))
world.log_in('robot', 'test')
chapter_name = (TEST_SECTION_NAME+"1").replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/model_course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url)
@step(u'I click on section "([^"]*)"') @step(u'I click on section "([^"]*)"')
def click_on_section(step, section): def click_on_section(step, section):
section_css = 'h3[tabindex="-1"]' section_css = 'h3[tabindex="-1"]'
elist = world.css_find(section_css) world.css_click(section_css)
assert not elist.is_empty()
elist.click()
subid = "ui-accordion-accordion-panel-"+str(int(section)-1) subid = "ui-accordion-accordion-panel-"+str(int(section)-1)
subsection_css = 'ul[id="%s"]>li[class=" "] a' % subid subsection_css = 'ul[id="%s"]>li[class=" "] a' % subid
elist = world.css_find(subsection_css) world.css_click(subsection_css)
assert not elist.is_empty()
elist.click()
@step(u'I click on subsection "([^"]*)"') @step(u'I click on subsection "([^"]*)"')
def click_on_subsection(step, subsection): def click_on_subsection(step, subsection):
subsection_css = 'ul[id="ui-accordion-accordion-panel-0"]>li[class=" "] a' subsection_css = 'ul[id="ui-accordion-accordion-panel-0"]>li[class=" "]>a'
elist = world.css_find(subsection_css) world.css_click(subsection_css)
assert not elist.is_empty()
elist.click()
@step(u'I click on sequence "([^"]*)"') @step(u'I click on sequence "([^"]*)"')
def click_on_subsection(step, sequence): def click_on_sequence(step, sequence):
sequence_css = 'a[data-element="%s"]' % sequence sequence_css = 'a[data-element="%s"]' % sequence
elist = world.css_find(sequence_css) world.css_click(sequence_css)
assert not elist.is_empty()
elist.click()
@step(u'I see the content of (?:sub)?section "([^"]*)"') @step(u'I should see the content of (?:sub)?section "([^"]*)"')
def see_section_content(step, section): def see_section_content(step, section):
if section == "2": if section == "2":
text = 'The correct answer is Option 2' text = 'The correct answer is Option 2'
...@@ -194,19 +114,45 @@ def see_section_content(step, section): ...@@ -194,19 +114,45 @@ def see_section_content(step, section):
step.given('I should see "' + text + '" somewhere on the page') step.given('I should see "' + text + '" somewhere on the page')
@step(u'I see the content of sequence "([^"]*)"') @step(u'I should see the content of sequence "([^"]*)"')
def see_sequence_content(step, sequence): def see_sequence_content(step, sequence):
step.given('I see the content of section "2"') step.given('I should see the content of section "2"')
@step(u'I go to the section') @step(u'I return later')
def return_to_course(step): def return_to_course(step):
step.given('I visit the homepage')
world.click_link("View Course") world.click_link("View Course")
world.click_link("Courseware") world.click_link("Courseware")
### #####################
#HELPERS # HELPERS
### #####################
def create_course():
world.clear_courses()
course = world.CourseFactory.create(org=TEST_COURSE_ORG,
number="model_course",
display_name=TEST_COURSE_NAME)
global COURSE_LOC
COURSE_LOC = course.location
def create_user_and_visit_course():
world.create_user('robot')
u = User.objects.get(username='robot')
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id("model_course"))
world.log_in('robot', 'test')
chapter_name = (TEST_SECTION_NAME+"1").replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/model_course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url)
def add_problem_to_course_section(course, problem_type, extraMeta=None, section=1, subsection=1): def add_problem_to_course_section(course, problem_type, extraMeta=None, section=1, subsection=1):
......
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