From ce665e3b4c64618f33fcfeeed66acc924e913ca5 Mon Sep 17 00:00:00 2001 From: Muddasser Date: Mon, 20 Jun 2016 12:24:24 +0000 Subject: [PATCH] Conversion of cms/component.feature into bokchoy tests --- .../contentstore/features/component.feature | 61 --------- common/test/acceptance/pages/studio/utils.py | 12 ++ .../tests/studio/test_studio_components.py | 119 +++++++++++++++++- 3 files changed, 130 insertions(+), 62 deletions(-) delete mode 100644 cms/djangoapps/contentstore/features/component.feature diff --git a/cms/djangoapps/contentstore/features/component.feature b/cms/djangoapps/contentstore/features/component.feature deleted file mode 100644 index cd34107f39..0000000000 --- a/cms/djangoapps/contentstore/features/component.feature +++ /dev/null @@ -1,61 +0,0 @@ -@shard_1 -Feature: CMS.Component Adding - As a course author, I want to be able to add a wide variety of components - - Scenario: I can add HTML components - Given I am in Studio editing a new unit - When I add this type of HTML component: - | Component | - | Text | - | Announcement | - | Zooming Image Tool | - | Raw HTML | - Then I see HTML components in this order: - | Component | - | Text | - | Announcement | - | Zooming Image Tool | - | Raw HTML | - - 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 | - - Scenario: I can add Common Problem components - Given I am in Studio editing a new unit - When I add this type of Problem component: - | Component | - | Blank Common Problem | - | Checkboxes | - | Dropdown | - | Multiple Choice | - | Numerical Input | - | Text Input | - Then I see Problem components in this order: - | Component | - | Blank Common Problem | - | Checkboxes | - | Dropdown | - | Multiple Choice | - | Numerical Input | - | Text Input | - -# Disabled 1/21/14 due to flakiness seen in master -# Scenario: I can add Advanced Latex Problem components -# Given I am in Studio editing a new unit -# Given I have enabled latex compiler -# When I add a "" "Advanced Problem" component -# Then I see a "" Problem component -# # Flush out the database before the next example executes -# And I reset the database - -# Examples: -# | Component | -# | Problem Written in LaTeX | -# | Problem with Adaptive Hint in Latex | diff --git a/common/test/acceptance/pages/studio/utils.py b/common/test/acceptance/pages/studio/utils.py index 5ac2148234..d118a35b51 100644 --- a/common/test/acceptance/pages/studio/utils.py +++ b/common/test/acceptance/pages/studio/utils.py @@ -101,6 +101,18 @@ def add_component(page, item_type, specific_type, is_advanced_problem=False): page.wait_for_ajax() +def add_components(page, item_type, items, is_advanced_problem=False): + """ + Adds multiple components of a specific type. + item_type should be "advanced", "html", "problem", or "video" + items is a list of components of specific type to be added. + Please note that if you want to create an advanced problem + then all other items must be of advanced problem type. + """ + for item in items: + add_component(page, item_type, item, is_advanced_problem) + + def add_html_component(page, menu_index, boilerplate=None): """ Adds an instance of the HTML component with the specified name. diff --git a/common/test/acceptance/tests/studio/test_studio_components.py b/common/test/acceptance/tests/studio/test_studio_components.py index c4527cc631..5146f240c7 100644 --- a/common/test/acceptance/tests/studio/test_studio_components.py +++ b/common/test/acceptance/tests/studio/test_studio_components.py @@ -6,7 +6,8 @@ import ddt from .base_studio_test import ContainerBase from ...fixtures.course import XBlockFixtureDesc from ...pages.studio.container import ContainerPage -from ...pages.studio.utils import add_component +from ...pages.studio.utils import add_component, add_components +from common.test.acceptance.pages.studio.settings_advanced import AdvancedSettingsPage @ddt.ddt @@ -65,3 +66,119 @@ class AdvancedProblemComponentTest(ContainerBase): add_component(page, 'problem', component, is_advanced_problem=True) problem = page.xblocks[1] self.assertEqual(problem.name, component) + + +class ComponentTest(ContainerBase): + """ + Test class to add different components. + (Not the advanced components) + """ + def setUp(self, is_staff=True): + """ + Create a course with a section, subsection, and unit to which to add the component. + """ + super(ComponentTest, self).setUp(is_staff=is_staff) + self.advanced_settings = AdvancedSettingsPage( + self.browser, + self.course_info['org'], + self.course_info['number'], + self.course_info['run'] + ) + + def populate_course_fixture(self, course_fixture): + course_fixture.add_advanced_settings( + {u"advanced_modules": {"value": ["split_test"]}} + ) + + course_fixture.add_children( + XBlockFixtureDesc('chapter', 'Test Section').add_children( + XBlockFixtureDesc('sequential', 'Test Subsection').add_children( + XBlockFixtureDesc('vertical', 'Test Unit') + ) + ) + ) + + def test_add_html_component(self): + """ + Scenario: I can add HTML components + Given I am in Studio editing a new unit + When I add this type of HTML component: + | Component | + | Text | + | Announcement | + | Zooming Image Tool | + | Raw HTML | + Then I see HTML components in this order: + | Component | + | Text | + | Announcement | + | Zooming Image Tool | + | Raw HTML | + """ + # Components to be added + components = ['Text', 'Announcement', 'Zooming Image Tool', 'Raw HTML'] + self.go_to_unit_page() + container_page = ContainerPage(self.browser, None) + # Add components + add_components(container_page, 'html', components) + problems = [x_block.name for x_block in container_page.xblocks[1:]] + # Assert that components appear in same order as added. + self.assertEqual(problems, components) + + 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 test_common_problem_component(self): + """ + Scenario: I can add Common Problem components + Given I am in Studio editing a new unit + When I add this type of Problem component: + | Component |` + | Blank Common Problem | + | Checkboxes | + | Dropdown | + | Multiple Choice | + | Numerical Input | + | Text Input | + Then I see Problem components in this order: + | Component | + | Blank Common Problem | + | Checkboxes | + | Dropdown | + | Multiple Choice | + | Numerical Input | + | Text Input | + """ + # Components to be added. + components = ['Blank Common Problem', 'Checkboxes', 'Dropdown', + 'Multiple Choice', 'Numerical Input', 'Text Input'] + + self.go_to_unit_page() + container_page = ContainerPage(self.browser, None) + # Add components + add_components(container_page, 'problem', components) + problems = [x_block.name for x_block in container_page.xblocks[1:]] + # Assert that components appear in the same order as added. + self.assertEqual(problems, components)