test_studio_textbooks.py 3.36 KB
Newer Older
1 2 3 4
"""
Acceptance tests for Studio related to the textbooks.
"""
from common.test.acceptance.tests.studio.base_studio_test import StudioCourseTest
5 6
from ...pages.studio.textbook_upload import TextbookUploadPage
from ...pages.lms.textbook_view import TextbookViewPage
7 8 9 10 11 12 13 14 15 16 17 18 19 20
from ...tests.helpers import disable_animations
from nose.plugins.attrib import attr


@attr('shard_2')
class TextbooksTest(StudioCourseTest):
    """
    Test that textbook functionality is working properly on studio side
    """
    def setUp(self, is_staff=True):
        """
        Install a course with no content using a fixture.
        """
        super(TextbooksTest, self).setUp(is_staff)
21
        self.textbook_upload_page = TextbookUploadPage(
22 23 24 25 26
            self.browser,
            self.course_info['org'],
            self.course_info['number'],
            self.course_info['run']
        )
27
        self.textbook_upload_page.visit()
28 29
        disable_animations(self)

30 31
        self.textbook_view_page = TextbookViewPage(self.browser, self.course_id)

32 33 34 35 36 37 38
    def test_create_first_book_message(self):
        """
        Scenario: A message is displayed on the textbooks page when there are no uploaded textbooks
        Given that I am viewing the Textbooks page in Studio
        And I have not yet uploaded a textbook
        Then I see a message stating that I have not uploaded any textbooks
        """
39
        message = self.textbook_upload_page.get_element_text('.wrapper-content .no-textbook-content')
40 41 42 43 44 45 46 47 48
        self.assertIn("You haven't added any textbooks", message)

    def test_new_textbook_upload(self):
        """
        Scenario: View Live link for textbook is correctly populated
        Given that I am viewing the Textbooks page in Studio
        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
        """
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        self.textbook_upload_page.upload_new_textbook()
        self.assertTrue(self.textbook_upload_page.is_view_live_link_worked())

    @attr('a11y')
    def test_textbook_page_a11y(self):
        """
        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': [
ssemenova committed
83
                'color-contrast',  # will always fail because pdf.js converts pdf to divs with transparent text
84 85 86 87 88 89 90
                '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()