diff --git a/cms/djangoapps/contentstore/features/advanced-settings.feature b/cms/djangoapps/contentstore/features/advanced-settings.feature index 13600f2086..514eb8898e 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.feature +++ b/cms/djangoapps/contentstore/features/advanced-settings.feature @@ -46,3 +46,9 @@ Feature: Advanced (manual) course policy Then it is displayed as a string And I reload the page Then it is displayed as a string + + Scenario: Confirmation is shown on save + Given I am on the Advanced Course Settings page in Studio + When I edit the value of a policy key + And I press the "Save" notification button + Then I see a confirmation that my changes have been saved diff --git a/cms/djangoapps/contentstore/features/advanced-settings.py b/cms/djangoapps/contentstore/features/advanced-settings.py index 37d5c12ecc..c08216c8e6 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.py +++ b/cms/djangoapps/contentstore/features/advanced-settings.py @@ -2,8 +2,8 @@ #pylint: disable=W0621 from lettuce import world, step -from nose.tools import assert_false, assert_equal, assert_regexp_matches -from common import type_in_codemirror +from nose.tools import assert_false, assert_equal, assert_regexp_matches, assert_true +from common import type_in_codemirror, press_the_notification_button KEY_CSS = '.key input.policy-key' VALUE_CSS = 'textarea.json' @@ -25,20 +25,6 @@ def i_am_on_advanced_course_settings(step): step.given('I select the Advanced Settings') -@step(u'I press the "([^"]*)" notification button$') -def press_the_notification_button(step, name): - css = 'a.action-%s' % name.lower() - - # Save was clicked if either the save notification bar is gone, or we have a error notification - # overlaying it (expected in the case of typing Object into display_name). - def save_clicked(): - confirmation_dismissed = world.is_css_not_present('.is-shown.wrapper-notification-warning') - error_showing = world.is_css_present('.is-shown.wrapper-notification-error') - return confirmation_dismissed or error_showing - - world.css_click(css, success_condition=save_clicked) - - @step(u'I edit the value of a policy key$') def edit_the_value_of_a_policy_key(step): type_in_codemirror(get_index_of(DISPLAY_NAME_KEY), 'X') diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index a65ad3a08f..d7ac27089e 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -12,6 +12,8 @@ import time from logging import getLogger logger = getLogger(__name__) +from terrain.browser import reset_data + _COURSE_NAME = 'Robot Super Course' _COURSE_NUM = '999' _COURSE_ORG = 'MITx' @@ -54,11 +56,41 @@ def i_press_the_category_delete_icon(_step, category): def i_have_opened_a_new_course(_step): open_new_course() +@step(u'I press the "([^"]*)" notification button$') +def press_the_notification_button(step, name): + css = 'a.action-%s' % name.lower() -@step('I (save|cancel) my changes$') -def save_changes(step, action): - button_css = '.action-%s' % action - world.css_click(button_css) + # Save was clicked if either the save notification bar is gone, or we have a error notification + # overlaying it (expected in the case of typing Object into display_name). + def save_clicked(): + confirmation_dismissed = world.is_css_not_present('.is-shown.wrapper-notification-warning') + error_showing = world.is_css_present('.is-shown.wrapper-notification-error') + return confirmation_dismissed or error_showing + + assert_true(world.css_click(css, success_condition=save_clicked), 'Save button not clicked after 5 attempts.') + + +@step('I change the "(.*)" field to "(.*)"$') +def i_change_field_to_value(step, field, value): + # Special casing this because we should type into CodeMirror + field_css = '#%s' % '-'.join([s.lower() for s in field.split()]) + if field_css == '#course-overview': + type_in_codemirror(0, value) + else: + ele = world.css_find(field_css).first + ele.fill(value) + ele._element.send_keys(Keys.ENTER) + + +@step('I reset the database') +def reset_the_db(step): + reset_data(None) + + +@step('I see a confirmation that my changes have been saved') +def i_see_a_confirmation(step): + confirmation_css = '#alert-confirmation' + assert world.is_css_present(confirmation_css) ####### HELPER FUNCTIONS ############## diff --git a/cms/djangoapps/contentstore/features/course-settings.feature b/cms/djangoapps/contentstore/features/course-settings.feature index 41ee99336d..9307cbe719 100644 --- a/cms/djangoapps/contentstore/features/course-settings.feature +++ b/cms/djangoapps/contentstore/features/course-settings.feature @@ -5,18 +5,18 @@ Feature: Course Settings Given I have opened a new course in Studio When I select Schedule and Details And I set course dates - And I save my changes + And I press the "Save" notification button Then I see the set dates on refresh Scenario: User can clear previously set course dates (except start date) Given I have set course dates And I clear all the dates except start - And I save my changes + And I press the "Save" notification button Then I see cleared dates on refresh Scenario: User cannot clear the course start date Given I have set course dates - And I save my changes + And I press the "Save" notification button And I clear the course start date Then I receive a warning about course start date And The previously set start date is shown on refresh @@ -24,13 +24,31 @@ Feature: Course Settings Scenario: User can correct the course start date warning Given I have tried to clear the course start And I have entered a new course start date - And I save my changes + And I press the "Save" notification button Then The warning about course start date goes away And My new course start date is shown on refresh Scenario: Settings are only persisted when saved Given I have set course dates - And I save my changes + And I press the "Save" notification button When I change fields - And I cancel my changes + And I press the "Cancel" notification button Then I do not see the new changes persisted on refresh + + Scenario: Confirmation is shown on save + Given I have opened a new course in Studio + When I select Schedule and Details + And I change the "" field to "" + And I press the "Save" notification button + Then I see a confirmation that my changes have been saved + # Lettuce hooks don't get called between each example, so we need + # to run the before.each_scenario hook manually to avoid database + # errors. + And I reset the database + + Examples: + | field | value | + | Course Start Time | 11:00 | + | Course Overview |

