def test_library_pagination(self):
     """
     Scenario: Ensure that adding several XBlocks to a library results in pagination.
     Given that I have a library in Studio with 40 XBlocks
     Then 10 are displayed
     And the first XBlock will be the 1st one
     And I'm on the 1st page
     When I add 1 Multiple Choice XBlock
     Then 1 XBlock will be displayed
     And I'm on the 5th page
     The first XBlock will be the newest one
     When I delete that XBlock
     Then 10 are displayed
     And I'm on the 4th page
     And the first XBlock is the 31st one
     And the last XBlock is the 40th one.
     """
     self.assertEqual(len(self.lib_page.xblocks), 10)
     self.assertEqual(self.lib_page.get_page_number(), '1')
     self.assertEqual(self.lib_page.xblocks[0].name, '1')
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 1)
     self.assertEqual(self.lib_page.get_page_number(), '5')
     self.assertEqual(self.lib_page.xblocks[0].name, "Multiple Choice")
     self.lib_page.click_delete_button(self.lib_page.xblocks[0].locator)
     self.assertEqual(len(self.lib_page.xblocks), 10)
     self.assertEqual(self.lib_page.get_page_number(), '4')
     self.assertEqual(self.lib_page.xblocks[0].name, '31')
     self.assertEqual(self.lib_page.xblocks[-1].name, '40')
Exemplo n.º 2
0
 def test_library_pagination(self):
     """
     Scenario: Ensure that adding several XBlocks to a library results in pagination.
     Given that I have a library in Studio with 40 XBlocks
     Then 10 are displayed
     And the first XBlock will be the 1st one
     And I'm on the 1st page
     When I add 1 Multiple Choice XBlock
     Then 1 XBlock will be displayed
     And I'm on the 5th page
     The first XBlock will be the newest one
     When I delete that XBlock
     Then 10 are displayed
     And I'm on the 4th page
     And the first XBlock is the 31st one
     And the last XBlock is the 40th one.
     """
     self.assertEqual(len(self.lib_page.xblocks), 10)
     self.assertEqual(self.lib_page.get_page_number(), '1')
     self.assertEqual(self.lib_page.xblocks[0].name, '1')
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 1)
     self.assertEqual(self.lib_page.get_page_number(), '5')
     self.assertEqual(self.lib_page.xblocks[0].name, "Multiple Choice")
     self.lib_page.click_delete_button(self.lib_page.xblocks[0].locator)
     self.assertEqual(len(self.lib_page.xblocks), 10)
     self.assertEqual(self.lib_page.get_page_number(), '4')
     self.assertEqual(self.lib_page.xblocks[0].name, '31')
     self.assertEqual(self.lib_page.xblocks[-1].name, '40')
Exemplo n.º 3
0
    def test_add_duplicate_delete_actions(self):
        """
        Scenario: Ensure that we can add an HTML block, duplicate it, then delete the original.
        Given I have a library in Studio with no XBlocks
        And I navigate to Library Page in Studio
        Then there are no XBlocks displayed
        When I add Text XBlock
        Then one XBlock is displayed
        When I duplicate first XBlock
        Then two XBlocks are displayed
        And those XBlocks locators' are different
        When I delete first XBlock
        Then one XBlock is displayed
        And displayed XBlock are second one
        """
        self.assertEqual(len(self.lib_page.xblocks), 0)

        # Create a new block:
        add_component(self.lib_page, "html", "Text")
        self.assertEqual(len(self.lib_page.xblocks), 1)
        first_block_id = self.lib_page.xblocks[0].locator

        # Duplicate the block:
        self.lib_page.click_duplicate_button(first_block_id)
        self.assertEqual(len(self.lib_page.xblocks), 2)
        second_block_id = self.lib_page.xblocks[1].locator
        self.assertNotEqual(first_block_id, second_block_id)

        # Delete the first block:
        self.lib_page.click_delete_button(first_block_id, confirm=True)
        self.assertEqual(len(self.lib_page.xblocks), 1)
        self.assertEqual(self.lib_page.xblocks[0].locator, second_block_id)
    def test_add_duplicate_delete_actions(self):
        """
        Scenario: Ensure that we can add an HTML block, duplicate it, then delete the original.
        Given I have a library in Studio with no XBlocks
        And I navigate to Library Page in Studio
        Then there are no XBlocks displayed
        When I add Text XBlock
        Then one XBlock is displayed
        When I duplicate first XBlock
        Then two XBlocks are displayed
        And those XBlocks locators' are different
        When I delete first XBlock
        Then one XBlock is displayed
        And displayed XBlock are second one
        """
        self.assertEqual(len(self.lib_page.xblocks), 0)

        # Create a new block:
        add_component(self.lib_page, "html", "Text")
        self.assertEqual(len(self.lib_page.xblocks), 1)
        first_block_id = self.lib_page.xblocks[0].locator

        # Duplicate the block:
        self.lib_page.click_duplicate_button(first_block_id)
        self.assertEqual(len(self.lib_page.xblocks), 2)
        second_block_id = self.lib_page.xblocks[1].locator
        self.assertNotEqual(first_block_id, second_block_id)

        # Delete the first block:
        self.lib_page.click_delete_button(first_block_id, confirm=True)
        self.assertEqual(len(self.lib_page.xblocks), 1)
        self.assertEqual(self.lib_page.xblocks[0].locator, second_block_id)
