Replace bulk email settings with admin config models
Moves ENABLE_INSTRUCTOR_EMAIL and REQUIRE_COURSE_EMAIL_AUTH from settings files
to admin-accessible configuration models. This allows for the bulk email settings
to be modified without a new AMI deploy. See TNL-4504.
Also updates tests:
-python tests mock out the new configurations in place of the old settings
-lettuce test has been moved to bokchoy
(note that there was some loss of coverage here - the lettuce tests had
been doing some voodoo to allow for cross-process inspection of emails
messages being "sent" by the server, from the client! In discussion with
testeng, this seems outside the realm of a visual acceptance test. So,
the bokchoy test simply confirm the successful queueing of the message,
and leaves the validation of sending messages to the relevant unit tests.)
-bok choy fixture has been added, to replace the settings in acceptance.py
-lettuce and bok choy databases have been updated to reflect the backend changes
The new default is to have bulk_email disabled, we'll need to call this out in the
next OpenEdx release to ensure administrators enable this feature if needed.
This commit is contained in:
@@ -75,6 +75,15 @@ class InstructorDashboardPage(CoursePage):
|
||||
timed_exam_section.wait_for_page()
|
||||
return timed_exam_section
|
||||
|
||||
def select_bulk_email(self):
|
||||
"""
|
||||
Selects the email tab and returns the bulk email section
|
||||
"""
|
||||
self.q(css='a[data-section=send_email]').first.click()
|
||||
email_section = BulkEmailPage(self.browser)
|
||||
email_section.wait_for_page()
|
||||
return email_section
|
||||
|
||||
@staticmethod
|
||||
def get_asset_path(file_name):
|
||||
"""
|
||||
@@ -98,6 +107,62 @@ class InstructorDashboardPage(CoursePage):
|
||||
return os.sep.join(folders_list_in_path)
|
||||
|
||||
|
||||
class BulkEmailPage(PageObject):
|
||||
"""
|
||||
Bulk email section of the instructor dashboard.
|
||||
This feature is controlled by an admin panel feature flag, which is turned on via database fixture for testing.
|
||||
"""
|
||||
url = None
|
||||
|
||||
def is_browser_on_page(self):
|
||||
return self.q(css='a[data-section=send_email].active-section').present
|
||||
|
||||
def _bounded_selector(self, selector):
|
||||
"""
|
||||
Return `selector`, but limited to the bulk-email context.
|
||||
"""
|
||||
return '.send-email {}'.format(selector)
|
||||
|
||||
def _select_recipient(self, recipient):
|
||||
"""
|
||||
Selects the specified recipient from the selector. Assumes that recipient is not None.
|
||||
"""
|
||||
recipient_selector_css = "select[name='send_to']"
|
||||
select_option_by_text(
|
||||
self.q(css=self._bounded_selector(recipient_selector_css)), recipient
|
||||
)
|
||||
|
||||
def send_message(self, recipient):
|
||||
"""
|
||||
Send a test message to the specified recipient.
|
||||
"""
|
||||
send_css = "input[name='send']"
|
||||
test_subject = "Hello"
|
||||
test_body = "This is a test email"
|
||||
|
||||
self._select_recipient(recipient)
|
||||
self.q(css=self._bounded_selector("input[name='subject']")).fill(test_subject)
|
||||
self.q(css=self._bounded_selector("iframe#mce_0_ifr"))[0].click()
|
||||
self.q(css=self._bounded_selector("iframe#mce_0_ifr"))[0].send_keys(test_body)
|
||||
|
||||
with self.handle_alert(confirm=True):
|
||||
self.q(css=self._bounded_selector(send_css)).click()
|
||||
|
||||
def verify_message_queued_successfully(self):
|
||||
"""
|
||||
Verifies that the "you email was queued" message appears.
|
||||
|
||||
Note that this does NOT ensure the message gets sent successfully, that functionality
|
||||
is covered by the bulk_email unit tests.
|
||||
"""
|
||||
confirmation_selector = self._bounded_selector(".msg-confirm")
|
||||
expected_text = u"Your email was successfully queued for sending."
|
||||
EmptyPromise(
|
||||
lambda: expected_text in self.q(css=confirmation_selector)[0].text,
|
||||
"Message Queued Confirmation"
|
||||
).fulfill()
|
||||
|
||||
|
||||
class MembershipPage(PageObject):
|
||||
"""
|
||||
Membership section of the Instructor dashboard.
|
||||
|
||||
@@ -46,6 +46,25 @@ class BaseInstructorDashboardTest(EventsTestMixin, UniqueCourseTest):
|
||||
return instructor_dashboard_page
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class BulkEmailTest(BaseInstructorDashboardTest):
|
||||
"""
|
||||
End-to-end tests for bulk emailing from instructor dash.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(BulkEmailTest, self).setUp()
|
||||
self.course_fixture = CourseFixture(**self.course_info).install()
|
||||
self.log_in_as_instructor()
|
||||
instructor_dashboard_page = self.visit_instructor_dashboard()
|
||||
self.send_email_page = instructor_dashboard_page.select_bulk_email()
|
||||
|
||||
@ddt.data("Myself", "Staff and admins", "All (students, staff, and admins)")
|
||||
def test_email_queued_for_sending(self, recipient):
|
||||
self.assertTrue(self.send_email_page.is_browser_on_page())
|
||||
self.send_email_page.send_message(recipient)
|
||||
self.send_email_page.verify_message_queued_successfully()
|
||||
|
||||
|
||||
@attr('shard_7')
|
||||
class AutoEnrollmentWithCSVTest(BaseInstructorDashboardTest):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user