Overview

| + | Course Introduction Video | 4r7wHMg5Yjg | + | Course Effort | 200:00 | diff --git a/cms/djangoapps/contentstore/features/course-settings.py b/cms/djangoapps/contentstore/features/course-settings.py index bcf260de23..85a11ec9ec 100644 --- a/cms/djangoapps/contentstore/features/course-settings.py +++ b/cms/djangoapps/contentstore/features/course-settings.py @@ -4,6 +4,7 @@ from lettuce import world, step from terrain.steps import reload_the_page from selenium.webdriver.common.keys import Keys +from common import type_in_codemirror import time from nose.tools import assert_true, assert_false, assert_equal diff --git a/cms/djangoapps/contentstore/features/grading.feature b/cms/djangoapps/contentstore/features/grading.feature index 3736582f39..1526c17d9f 100644 --- a/cms/djangoapps/contentstore/features/grading.feature +++ b/cms/djangoapps/contentstore/features/grading.feature @@ -32,7 +32,7 @@ Feature: Course Grading And I have populated the course And I am viewing the grading settings When I change assignment type "Homework" to "New Type" - And I save my changes + And I press the "Save" notification button And I go back to the main course page Then I do see the assignment name "New Type" And I do not see the assignment name "Homework" @@ -42,6 +42,7 @@ Feature: Course Grading And I have populated the course And I am viewing the grading settings When I delete the assignment type "Homework" + And I press the "Save" notification button And I go back to the main course page Then I do not see the assignment name "Homework" @@ -50,7 +51,7 @@ Feature: Course Grading And I have populated the course And I am viewing the grading settings When I add a new assignment type "New Type" - And I save my changes + And I press the "Save" notification button And I go back to the main course page Then I do see the assignment name "New Type" @@ -59,5 +60,22 @@ Feature: Course Grading And I have populated the course And I am viewing the grading settings When I change assignment type "Homework" to "New Type" - And I cancel my changes + And I press the "Cancel" notification button Then I do not see the changes persisted on refresh + + Scenario: Confirmation is shown on save + Given I have opened a new course in Studio + And I have populated the course + And I am viewing the grading settings + When I change the "" field to "" + And I press the "Save" notification button + Then I see a confirmation that my changes have been saved + # Lettuce hooks don't get called between each example, so we need + # to run the before.each_scenario hook manually to avoid database + # errors. + And I reset the database + + Examples: + | field | value | + | Course Grading Graceperiod | 1:00 | + | Course Grading Assignment Name | New Assignment Name |