Commit e2c65c57 by Douglas Hall

Added Studio settings image upload acceptance tests

parent 06fa0839
......@@ -8,6 +8,7 @@ from bok_choy.promise import EmptyPromise
from bok_choy.javascript import requirejs
from .course_page import CoursePage
from .users import wait_for_ajax_or_reload
from .utils import press_the_notification_button
......@@ -26,6 +27,7 @@ class SettingsPage(CoursePage):
# Helpers
################
def is_browser_on_page(self):
wait_for_ajax_or_reload(self.browser)
return self.q(css='body.view-settings').visible
def wait_for_require_js(self):
......@@ -35,6 +37,20 @@ class SettingsPage(CoursePage):
if hasattr(self, 'wait_for_js'):
self.wait_for_js() # pylint: disable=no-member
def wait_for_jquery_value(self, jquery_element, value):
"""
Use jQuery to obtain the element's value.
This is useful for when jQuery performs functions towards the
end of the page load. (In other words, waiting for jquery to
load is not enough; we need to also query values that it has
injected onto the page to ensure it's done.)
"""
self.wait_for(
lambda: self.browser.execute_script(
"return $('{ele}').val();".format(ele=jquery_element)) == '{val}'.format(val=value),
'wait for jQuery to finish loading data on page.'
)
def refresh_and_wait_for_load(self):
"""
Refresh the page and wait for all resources to load.
......@@ -267,7 +283,7 @@ class SettingsPage(CoursePage):
"""
# wait for upload button
self.wait_for_element_presence(upload_btn_selector, 'upload button is present')
self.wait_for_element_visibility(upload_btn_selector, 'upload button is present')
self.q(css=upload_btn_selector).results[0].click()
......
......@@ -510,6 +510,15 @@ class StudioSettingsA11yTest(StudioCourseTest):
],
})
# TODO: Figure out how to get CodeMirror to pass accessibility testing
# We use the CodeMirror Javascript library to
# add code editing to a number of textarea elements
# on this page. CodeMirror generates markup that does
# not pass our accessibility testing rules.
self.settings_page.a11y_audit.config.set_scope(
exclude=['.CodeMirror textarea']
)
self.settings_page.a11y_audit.check_for_accessibility_errors()
......@@ -571,3 +580,41 @@ class StudioSubsectionSettingsA11yTest(StudioCourseTest):
include=['section.edit-settings-timed-examination']
)
self.course_outline.a11y_audit.check_for_accessibility_errors()
class StudioSettingsImageUploadTest(StudioCourseTest):
"""
Class to test course settings image uploads.
"""
def setUp(self): # pylint: disable=arguments-differ
super(StudioSettingsImageUploadTest, self).setUp()
self.settings_page = SettingsPage(self.browser, self.course_info['org'], self.course_info['number'],
self.course_info['run'])
# from nose.tools import set_trace; set_trace()
self.settings_page.visit()
# Ensure jquery is loaded before running a jQuery
self.settings_page.wait_for_ajax()
# This text appears towards the end of the work that jQuery is performing on the page
self.settings_page.wait_for_jquery_value('input#course-name:text', 'test_run')
def test_upload_course_card_image(self):
# upload image
file_to_upload = 'image.jpg'
self.settings_page.upload_image('#upload-course-image', file_to_upload)
self.assertIn(file_to_upload, self.settings_page.get_uploaded_image_path('#course-image'))
def test_upload_course_banner_image(self):
# upload image
file_to_upload = 'image.jpg'
self.settings_page.upload_image('#upload-banner-image', file_to_upload)
self.assertIn(file_to_upload, self.settings_page.get_uploaded_image_path('#banner-image'))
def test_upload_course_video_thumbnail_image(self):
# upload image
file_to_upload = 'image.jpg'
self.settings_page.upload_image('#upload-video-thumbnail-image', file_to_upload)
self.assertIn(file_to_upload, self.settings_page.get_uploaded_image_path('#video-thumbnail-image'))
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