From 46248c7006fc004aca5c4c998dbf00ad92781979 Mon Sep 17 00:00:00 2001 From: David Baumgold <david@davidbaumgold.com> Date: Mon, 3 Feb 2014 13:45:07 -0500 Subject: [PATCH] add lettuce test for displaying category if display_name is empty --- cms/djangoapps/contentstore/features/component.feature | 9 +++++++++ cms/djangoapps/contentstore/features/component.py | 12 +++++++++++- cms/djangoapps/contentstore/features/component_settings_editor_helpers.py | 16 ++++++++++++++++ cms/djangoapps/contentstore/features/problem-editor.py | 23 ++++------------------- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/cms/djangoapps/contentstore/features/component.feature b/cms/djangoapps/contentstore/features/component.feature index 1712aaa..90b8a8b 100644 --- a/cms/djangoapps/contentstore/features/component.feature +++ b/cms/djangoapps/contentstore/features/component.feature @@ -119,3 +119,12 @@ Feature: CMS.Component Adding Then I see the display name is "Text" When I change the display name to "I'm the Cuddliest!" Then I see the display name is "I'm the Cuddliest!" + + Scenario: If a component has no display name, the category is displayed + Given I am in Studio editing a new unit + When I add a "Blank Advanced Problem" "Advanced Problem" component + Then I see the display name is "Blank Advanced Problem" + When I change the display name to "" + Then I see the display name is "problem" + When I unset the display name + Then I see the display name is "Blank Advanced Problem" diff --git a/cms/djangoapps/contentstore/features/component.py b/cms/djangoapps/contentstore/features/component.py index 9d45cc1..59a1a30 100644 --- a/cms/djangoapps/contentstore/features/component.py +++ b/cms/djangoapps/contentstore/features/component.py @@ -8,6 +8,8 @@ from lettuce import world, step from nose.tools import assert_true, assert_in # pylint: disable=E0611 +DISPLAY_NAME = "Display Name" + @step(u'I add this type of single step component:$') def add_a_single_step_component(step): @@ -165,5 +167,13 @@ def check_component_display_name(step, display_name): @step(u'I change the display name to "([^"]*)"') def change_display_name(step, display_name): world.edit_component_and_select_settings() - world.css_fill("ul.settings-list li:first-child input", display_name) + index = world.get_setting_entry_index(DISPLAY_NAME) + world.set_field_value(index, display_name) + world.save_component(step) + + +@step(u'I unset the display name') +def unset_display_name(step): + world.edit_component_and_select_settings() + world.revert_setting_entry(DISPLAY_NAME) world.save_component(step) diff --git a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py index d3c0beb..46c7da2 100644 --- a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py +++ b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py @@ -5,6 +5,7 @@ from lettuce import world from nose.tools import assert_equal, assert_in # pylint: disable=E0611 from terrain.steps import reload_the_page from common import type_in_codemirror +from selenium.webdriver.common.keys import Keys @world.absorb @@ -219,3 +220,18 @@ def get_setting_entry_index(label): return index return None return world.retry_on_exception(get_index) + + +@world.absorb +def set_field_value(index, value): + """ + Set the field to the specified value. + + Note: we cannot use css_fill here because the value is not set + until after you move away from that field. + Instead we will find the element, set its value, then hit the Tab key + to get to the next field. + """ + elem = world.css_find('div.wrapper-comp-setting input.setting-input')[index] + elem.value = value + elem.type(Keys.TAB) diff --git a/cms/djangoapps/contentstore/features/problem-editor.py b/cms/djangoapps/contentstore/features/problem-editor.py index 2265b50..b52fdc6 100644 --- a/cms/djangoapps/contentstore/features/problem-editor.py +++ b/cms/djangoapps/contentstore/features/problem-editor.py @@ -7,7 +7,6 @@ from nose.tools import assert_equal, assert_true # pylint: disable=E0611 from common import type_in_codemirror, open_new_course from advanced_settings import change_value from course_import import import_file, go_to_import -from selenium.webdriver.common.keys import Keys DISPLAY_NAME = "Display Name" MAXIMUM_ATTEMPTS = "Maximum Attempts" @@ -53,7 +52,7 @@ def i_can_modify_the_display_name(_step): # Verifying that the display name can be a string containing a floating point value # (to confirm that we don't throw an error because it is of the wrong type). index = world.get_setting_entry_index(DISPLAY_NAME) - set_field_value(index, '3.4') + world.set_field_value(index, '3.4') verify_modified_display_name() @@ -66,7 +65,7 @@ def my_display_name_change_is_persisted_on_save(step): @step('I can specify special characters in the display name') def i_can_modify_the_display_name_with_special_chars(_step): index = world.get_setting_entry_index(DISPLAY_NAME) - set_field_value(index, "updated ' \" &") + world.set_field_value(index, "updated ' \" &") verify_modified_display_name_with_special_chars() @@ -141,7 +140,7 @@ def set_the_max_attempts(step, max_attempts_set): # on firefox with selenium, the behaviour is different. # eg 2.34 displays as 2.34 and is persisted as 2 index = world.get_setting_entry_index(MAXIMUM_ATTEMPTS) - set_field_value(index, max_attempts_set) + world.set_field_value(index, max_attempts_set) world.save_component_and_reopen(step) value = world.css_value('input.setting-input', index=index) assert value != "", "max attempts is blank" @@ -282,23 +281,9 @@ def verify_unset_display_name(): world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, 'Blank Advanced Problem', False) -def set_field_value(index, value): - """ - Set the field to the specified value. - - Note: we cannot use css_fill here because the value is not set - until after you move away from that field. - Instead we will find the element, set its value, then hit the Tab key - to get to the next field. - """ - elem = world.css_find('div.wrapper-comp-setting input.setting-input')[index] - elem.value = value - elem.type(Keys.TAB) - - def set_weight(weight): index = world.get_setting_entry_index(PROBLEM_WEIGHT) - set_field_value(index, weight) + world.set_field_value(index, weight) def open_high_level_source(): -- libgit2 0.26.0