Course registration bokchoy test
This commit is contained in:
@@ -27,3 +27,10 @@ class CourseAboutPage(CoursePage):
|
||||
registration_page = RegisterPage(self.browser, self.course_id)
|
||||
registration_page.wait_for_page()
|
||||
return registration_page
|
||||
|
||||
def enroll_in_course(self):
|
||||
"""
|
||||
Click on enroll button
|
||||
"""
|
||||
self.wait_for_element_visibility('.register', 'Enroll button is present')
|
||||
self.q(css='.register').first.click()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Student dashboard page.
|
||||
"""
|
||||
from bok_choy.page_object import PageObject
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from common.test.acceptance.pages.lms import BASE_URL
|
||||
|
||||
@@ -246,3 +247,20 @@ class DashboardPage(PageObject):
|
||||
'Language selector element is available'
|
||||
)
|
||||
return self.q(css='#settings-language-value')
|
||||
|
||||
def is_course_present(self, course_id):
|
||||
"""
|
||||
Checks whether course is present or not.
|
||||
|
||||
Arguments:
|
||||
course_id(str): The unique course id.
|
||||
|
||||
Returns:
|
||||
bool: True if the course is present.
|
||||
"""
|
||||
course_number = CourseKey.from_string(course_id).course
|
||||
return self.q(
|
||||
css='#actions-dropdown-link-0[data-course-number="{}"]'.format(
|
||||
course_number
|
||||
)
|
||||
).present
|
||||
|
||||
@@ -54,3 +54,12 @@ class CourseDiscoveryPage(PageObject):
|
||||
"""
|
||||
self.clear_button.click()
|
||||
self.wait_for_ajax()
|
||||
|
||||
def click_course(self, course_id):
|
||||
"""
|
||||
Click on the course
|
||||
|
||||
Args:
|
||||
course_id(string): ID of the course which is to be clicked
|
||||
"""
|
||||
self.q(css='.courses-listing-item a').filter(lambda el: course_id in el.get_attribute('href')).click()
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
"""
|
||||
End-to-end tests for the LMS.
|
||||
"""
|
||||
import json
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from textwrap import dedent
|
||||
|
||||
@@ -29,6 +31,8 @@ from common.test.acceptance.pages.lms.problem import ProblemPage
|
||||
from common.test.acceptance.pages.lms.progress import ProgressPage
|
||||
from common.test.acceptance.pages.lms.tab_nav import TabNavPage
|
||||
from common.test.acceptance.pages.lms.video.video import VideoPage
|
||||
from common.test.acceptance.pages.lms.discovery import CourseDiscoveryPage
|
||||
from common.test.acceptance.pages.lms.course_about import CourseAboutPage
|
||||
from common.test.acceptance.pages.studio.settings import SettingsPage
|
||||
from common.test.acceptance.tests.helpers import (
|
||||
EventsTestMixin,
|
||||
@@ -37,6 +41,7 @@ from common.test.acceptance.tests.helpers import (
|
||||
get_selected_option_text,
|
||||
load_data_str,
|
||||
select_option_by_text,
|
||||
remove_file
|
||||
)
|
||||
from openedx.core.lib.tests import attr
|
||||
|
||||
@@ -1140,3 +1145,60 @@ class LMSLanguageTest(UniqueCourseTest):
|
||||
get_selected_option_text(language_selector),
|
||||
u'English'
|
||||
)
|
||||
|
||||
|
||||
@attr(shard=19)
|
||||
class RegisterCourseTests(EventsTestMixin, UniqueCourseTest):
|
||||
"""Test that learner can enroll into a course from courses page"""
|
||||
|
||||
TEST_INDEX_FILENAME = "test_root/index_file.dat"
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Initialize the test.
|
||||
|
||||
Create the necessary page objects, create course page and courses to find.
|
||||
"""
|
||||
super(RegisterCourseTests, self).setUp()
|
||||
|
||||
# create test file in which index for this test will live
|
||||
with open(self.TEST_INDEX_FILENAME, "w+") as index_file:
|
||||
json.dump({}, index_file)
|
||||
self.addCleanup(remove_file, self.TEST_INDEX_FILENAME)
|
||||
|
||||
self.course_discovery = CourseDiscoveryPage(self.browser)
|
||||
self.dashboard_page = DashboardPage(self.browser)
|
||||
self.course_about = CourseAboutPage(self.browser, self.course_id)
|
||||
|
||||
# Create a course
|
||||
CourseFixture(
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run'],
|
||||
self.course_info['display_name'],
|
||||
settings={'enrollment_start': datetime(1970, 1, 1).isoformat()}
|
||||
).install()
|
||||
|
||||
# Create a user and log them in
|
||||
AutoAuthPage(self.browser).visit()
|
||||
|
||||
def test_register_for_course(self):
|
||||
"""
|
||||
Scenario: I can register for a course
|
||||
Given The course "6.002x" exists
|
||||
And I am logged in
|
||||
And I visit the courses page
|
||||
When I register for the course "6.002x"
|
||||
Then I should see the course numbered "6.002x" in my dashboard
|
||||
And a "edx.course.enrollment.activated" server event is emitted
|
||||
"""
|
||||
# Navigate to the dashboard
|
||||
self.course_discovery.visit()
|
||||
self.course_discovery.click_course(self.course_id)
|
||||
self.course_about.wait_for_page()
|
||||
self.course_about.enroll_in_course()
|
||||
self.dashboard_page.wait_for_page()
|
||||
self.assertTrue(self.dashboard_page.is_course_present(self.course_id))
|
||||
self.assert_matching_events_were_emitted(
|
||||
event_filter={'name': u'edx.course.enrollment.activated', 'event_source': 'server'}
|
||||
)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
@shard_1
|
||||
Feature: LMS.Register for a course
|
||||
As a registered user
|
||||
In order to access my class content
|
||||
I want to register for a class on the edX website
|
||||
|
||||
Scenario: I can register for a course
|
||||
Given The course "6.002x" exists
|
||||
And I am logged in
|
||||
And I visit the courses page
|
||||
When I register for the course "6.002x"
|
||||
Then I should see the course numbered "6.002x" in my dashboard
|
||||
And a "edx.course.enrollment.activated" server event is emitted
|
||||
Reference in New Issue
Block a user