Commit 0431bacb by Sofiya Semenova Committed by GitHub

Merge pull request #12656 from edx/ssemenova/tabindex

Removing instances of positive integer tab index values
parents d5285106 e7e1f647
"""
Course Textbooks page.
"""
from .course_page import CoursePage
from bok_choy.promise import EmptyPromise
class TextbookViewPage(CoursePage):
"""
Course Textbooks page.
"""
url_path = "pdfbook/0/"
def is_browser_on_page(self):
return self.q(css='.book-sidebar').present
def switch_to_pdf_frame(self, test):
"""
Waits for pdf frame to load, then switches driver to the frame
"""
EmptyPromise(
lambda: self.q(css='iframe').present, "Iframe loaded"
).fulfill()
driver = test.get_web_driver()
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
...@@ -8,7 +8,7 @@ from ..common.utils import click_css ...@@ -8,7 +8,7 @@ from ..common.utils import click_css
from .course_page import CoursePage from .course_page import CoursePage
class TextbooksPage(CoursePage): class TextbookUploadPage(CoursePage):
""" """
Course Textbooks page. Course Textbooks page.
""" """
...@@ -41,7 +41,7 @@ class TextbooksPage(CoursePage): ...@@ -41,7 +41,7 @@ class TextbooksPage(CoursePage):
Uploads a pdf textbook. Uploads a pdf textbook.
""" """
# If the pdf upload section has not yet been toggled on, click on the upload pdf button # If the pdf upload section has not yet been toggled on, click on the upload pdf button
test_dir = path(__file__).abspath().dirname().dirname().dirname() test_dir = path(__file__).abspath().dirname().dirname().dirname().dirname() # pylint:disable=no-value-for-parameter
file_path = test_dir + '/data/uploads/' + file_name file_path = test_dir + '/data/uploads/' + file_name
click_css(self, ".edit-textbook .action-upload", require_notification=False) click_css(self, ".edit-textbook .action-upload", require_notification=False)
...@@ -70,3 +70,13 @@ class TextbooksPage(CoursePage): ...@@ -70,3 +70,13 @@ class TextbooksPage(CoursePage):
return False return False
return response.status_code == 200 return response.status_code == 200
def upload_new_textbook(self):
"""
Fills out form to upload a new textbook
"""
self.open_add_textbook_form()
self.upload_pdf_file('textbook.pdf')
self.set_input_field_value('.edit-textbook #textbook-name-input', 'book_1')
self.set_input_field_value('.edit-textbook #chapter1-name', 'chap_1')
self.click_textbook_submit_button()
...@@ -18,7 +18,7 @@ from ...pages.studio.settings import SettingsPage ...@@ -18,7 +18,7 @@ from ...pages.studio.settings import SettingsPage
from ...pages.studio.settings_advanced import AdvancedSettingsPage from ...pages.studio.settings_advanced import AdvancedSettingsPage
from ...pages.studio.settings_graders import GradingPage from ...pages.studio.settings_graders import GradingPage
from ...pages.studio.signup import SignupPage from ...pages.studio.signup import SignupPage
from ...pages.studio.textbooks import TextbooksPage from ...pages.studio.textbook_upload import TextbookUploadPage
from ...fixtures.course import XBlockFixtureDesc from ...fixtures.course import XBlockFixtureDesc
from base_studio_test import StudioCourseTest from base_studio_test import StudioCourseTest
...@@ -82,7 +82,7 @@ class CoursePagesTest(StudioCourseTest): ...@@ -82,7 +82,7 @@ class CoursePagesTest(StudioCourseTest):
# AssetIndexPage, # TODO: Skip testing this page due to FEDX-88 # AssetIndexPage, # TODO: Skip testing this page due to FEDX-88
CourseUpdatesPage, CourseUpdatesPage,
PagesPage, ExportCoursePage, ImportCoursePage, CourseTeamPage, CourseOutlinePage, SettingsPage, PagesPage, ExportCoursePage, ImportCoursePage, CourseTeamPage, CourseOutlinePage, SettingsPage,
AdvancedSettingsPage, GradingPage, TextbooksPage AdvancedSettingsPage, GradingPage, TextbookUploadPage
] ]
] ]
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
Acceptance tests for Studio related to the textbooks. Acceptance tests for Studio related to the textbooks.
""" """
from common.test.acceptance.tests.studio.base_studio_test import StudioCourseTest from common.test.acceptance.tests.studio.base_studio_test import StudioCourseTest
from ...pages.studio.textbooks import TextbooksPage from ...pages.studio.textbook_upload import TextbookUploadPage
from ...pages.lms.textbook_view import TextbookViewPage
from ...tests.helpers import disable_animations from ...tests.helpers import disable_animations
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
...@@ -17,15 +18,17 @@ class TextbooksTest(StudioCourseTest): ...@@ -17,15 +18,17 @@ class TextbooksTest(StudioCourseTest):
Install a course with no content using a fixture. Install a course with no content using a fixture.
""" """
super(TextbooksTest, self).setUp(is_staff) super(TextbooksTest, self).setUp(is_staff)
self.textbook_page = TextbooksPage( self.textbook_upload_page = TextbookUploadPage(
self.browser, self.browser,
self.course_info['org'], self.course_info['org'],
self.course_info['number'], self.course_info['number'],
self.course_info['run'] self.course_info['run']
) )
self.textbook_page.visit() self.textbook_upload_page.visit()
disable_animations(self) disable_animations(self)
self.textbook_view_page = TextbookViewPage(self.browser, self.course_id)
def test_create_first_book_message(self): def test_create_first_book_message(self):
""" """
Scenario: A message is displayed on the textbooks page when there are no uploaded textbooks Scenario: A message is displayed on the textbooks page when there are no uploaded textbooks
...@@ -33,7 +36,7 @@ class TextbooksTest(StudioCourseTest): ...@@ -33,7 +36,7 @@ class TextbooksTest(StudioCourseTest):
And I have not yet uploaded a textbook And I have not yet uploaded a textbook
Then I see a message stating that I have not uploaded any textbooks Then I see a message stating that I have not uploaded any textbooks
""" """
message = self.textbook_page.get_element_text('.wrapper-content .no-textbook-content') message = self.textbook_upload_page.get_element_text('.wrapper-content .no-textbook-content')
self.assertIn("You haven't added any textbooks", message) self.assertIn("You haven't added any textbooks", message)
def test_new_textbook_upload(self): def test_new_textbook_upload(self):
...@@ -43,9 +46,44 @@ class TextbooksTest(StudioCourseTest): ...@@ -43,9 +46,44 @@ class TextbooksTest(StudioCourseTest):
And I have uploaded a PDF textbook and save the new textbook information And I have uploaded a PDF textbook and save the new textbook information
Then the "View Live" link contains a link to the textbook in the LMS Then the "View Live" link contains a link to the textbook in the LMS
""" """
self.textbook_page.open_add_textbook_form() self.textbook_upload_page.upload_new_textbook()
self.textbook_page.upload_pdf_file('textbook.pdf') self.assertTrue(self.textbook_upload_page.is_view_live_link_worked())
self.textbook_page.set_input_field_value('.edit-textbook #textbook-name-input', 'book_1')
self.textbook_page.set_input_field_value('.edit-textbook #chapter1-name', 'chap_1') @attr('a11y')
self.textbook_page.click_textbook_submit_button() def test_textbook_page_a11y(self):
self.assertTrue(self.textbook_page.is_view_live_link_worked()) """
Uploads a new textbook
Runs an accessibility test on the textbook page in lms
"""
self.textbook_upload_page.upload_new_textbook()
self.textbook_view_page.visit()
self.textbook_view_page.a11y_audit.config.set_rules({
'ignore': [
'color-contrast', # AC-500
'skip-link', # AC-501
'link-href', # AC-502
'section' # AC-503
],
})
self.textbook_view_page.a11y_audit.check_for_accessibility_errors()
@attr('a11y')
def test_pdf_viewer_a11y(self):
"""
Uploads a new textbook
Runs an accessibility test on the pdf viewer frame in lms
"""
self.textbook_upload_page.upload_new_textbook()
self.textbook_view_page.visit()
self.textbook_view_page.switch_to_pdf_frame(self)
self.textbook_view_page.a11y_audit.config.set_rules({
'ignore': [
'html-lang', # AC-504
'meta-viewport', # AC-505
'skip-link', # AC-506
'link-href', # AC-507
],
})
self.textbook_view_page.a11y_audit.check_for_accessibility_errors()
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
%endif %endif
<p>${_("Your username, email, and full name will be sent to {destination}, where the collection and use of this information will be governed by their terms of service and privacy policy.").format(destination=return_to)}</p> <p>${_("Your username, email, and full name will be sent to {destination}, where the collection and use of this information will be governed by their terms of service and privacy policy.").format(destination=return_to)}</p>
<label>${_("E-mail")}</label> <label>${_("E-mail")}</label>
<input type="text" name="email" placeholder="${_('E-mail')}" tabindex="1" autofocus="autofocus" /> <input type="text" name="email" placeholder="${_('E-mail')}" autofocus="autofocus" />
<label>${_("Password")}</label> <label>${_("Password")}</label>
<input type="password" name="password" placeholder="${_('Password')}" tabindex="2" /> <input type="password" name="password" placeholder="${_('Password')}" />
<div class="submit"> <div class="submit">
<input name="submit" type="submit" value="${_('Return To %s') % return_to}" tabindex="3" /> <input name="submit" type="submit" value="${_('Return To %s') % return_to}" />
</div> </div>
</form> </form>
</div> </div>
......
...@@ -29,7 +29,7 @@ $(function(){ ...@@ -29,7 +29,7 @@ $(function(){
<div class="book-wrapper"> <div class="book-wrapper">
%if 'chapters' in textbook: %if 'chapters' in textbook:
<section class="book-sidebar" aria-label="${_('Textbook Navigation')}"> <section class="book-sidebar" aria-label="${_('Textbook Navigation')}">
<ul id="booknav" tabindex="0"> <ul id="booknav">
% for (index, entry) in enumerate(textbook['chapters']): % for (index, entry) in enumerate(textbook['chapters']):
<li> <li>
<a class="chapter" rel="${entry['url']}" href="#">${entry.get('title')}</a> <a class="chapter" rel="${entry['url']}" href="#">${entry.get('title')}</a>
...@@ -47,8 +47,6 @@ $(function(){ ...@@ -47,8 +47,6 @@ $(function(){
width="856" width="856"
height="1108" height="1108"
frameborder="0" frameborder="0"
seamless seamless></iframe>
tabindex="1"
aria-live="polite"></iframe>
</div> </div>
</div> </div>
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