From 57f8bbf69dddd55e7168fb6ccb65ea3567163e0d Mon Sep 17 00:00:00 2001 From: cahrens Date: Fri, 31 May 2013 11:26:31 -0400 Subject: [PATCH] Updates to Selenium test based on feedback. --- .../features/problem-editor.feature | 10 +++--- .../contentstore/features/problem-editor.py | 34 ++++++++----------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/cms/djangoapps/contentstore/features/problem-editor.feature b/cms/djangoapps/contentstore/features/problem-editor.feature index 001ca09dcb..6ed8c1619b 100644 --- a/cms/djangoapps/contentstore/features/problem-editor.feature +++ b/cms/djangoapps/contentstore/features/problem-editor.feature @@ -35,29 +35,29 @@ Feature: Problem Editor Scenario: User can modify float input values Given I have created a Blank Common Problem And I edit and select Settings - Then I can set the weight to 3.5 + Then I can set the weight to "3.5" And my change to weight is persisted And I can revert to the default value of unset for weight Scenario: User cannot type letters in float number field Given I have created a Blank Common Problem And I edit and select Settings - Then if I set the weight to abc, it remains unset + Then if I set the weight to "abc", it remains unset Scenario: User cannot type decimal values integer number field Given I have created a Blank Common Problem And I edit and select Settings - Then if I set the max attempts to 2.34, the max attempts are persisted as 234 + Then if I set the max attempts to "2.34", it displays initially as "234", and is persisted as "234" Scenario: User cannot type out of range values in an integer number field Given I have created a Blank Common Problem And I edit and select Settings - Then if I set the max attempts to -3, the max attempts are persisted as 1 + Then if I set the max attempts to "-3", it displays initially as "-3", and is persisted as "1" Scenario: Settings changes are not saved on Cancel Given I have created a Blank Common Problem And I edit and select Settings - Then I can set the weight to 3.5 + Then I can set the weight to "3.5" And I can modify the display name Then If I press Cancel my changes are not persisted diff --git a/cms/djangoapps/contentstore/features/problem-editor.py b/cms/djangoapps/contentstore/features/problem-editor.py index bf71094316..5dfcf55046 100644 --- a/cms/djangoapps/contentstore/features/problem-editor.py +++ b/cms/djangoapps/contentstore/features/problem-editor.py @@ -94,9 +94,9 @@ def i_can_revert_to_default_for_randomization(step): world.verify_setting_entry(world.get_setting_entry(RANDOMIZATION), RANDOMIZATION, "Always", False) -@step('I can set the weight to 3.5') -def i_can_set_weight_to_3_5(step): - world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill('3.5') +@step('I can set the weight to "(.*)"?') +def i_can_set_weight(step, weight): + set_weight(weight) verify_modified_weight() @@ -113,9 +113,9 @@ def i_can_revert_to_default_for_unset_weight(step): world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", False) -@step('if I set the weight to abc, it remains unset') -def set_the_weight_to_abc(step): - world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill('abc') +@step('if I set the weight to "(.*)", it remains unset') +def set_the_weight_to_abc(step, bad_weight): + set_weight(bad_weight) # We show the clear button immediately on type, hence the "True" here. world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", True) world.save_component_and_reopen(step) @@ -123,20 +123,12 @@ def set_the_weight_to_abc(step): world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", False) -@step('if I set the max attempts to 2.34, the max attempts are persisted as 234') -def set_the_max_attempts_234(step): - world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill('2.34') - world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "234", True) +@step('if I set the max attempts to "(.*)", it displays initially as "(.*)", and is persisted as "(.*)"') +def set_the_max_attempts(step, max_attempts_set, max_attempts_displayed, max_attempts_persisted): + world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill(max_attempts_set) + world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, max_attempts_displayed, True) world.save_component_and_reopen(step) - world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "234", True) - - -@step('I set the max attempts to -3, the max attempts are persisted as 1') -def set_max_attempts_to_neg_3(step): - world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill('-3') - world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "-3", True) - world.save_component_and_reopen(step) - world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "1", True) + world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, max_attempts_persisted, True) @step('Edit High Level Source is not visible') @@ -189,3 +181,7 @@ def verify_modified_display_name_with_special_chars(): def verify_unset_display_name(): world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, '', False) + + +def set_weight(weight): + world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill(weight)