Exemplo n.º 5
0
 def test_add_latex_html_component(self):
     """
     Scenario: I can add Latex HTML components
     Given I am in Studio editing a new unit
     Given I have enabled latex compiler
     When I add this type of HTML component:
         | Component               |
         | E-text Written in LaTeX |
     Then I see HTML components in this order:
         | Component               |
         | E-text Written in LaTeX |
     """
     # Latex component
     component = 'E-text Written in LaTeX'
     # Visit advanced settings page and enable latex compiler.
     self.advanced_settings.visit()
     self.advanced_settings.set('Enable LaTeX Compiler', 'True')
     self.go_to_unit_page()
     container_page = ContainerPage(self.browser, None)
     # Add latex component
     add_component(container_page,
                   'html',
                   component,
                   is_advanced_problem=False)
     problem = container_page.xblocks[1]
     # Asset that component has been added.
     self.assertEqual(problem.name, component)
    def _add_component(self, sub_type):
        """
        Add sub-type of HTML component in studio

        Args:
            sub_type(str): Sub-type of HTML component
        """
        add_component(self.container_page, 'html', sub_type)
        self.component = self.unit.xblocks[1]
        self.html_editor = HtmlXBlockEditorView(self.browser, self.component.locator)
        self.iframe = HTMLEditorIframe(self.browser, self.component.locator)
 def test_no_edit_visibility_button(self):
     """
     Scenario: Ensure that library xblocks do not have 'edit visibility' buttons.
     Given I have a library in Studio with no XBlocks
     And I navigate to Library Page in Studio
     When I add Text XBlock
     Then one XBlock is displayed
     And no 'edit visibility' button is shown
     """
     add_component(self.lib_page, "html", "Text")
     self.assertFalse(self.lib_page.xblocks[0].has_edit_visibility_button)
Exemplo n.º 8
0
 def test_no_edit_visibility_button(self):
     """
     Scenario: Ensure that library xblocks do not have 'edit visibility' buttons.
     Given I have a library in Studio with no XBlocks
     And I navigate to Library Page in Studio
     When I add Text XBlock
     Then one XBlock is displayed
     And no 'edit visibility' button is shown
     """
     add_component(self.lib_page, "html", "Text")
     self.assertFalse(self.lib_page.xblocks[0].has_edit_visibility_button)
Exemplo n.º 9
0
 def test_nav_present_but_disabled(self, position):
     """
     Scenario: Ensure that the navigation buttons aren't active when there aren't enough XBlocks.
     Given that I have a library in Studio with no XBlocks
     The Navigation buttons should be disabled.
     When I add a multiple choice problem
     The Navigation buttons should be disabled.
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     self.assertTrue(self.lib_page.nav_disabled(position))
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertTrue(self.lib_page.nav_disabled(position))
 def test_nav_present_but_disabled(self, position):
     """
     Scenario: Ensure that the navigation buttons aren't active when there aren't enough XBlocks.
     Given that I have a library in Studio with no XBlocks
     The Navigation buttons should be disabled.
     When I add a multiple choice problem
     The Navigation buttons should be disabled.
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     self.assertTrue(self.lib_page.nav_disabled(position))
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertTrue(self.lib_page.nav_disabled(position))
    def _add_component(self, sub_type):
        """
        Add sub-type of HTML component in studio

        Args:
            sub_type(str): Sub-type of HTML component
        """
        add_component(self.container_page, 'html', sub_type)
        self.component = self.unit.xblocks[1]
        self.html_editor = HtmlXBlockEditorView(self.browser,
                                                self.component.locator)
        self.iframe = HTMLEditorIframe(self.browser, self.component.locator)
