From d9fb0673558cd98ddf57964b13a07ee6cf0ee8a6 Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 20 Feb 2013 15:34:53 -0500 Subject: [PATCH] Test point for formatting of JSON entry. --- .../features/advanced-settings.feature | 8 +++++++- .../contentstore/features/advanced-settings.py | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/features/advanced-settings.feature b/cms/djangoapps/contentstore/features/advanced-settings.feature index 4790c2eef7..6010977166 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.feature +++ b/cms/djangoapps/contentstore/features/advanced-settings.feature @@ -21,4 +21,10 @@ Feature: Advanced (manual) course policy And I create New Entries Then they are alphabetized And I reload the page - Then they are alphabetized \ No newline at end of file + Then they are alphabetized + + Scenario: Test how multi-line input appears + Given I have opened a new course in Studio + When I select the Advanced Settings + And I create a JSON object + Then it is displayed as formatted \ No newline at end of file diff --git a/cms/djangoapps/contentstore/features/advanced-settings.py b/cms/djangoapps/contentstore/features/advanced-settings.py index 5356a96739..9a428c5298 100644 --- a/cms/djangoapps/contentstore/features/advanced-settings.py +++ b/cms/djangoapps/contentstore/features/advanced-settings.py @@ -45,6 +45,19 @@ def create_new_entries(step): def they_are_alphabetized(step): assert_policy_entries(["a", "display_name", "z"], ['"zebra"', '"Robot Super Course"', '"apple"']) +@step('I create a JSON object$') +def create_JSON_object(step): + create_entry("json", '{"key": "value", "key_2": "value_2"}') + click_save() + +@step('it is displayed as formatted$') +def it_is_formatted(step): + assert_policy_entries(["display_name", "json"], ['"Robot Super Course"', '{\n "key": "value",\n "key_2": "value_2"\n}']) + +# TODO: this is copied from terrain's step.py. Need to figure out how to share that code. +@step('I reload the page$') +def reload_the_page(step): + world.browser.reload() def create_entry(key, value): css_click_at('a.new-advanced-policy-item') @@ -53,7 +66,8 @@ def create_entry(key, value): # For some reason have to get the instance for each command (get error that it is no longer attached to the DOM) # Have to do all this because Selenium has a bug that fill does not remove existing text css_find('.CodeMirror textarea').last.double_click() - css_find('.CodeMirror textarea').last._element.send_keys(Keys.ARROW_LEFT) + css_find('.CodeMirror textarea').last._element.send_keys(Keys.BACK_SPACE) + css_find('.CodeMirror textarea').last._element.send_keys(Keys.BACK_SPACE) css_find('.CodeMirror textarea').last.fill(value)