Merge pull request #11514 from attiyaIshaque/ai/tnl4067-auto-register-course
User automatically registered to course.
This commit is contained in:
@@ -678,6 +678,7 @@ class MembershipPageAutoEnrollSection(PageObject):
|
||||
|
||||
auto_enroll_browse_button_selector = '.auto_enroll_csv .file-browse input.file_field#browseBtn'
|
||||
auto_enroll_upload_button_selector = '.auto_enroll_csv button[name="enrollment_signup_button"]'
|
||||
batch_enrollment_selector = '.batch-enrollment'
|
||||
NOTIFICATION_ERROR = 'error'
|
||||
NOTIFICATION_WARNING = 'warning'
|
||||
NOTIFICATION_SUCCESS = 'confirmation'
|
||||
@@ -750,6 +751,31 @@ class MembershipPageAutoEnrollSection(PageObject):
|
||||
self.q(css=self.auto_enroll_browse_button_selector).results[0].send_keys(file_path)
|
||||
self.click_upload_file_button()
|
||||
|
||||
def fill_enrollment_batch_text_box(self, email):
|
||||
"""
|
||||
Fill in the form with the provided email and submit it.
|
||||
"""
|
||||
email_selector = "{} >p>textarea".format(self.batch_enrollment_selector)
|
||||
enrollment_button = "{} .enrollment-button[data-action='enroll']".format(self.batch_enrollment_selector)
|
||||
|
||||
# Fill the email addresses after the email selector is visible.
|
||||
self.wait_for_element_visibility(email_selector, 'Email field is visible')
|
||||
self.q(css=email_selector).fill(email)
|
||||
|
||||
# Verify enrollment button is present before clicking
|
||||
EmptyPromise(
|
||||
lambda: self.q(css=enrollment_button).present, "Enrollment button"
|
||||
).fulfill()
|
||||
self.q(css=enrollment_button).click()
|
||||
|
||||
def get_notification_text(self):
|
||||
"""
|
||||
Check notification div is visible and have message.
|
||||
"""
|
||||
notification_selector = '{} .request-response'.format(self.batch_enrollment_selector)
|
||||
self.wait_for_element_visibility(notification_selector, 'Notification div is visible')
|
||||
return self.q(css="{} h3".format(notification_selector)).text
|
||||
|
||||
|
||||
class SpecialExamsPageAllowanceSection(PageObject):
|
||||
"""
|
||||
|
||||
@@ -21,6 +21,7 @@ from ...pages.lms.dashboard import DashboardPage
|
||||
from ...pages.lms.problem import ProblemPage
|
||||
from ...pages.lms.track_selection import TrackSelectionPage
|
||||
from ...pages.lms.pay_and_verify import PaymentAndVerificationFlow, FakePaymentPage
|
||||
from ...pages.lms.login_and_register import CombinedLoginAndRegisterPage
|
||||
from common.test.acceptance.tests.helpers import disable_animations
|
||||
from ...fixtures.certificates import CertificateConfigFixture
|
||||
|
||||
@@ -58,6 +59,9 @@ class AutoEnrollmentWithCSVTest(BaseInstructorDashboardTest):
|
||||
self.log_in_as_instructor()
|
||||
instructor_dashboard_page = self.visit_instructor_dashboard()
|
||||
self.auto_enroll_section = instructor_dashboard_page.select_membership().select_auto_enroll_section()
|
||||
# Initialize the page objects
|
||||
self.register_page = CombinedLoginAndRegisterPage(self.browser, start_page="register")
|
||||
self.dashboard_page = DashboardPage(self.browser)
|
||||
|
||||
def test_browse_and_upload_buttons_are_visible(self):
|
||||
"""
|
||||
@@ -68,6 +72,38 @@ class AutoEnrollmentWithCSVTest(BaseInstructorDashboardTest):
|
||||
self.assertTrue(self.auto_enroll_section.is_file_attachment_browse_button_visible())
|
||||
self.assertTrue(self.auto_enroll_section.is_upload_button_visible())
|
||||
|
||||
def test_enroll_unregister_student(self):
|
||||
"""
|
||||
Scenario: On the Membership tab of the Instructor Dashboard, Batch Enrollment div is visible.
|
||||
Given that I am on the Membership tab on the Instructor Dashboard
|
||||
Then I enter the email and enroll it.
|
||||
Logout the current page.
|
||||
And Navigate to the registration page and register the student.
|
||||
Then I see the course which enrolled the student.
|
||||
"""
|
||||
username = "test_{uuid}".format(uuid=self.unique_id[0:6])
|
||||
email = "{user}@example.com".format(user=username)
|
||||
self.auto_enroll_section.fill_enrollment_batch_text_box(email)
|
||||
self.assertIn(
|
||||
'Successfully sent enrollment emails to the following users. '
|
||||
'They will be enrolled once they register:',
|
||||
self.auto_enroll_section.get_notification_text()
|
||||
)
|
||||
LogoutPage(self.browser).visit()
|
||||
self.register_page.visit()
|
||||
self.register_page.register(
|
||||
email=email,
|
||||
password="123456",
|
||||
username=username,
|
||||
full_name="Test User",
|
||||
terms_of_service=True,
|
||||
country="US",
|
||||
favorite_movie="Harry Potter",
|
||||
)
|
||||
course_names = self.dashboard_page.wait_for_page().available_courses
|
||||
self.assertEquals(len(course_names), 1)
|
||||
self.assertIn(self.course_info["display_name"], course_names)
|
||||
|
||||
def test_clicking_file_upload_button_without_file_shows_error(self):
|
||||
"""
|
||||
Scenario: Clicking on the upload button without specifying a CSV file results in error.
|
||||
|
||||
Reference in New Issue
Block a user