Exemplo n.º 12
0
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(ProblemComponentEditor, self).setUp(is_staff=is_staff)
     self.component = 'Blank Common Problem'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     # Add a Problem
     add_component(self.container_page, 'problem', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.problem_editor = ProblemXBlockEditorView(self.browser, self.component.locator)
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(DiscussionComponentTest, self).setUp(is_staff=is_staff)
     self.component = 'discussion'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     # Add Discussion component
     add_component(self.container_page, 'discussion', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.discussion_editor = DiscussionComponentEditor(self.browser, self.component.locator)
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(ProblemComponentEditor, self).setUp(is_staff=is_staff)
     self.component = 'Blank Common Problem'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     # Add a Problem
     add_component(self.container_page, 'problem', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.problem_editor = ProblemXBlockEditorView(self.browser, self.component.locator)
Exemplo n.º 15
0
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(DiscussionComponentTest, self).setUp(is_staff=is_staff)
     self.component = 'discussion'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     # Add Discussion component
     add_component(self.container_page, 'discussion', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.discussion_editor = DiscussionComponentEditor(self.browser, self.component.locator)
Exemplo n.º 16
0
 def setUp(self, is_staff=True):
     """
     Create a course with a section, subsection, and unit to which to add the component.
     """
     super(HTMLComponentEditor, self).setUp(is_staff=is_staff)
     self.component = 'Text'
     self.unit = self.go_to_unit_page()
     self.container_page = ContainerPage(self.browser, None)
     self.xblock_wrapper = XBlockWrapper(self.browser, None)
     # Add HTML component
     add_component(self.container_page, 'html', self.component)
     self.component = self.unit.xblocks[1]
     self.container_page.edit()
     self.html_editor = HtmlXBlockEditorView(self.browser, self.component.locator)
     self.iframe = HTMLEditorIframe(self.browser, self.component.locator)
Exemplo n.º 17
0
 def test_library_pagination(self):
     """
     Scenario: Ensure that adding several XBlocks to a library results in pagination.
     Given that I have a library in Studio with no XBlocks
     And I create 10 Multiple Choice XBlocks
     Then 10 are displayed.
     When I add one more Multiple Choice XBlock
     Then 1 XBlock will be displayed
     When I delete that XBlock
     Then 10 are displayed.
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     for _ in range(10):
         add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 10)
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 1)
     self.lib_page.click_delete_button(self.lib_page.xblocks[0].locator)
     self.assertEqual(len(self.lib_page.xblocks), 10)
 def test_library_pagination(self):
     """
     Scenario: Ensure that adding several XBlocks to a library results in pagination.
     Given that I have a library in Studio with no XBlocks
     And I create 10 Multiple Choice XBlocks
     Then 10 are displayed.
     When I add one more Multiple Choice XBlock
     Then 1 XBlock will be displayed
     When I delete that XBlock
     Then 10 are displayed.
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     for _ in range(10):
         add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 10)
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 1)
     self.lib_page.click_delete_button(self.lib_page.xblocks[0].locator)
     self.assertEqual(len(self.lib_page.xblocks), 10)
 def test_delete_deletes_only_desired_block(self):
     """
     Scenario: Ensure that when deleting XBlock only desired XBlock is deleted
     Given that I have a library in Studio with no XBlocks
     And I create Blank Common Problem XBlock
     And I create Checkboxes XBlock
     When I delete Blank Problem XBlock
     Then Checkboxes XBlock is not deleted
     And Blank Common Problem XBlock is deleted
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     add_component(self.lib_page, "problem", "Blank Common Problem")
     add_component(self.lib_page, "problem", "Checkboxes")
     self.assertEqual(len(self.lib_page.xblocks), 2)
     self.assertIn("Blank Common Problem", self.lib_page.xblocks[0].name)
     self.assertIn("Checkboxes", self.lib_page.xblocks[1].name)
     self.lib_page.click_delete_button(self.lib_page.xblocks[0].locator)
     self.assertEqual(len(self.lib_page.xblocks), 1)
     problem_block = self.lib_page.xblocks[0]
     self.assertIn("Checkboxes", problem_block.name)
Exemplo n.º 20
0
 def test_delete_deletes_only_desired_block(self):
     """
     Scenario: Ensure that when deleting XBlock only desired XBlock is deleted
     Given that I have a library in Studio with no XBlocks
     And I create Blank Common Problem XBlock
     And I create Checkboxes XBlock
     When I delete Blank Problem XBlock
     Then Checkboxes XBlock is not deleted
     And Blank Common Problem XBlock is deleted
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     add_component(self.lib_page, "problem", "Blank Common Problem")
     add_component(self.lib_page, "problem", "Checkboxes")
     self.assertEqual(len(self.lib_page.xblocks), 2)
     self.assertIn("Blank Common Problem", self.lib_page.xblocks[0].name)
     self.assertIn("Checkboxes", self.lib_page.xblocks[1].name)
     self.lib_page.click_delete_button(self.lib_page.xblocks[0].locator)
     self.assertEqual(len(self.lib_page.xblocks), 1)
     problem_block = self.lib_page.xblocks[0]
     self.assertIn("Checkboxes", problem_block.name)
    def test_add_advanced_problem(self, component):
        """
        Scenario Outline: I can add Advanced Problem components
           Given I am in Studio editing a new unit
           When I add a "<Component>" "Advanced Problem" component
           Then I see a "<Component>" Problem component

        Examples:
               | Component                     |
               | Blank Advanced Problem        |
               | Circuit Schematic Builder     |
               | Custom Python-Evaluated Input |
               | Drag and Drop                 |
               | Image Mapped Input            |
               | Math Expression Input         |
               | Problem with Adaptive Hint    |
        """
        self.go_to_unit_page()
        page = ContainerPage(self.browser, None)
        add_component(page, 'problem', component, is_advanced_problem=True)
        problem = page.xblocks[1]
        self.assertEqual(problem.name, component)
    def test_add_advanced_problem(self, component):
        """
        Scenario Outline: I can add Advanced Problem components
           Given I am in Studio editing a new unit
           When I add a "<Component>" "Advanced Problem" component
           Then I see a "<Component>" Problem component

        Examples:
               | Component                     |
               | Blank Advanced Problem        |
               | Circuit Schematic Builder     |
               | Custom Python-Evaluated Input |
               | Drag and Drop                 |
               | Image Mapped Input            |
               | Math Expression Input         |
               | Problem with Adaptive Hint    |
        """
        self.go_to_unit_page()
        page = ContainerPage(self.browser, None)
        add_component(page, 'problem', component, is_advanced_problem=True)
        problem = page.xblocks[1]
        self.assertEqual(problem.name, component)
 def test_add_edit_xblock(self):
     """
     Scenario: Ensure that we can add an XBlock, edit it, then see the resulting changes.
     Given I have a library in Studio with no XBlocks
     And I navigate to Library Page in Studio
     Then there are no XBlocks displayed
     When I add Multiple Choice XBlock
     Then one XBlock is displayed
     When I edit first XBlock
     And I go to basic tab
     And set it's text to a fairly trivial question about Battlestar Galactica
     And save XBlock
     Then one XBlock is displayed
     And first XBlock student content contains at least part of text I set
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     # Create a new problem block:
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 1)
     problem_block = self.lib_page.xblocks[0]
     # Edit it:
     problem_block.edit()
     problem_block.open_basic_tab()
     problem_block.set_codemirror_text(
         """
         >>Who is "Starbuck"?<<
          (x) Kara Thrace
          ( ) William Adama
          ( ) Laura Roslin
          ( ) Lee Adama
          ( ) Gaius Baltar
         """
     )
     problem_block.save_settings()
     # Check that the save worked:
     self.assertEqual(len(self.lib_page.xblocks), 1)
     problem_block = self.lib_page.xblocks[0]
     self.assertIn("Laura Roslin", problem_block.author_content)
Exemplo n.º 24
0
 def test_add_edit_xblock(self):
     """
     Scenario: Ensure that we can add an XBlock, edit it, then see the resulting changes.
     Given I have a library in Studio with no XBlocks
     And I navigate to Library Page in Studio
     Then there are no XBlocks displayed
     When I add Multiple Choice XBlock
     Then one XBlock is displayed
     When I edit first XBlock
     And I go to basic tab
     And set it's text to a fairly trivial question about Battlestar Galactica
     And save XBlock
     Then one XBlock is displayed
     And first XBlock student content contains at least part of text I set
     """
     self.assertEqual(len(self.lib_page.xblocks), 0)
     # Create a new problem block:
     add_component(self.lib_page, "problem", "Multiple Choice")
     self.assertEqual(len(self.lib_page.xblocks), 1)
     problem_block = self.lib_page.xblocks[0]
     # Edit it:
     problem_block.edit()
     problem_block.open_basic_tab()
     problem_block.set_codemirror_text(
         """
         >>Who is "Starbuck"?<<
          (x) Kara Thrace
          ( ) William Adama
          ( ) Laura Roslin
          ( ) Lee Adama
          ( ) Gaius Baltar
         """
     )
     problem_block.save_settings()
     # Check that the save worked:
     self.assertEqual(len(self.lib_page.xblocks), 1)
     problem_block = self.lib_page.xblocks[0]
     self.assertIn("Laura Roslin", problem_block.author_content)
Exemplo n.º 25
0
 def test_preview_add_xblock(self):
     """
     Scenario: Ensure previews are shown when adding new blocks, regardless of preview setting.
     Given that I have a library in Studio with 40 XBlocks
     Then previews are visible
     And when I click the toggle previews button
     Then the previews will not be visible
     And when I add an XBlock
     Then I will be on the 5th page
     And the XBlock will have loaded a preview
     And when I revisit the library
     And I go to the 5th page
     Then the top XBlock will be the one I added
     And it will not have a preview
     And when I add an XBlock
     Then the XBlock I added will have a preview
     And the top XBlock will not have one.
     """
     self.assertTrue(self.lib_page.are_previews_showing())
     self.lib_page.toggle_previews()
     self.assertFalse(self.lib_page.are_previews_showing())
     add_component(self.lib_page, "problem", "Checkboxes")
     self.assertEqual(self.lib_page.get_page_number(), '5')
     first_added = self.lib_page.xblocks[0]
     self.assertIn("Checkboxes", first_added.name)
     self.assertFalse(self.lib_page.xblocks[0].is_placeholder())
     self.lib_page.visit()
     self.lib_page.wait_until_ready()
     self.lib_page.go_to_page(5)
     self.assertTrue(self.lib_page.xblocks[0].is_placeholder())
     add_component(self.lib_page, "problem", "Multiple Choice")
     # DOM has detatched the element since last assignment
     first_added = self.lib_page.xblocks[0]
     second_added = self.lib_page.xblocks[1]
     self.assertIn("Multiple Choice", second_added.name)
     self.assertFalse(second_added.is_placeholder())
     self.assertTrue(first_added.is_placeholder())
 def test_preview_add_xblock(self):
     """
     Scenario: Ensure previews are shown when adding new blocks, regardless of preview setting.
     Given that I have a library in Studio with 40 XBlocks
     Then previews are visible
     And when I click the toggle previews button
     Then the previews will not be visible
     And when I add an XBlock
     Then I will be on the 5th page
     And the XBlock will have loaded a preview
     And when I revisit the library
     And I go to the 5th page
     Then the top XBlock will be the one I added
     And it will not have a preview
     And when I add an XBlock
     Then the XBlock I added will have a preview
     And the top XBlock will not have one.
     """
     self.assertTrue(self.lib_page.are_previews_showing())
     self.lib_page.toggle_previews()
     self.assertFalse(self.lib_page.are_previews_showing())
     add_component(self.lib_page, "problem", "Checkboxes")
     self.assertEqual(self.lib_page.get_page_number(), '5')
     first_added = self.lib_page.xblocks[0]
     self.assertIn("Checkboxes", first_added.name)
     self.assertFalse(self.lib_page.xblocks[0].is_placeholder())
     self.lib_page.visit()
     self.lib_page.wait_until_ready()
     self.lib_page.go_to_page(5)
     self.assertTrue(self.lib_page.xblocks[0].is_placeholder())
     add_component(self.lib_page, "problem", "Multiple Choice")
     # DOM has detatched the element since last assignment
     first_added = self.lib_page.xblocks[0]
     second_added = self.lib_page.xblocks[1]
     self.assertIn("Multiple Choice", second_added.name)
     self.assertFalse(second_added.is_placeholder())
     self.assertTrue(first_added.is_placeholder())
 def test_add_latex_html_component(self):
     """
     Scenario: I can add Latex HTML components
     Given I am in Studio editing a new unit
     Given I have enabled latex compiler
     When I add this type of HTML component:
         | Component               |
         | E-text Written in LaTeX |
     Then I see HTML components in this order:
         | Component               |
         | E-text Written in LaTeX |
     """
     # Latex component
     component = 'E-text Written in LaTeX'
     # Visit advanced settings page and enable latex compiler.
     self.advanced_settings.visit()
     self.advanced_settings.set('Enable LaTeX Compiler', 'True')
     self.go_to_unit_page()
     container_page = ContainerPage(self.browser, None)
     # Add latex component
     add_component(container_page, 'html', component, is_advanced_problem=False)
     problem = container_page.xblocks[1]
     # Asset that component has been added.
     self.assertEqual(problem.name, component)