Commit 3a6f43f3 by Jay Zoldak

Create additional BDD spec tests for Course Advanced Settings editor

parent 85b75bad
...@@ -14,6 +14,30 @@ Feature: Advanced (manual) course policy ...@@ -14,6 +14,30 @@ Feature: Advanced (manual) course policy
And I reload the page And I reload the page
Then there are no advanced policy settings Then there are no advanced policy settings
Scenario: Test cancel editing key name
Given I am on the Advanced Course Settings page in Studio
When I edit the name of a policy key
And I press the "Cancel" notification button
Then the policy key name is unchanged
Scenario: Test editing key name
Given I am on the Advanced Course Settings page in Studio
When I edit the name of a policy key
And I press the "Save" notification button
Then the policy key name is changed
Scenario: Test cancel editing key value
Given I am on the Advanced Course Settings page in Studio
When I edit the value of a policy key
And I press the "Cancel" notification button
Then the policy key value is unchanged
Scenario: Test editing key value
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 the policy key value is changed
Scenario: Add new entries, and they appear alphabetically after save Scenario: Add new entries, and they appear alphabetically after save
Given I am on the Advanced Course Settings page in Studio Given I am on the Advanced Course Settings page in Studio
When I create New Entries When I create New Entries
......
...@@ -5,6 +5,9 @@ import time ...@@ -5,6 +5,9 @@ import time
from nose.tools import assert_equal from nose.tools import assert_equal
from nose.tools import assert_true from nose.tools import assert_true
"""
http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver/selenium.webdriver.common.keys.html
"""
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
...@@ -24,20 +27,39 @@ def i_am_on_advanced_course_settings(step): ...@@ -24,20 +27,39 @@ def i_am_on_advanced_course_settings(step):
step.given('I select the Advanced Settings') step.given('I select the Advanced Settings')
@step('I see only the display name$') # TODO: this is copied from terrain's step.py. Need to figure out how to share that code.
def i_see_only_display_name(step): @step('I reload the page$')
assert_policy_entries(["display_name"], ['"Robot Super Course"']) def reload_the_page(step):
world.browser.reload()
@step('I delete the display name') @step(u'I edit the name of a policy key$')
def i_delete_the_display_name(step): def edit_the_name_of_a_policy_key(step):
delete_entry(0) policy_key_css = 'input.policy-key'
click_save() e = css_find(policy_key_css).first
e.fill('new')
@step('there are no advanced policy settings$') @step(u'I press the "([^"]*)" notification button$')
def no_policy_settings(step): def press_the_notification_button(step, name):
assert_policy_entries([], []) world.browser.click_link_by_text(name)
@step(u'I edit the value of a policy key$')
def edit_the_value_of_a_policy_key(step):
"""
It is hard to figure out how to get into the CodeMirror
area, so cheat and do it from the policy key field :)
"""
policy_key_css = 'input.policy-key'
e = css_find(policy_key_css).first
e._element.send_keys(Keys.TAB, Keys.END, Keys.ARROW_LEFT, ' ', 'X')
@step('I delete the display name$')
def delete_the_display_name(step):
delete_entry(0)
click_save()
@step('create New Entries$') @step('create New Entries$')
...@@ -47,28 +69,62 @@ def create_new_entries(step): ...@@ -47,28 +69,62 @@ def create_new_entries(step):
click_save() click_save()
@step('they are alphabetized$')
def they_are_alphabetized(step):
assert_policy_entries(["a", "display_name", "z"], ['"zebra"', '"Robot Super Course"', '"apple"'])
@step('I create a JSON object$') @step('I create a JSON object$')
def create_JSON_object(step): def create_JSON_object(step):
create_entry("json", '{"key": "value", "key_2": "value_2"}') create_entry("json", '{"key": "value", "key_2": "value_2"}')
click_save() click_save()
############### RESULTS ####################
@step('I see only the display name$')
def i_see_only_display_name(step):
assert_policy_entries(["display_name"], ['"Robot Super Course"'])
@step('there are no advanced policy settings$')
def no_policy_settings(step):
assert_policy_entries([], [])
@step('they are alphabetized$')
def they_are_alphabetized(step):
assert_policy_entries(["a", "display_name", "z"], ['"zebra"', '"Robot Super Course"', '"apple"'])
@step('it is displayed as formatted$') @step('it is displayed as formatted$')
def it_is_formatted(step): def it_is_formatted(step):
assert_policy_entries(["display_name", "json"], ['"Robot Super Course"', '{\n "key": "value",\n "key_2": "value_2"\n}']) 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(u'the policy key name is unchanged$')
@step('I reload the page$') def the_policy_key_name_is_unchanged(step):
def reload_the_page(step): policy_key_css = 'input.policy-key'
world.browser.reload() e = css_find(policy_key_css).first
assert_equal(e.value, 'display_name')
@step(u'the policy key name is changed$')
def the_policy_key_name_is_changed(step):
policy_key_css = 'input.policy-key'
e = css_find(policy_key_css).first
assert_equal(e.value, 'new')
@step(u'the policy key value is unchanged$')
def the_policy_key_value_is_unchanged(step):
policy_value_css = 'li.course-advanced-policy-list-item div.value textarea'
e = css_find(policy_value_css).first
assert_equal(e.value, '"Robot Super Course"')
@step(u'the policy key value is changed$')
def the_policy_key_value_is_unchanged(step):
policy_value_css = 'li.course-advanced-policy-list-item div.value textarea'
e = css_find(policy_value_css).first
assert_equal(e.value, '"Robot Super Course X"')
############# HELPERS ###############
def create_entry(key, value): def create_entry(key, value):
# Scroll down the page so the button is visible # Scroll down the page so the button is visible
world.scroll_to_bottom() world.scroll_to_bottom()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment