from .base_studio_test import ContainerBase from ..fixtures.course import XBlockFixtureDesc from ..pages.studio.utils import verify_ordering class BadComponentTest(ContainerBase): """ Tests that components with bad content do not break the Unit page. """ __test__ = False def get_bad_html_content(self): """ Return the "bad" HTML content that has been problematic for Studio. """ pass def populate_course_fixture(self, course_fixture): """ Sets up a course structure with a unit and a HTML component with bad data and a properly constructed problem. """ course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('html', 'Unit HTML', data=self.get_bad_html_content()), XBlockFixtureDesc('problem', 'Unit Problem', data='') ) ) ) ) def test_html_comp_visible(self): """ Tests that bad HTML data within an HTML component doesn't prevent Studio from displaying the components on the unit page. """ unit = self.go_to_unit_page() verify_ordering(self, unit, [{"": ["Unit HTML", "Unit Problem"]}]) class CopiedFromLmsBadContentTest(BadComponentTest): """ Tests that components with HTML copied from the LMS (LmsRuntime) do not break the Unit page. """ __test__ = True def get_bad_html_content(self): """ Return the "bad" HTML content that has been problematic for Studio. """ return """

Copied from LMS HTML component

""" class CopiedFromStudioBadContentTest(BadComponentTest): """ Tests that components with HTML copied from the Studio (containing "ui-sortable" class) do not break the Unit page. """ __test__ = True def get_bad_html_content(self): """ Return the "bad" HTML content that has been problematic for Studio. """ return """
  1. VOICE COMPARISON

    You can access the experimental Voice Comparison tool at the link below.

""" class JSErrorBadContentTest(BadComponentTest): """ Tests that components that throw JS errors do not break the Unit page. """ __test__ = True def get_bad_html_content(self): """ Return the "bad" HTML content that has been problematic for Studio. """ return ""