Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
40af08aa
Commit
40af08aa
authored
Mar 11, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Saving tests in progress
parent
82a00104
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
139 deletions
+59
-139
cms/djangoapps/contentstore/features/advanced-settings.feature
+22
-42
cms/djangoapps/contentstore/features/advanced-settings.py
+37
-97
No files found.
cms/djangoapps/contentstore/features/advanced-settings.feature
View file @
40af08aa
...
@@ -2,53 +2,33 @@ Feature: Advanced (manual) course policy
...
@@ -2,53 +2,33 @@ Feature: Advanced (manual) course policy
In order to specify course policy settings for which no custom user interface exists
In order to specify course policy settings for which no custom user interface exists
I want to be able to manually enter JSON key/value pairs
I want to be able to manually enter JSON key/value pairs
Scenario
:
A
course author sees only display_name on a newly created course
# Scenario: A course author sees default advanced settings
Given
I have opened a new course in Studio
#
Given I have opened a new course in Studio
When
I select the Advanced Settings
#
When I select the Advanced Settings
Then
I see only the display name
# Then I see default advanced settings
@skip-phantom
Scenario
:
Test if there are no policy settings without existing UI controls
Given
I am on the Advanced Course Settings page in Studio
When
I delete the display name
Then
there are no advanced policy settings
And
I reload the page
Then
there are no advanced policy settings
@skip-phantom
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
# Scenario: Test cancel editing key value
Given
I am on the Advanced Course Settings page in Studio
# Given I am on the Advanced Course Settings page in Studio
When
I edit the value of a policy key
# When I edit the value of a policy key
And
I press the
"Cancel"
notification button
# And I press the "Cancel" notification button
Then
the policy key value is unchanged
# Then the policy key value is unchanged
#
@skip-phantom
Scenario
:
Test editing key value
Scenario
:
Test editing key value
Given
I am on the Advanced Course Settings page in Studio
Given
I am on the Advanced Course Settings page in Studio
When
I edit the value of a policy key
When
I edit the value of a policy key
And
I press the
"Save"
notification button
And
I press the
"Save"
notification button
Then
the policy key value is changed
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
Then
they are alphabetized
#
Then they are alphabetized
And
I reload the page
#
And I reload the page
Then
they are alphabetized
#
Then they are alphabetized
#
Scenario
:
Test how multi-line input appears
#
Scenario: Test how multi-line input appears
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 a JSON object
#
When I create a JSON object
Then
it is displayed as formatted
#
Then it is displayed as formatted
cms/djangoapps/contentstore/features/advanced-settings.py
View file @
40af08aa
...
@@ -20,7 +20,6 @@ def i_select_advanced_settings(step):
...
@@ -20,7 +20,6 @@ def i_select_advanced_settings(step):
css_click
(
expand_icon_css
)
css_click
(
expand_icon_css
)
link_css
=
'li.nav-course-settings-advanced a'
link_css
=
'li.nav-course-settings-advanced a'
css_click
(
link_css
)
css_click
(
link_css
)
# world.browser.click_link_by_text('Advanced Settings')
@step
(
'I am on the Advanced Course Settings page in Studio$'
)
@step
(
'I am on the Advanced Course Settings page in Studio$'
)
...
@@ -35,13 +34,6 @@ def reload_the_page(step):
...
@@ -35,13 +34,6 @@ def reload_the_page(step):
world
.
browser
.
reload
()
world
.
browser
.
reload
()
@step
(
u'I edit the name of a policy key$'
)
def
edit_the_name_of_a_policy_key
(
step
):
policy_key_css
=
'input.policy-key'
e
=
css_find
(
policy_key_css
)
.
first
e
.
type
(
'_new'
)
@step
(
u'I press the "([^"]*)" notification button$'
)
@step
(
u'I press the "([^"]*)" notification button$'
)
def
press_the_notification_button
(
step
,
name
):
def
press_the_notification_button
(
step
,
name
):
def
is_visible
(
driver
):
def
is_visible
(
driver
):
...
@@ -59,6 +51,11 @@ def press_the_notification_button(step, name):
...
@@ -59,6 +51,11 @@ def press_the_notification_button(step, name):
css_click_at
(
css
)
css_click_at
(
css
)
wait_for
(
is_invisible
)
wait_for
(
is_invisible
)
if
name
==
"Save"
:
css
=
""
wait_for
(
is_visible
)
@step
(
u'I edit the value of a policy key$'
)
@step
(
u'I edit the value of a policy key$'
)
def
edit_the_value_of_a_policy_key
(
step
):
def
edit_the_value_of_a_policy_key
(
step
):
"""
"""
...
@@ -66,23 +63,11 @@ def edit_the_value_of_a_policy_key(step):
...
@@ -66,23 +63,11 @@ def edit_the_value_of_a_policy_key(step):
area, so cheat and do it from the policy key field :)
area, so cheat and do it from the policy key field :)
"""
"""
policy_key_css
=
'input.policy-key'
policy_key_css
=
'input.policy-key'
e
=
css_find
(
policy_key_css
)
.
first
index
=
get_index_of
(
"display_name"
)
e
=
css_find
(
policy_key_css
)[
index
]
e
.
_element
.
send_keys
(
Keys
.
TAB
,
Keys
.
END
,
Keys
.
ARROW_LEFT
,
' '
,
'X'
)
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$'
)
def
create_new_entries
(
step
):
create_entry
(
"z"
,
"apple"
)
create_entry
(
"a"
,
"zebra"
)
click_save
()
@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"}'
)
...
@@ -90,19 +75,11 @@ def create_JSON_object(step):
...
@@ -90,19 +75,11 @@ def create_JSON_object(step):
############### RESULTS ####################
############### RESULTS ####################
@step
(
'I see only the display name$'
)
@step
(
'I see default advanced settings$'
)
def
i_see_only_display_name
(
step
):
def
i_see_default_advanced_settings
(
step
):
assert_policy_entries
([
"display_name"
],
[
'"Robot Super Course"'
])
# Test only a few of the existing properties (there are around 34 of them)
assert_policy_entries
(
[
"advanced_modules"
,
"display_name"
,
"show_calculator"
],
[
"[]"
,
'"Robot Super Course"'
,
"false"
],
False
)
@step
(
'there are no advanced policy settings$'
)
def
no_policy_settings
(
step
):
keys_css
=
'input.policy-key'
val_css
=
'textarea.json'
k
=
world
.
browser
.
is_element_not_present_by_css
(
keys_css
,
5
)
v
=
world
.
browser
.
is_element_not_present_by_css
(
val_css
,
5
)
assert_true
(
k
)
assert_true
(
v
)
@step
(
'they are alphabetized$'
)
@step
(
'they are alphabetized$'
)
...
@@ -114,77 +91,39 @@ def they_are_alphabetized(step):
...
@@ -114,77 +91,39 @@ def they_are_alphabetized(step):
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
}'
])
@step
(
u'the policy key name is unchanged$'
)
def
the_policy_key_name_is_unchanged
(
step
):
policy_key_css
=
'input.policy-key'
val
=
css_find
(
policy_key_css
)
.
first
.
value
assert_equal
(
val
,
'display_name'
)
@step
(
u'the policy key name is changed$'
)
def
the_policy_key_name_is_changed
(
step
):
policy_key_css
=
'input.policy-key'
val
=
css_find
(
policy_key_css
)
.
first
.
value
assert_equal
(
val
,
'display_name_new'
)
@step
(
u'the policy key value is unchanged$'
)
@step
(
u'the policy key value is unchanged$'
)
def
the_policy_key_value_is_unchanged
(
step
):
def
the_policy_key_value_is_unchanged
(
step
):
policy_value_css
=
'li.course-advanced-policy-list-item div.value textarea'
assert_equal
(
get_display_name_value
(),
'"Robot Super Course"'
)
val
=
css_find
(
policy_value_css
)
.
first
.
value
assert_equal
(
val
,
'"Robot Super Course"'
)
@step
(
u'the policy key value is changed$'
)
@step
(
u'the policy key value is changed$'
)
def
the_policy_key_value_is_unchanged
(
step
):
def
the_policy_key_value_is_changed
(
step
):
policy_value_css
=
'li.course-advanced-policy-list-item div.value textarea'
assert_equal
(
get_display_name_value
(),
'"Robot Super Course X"'
)
val
=
css_find
(
policy_value_css
)
.
first
.
value
assert_equal
(
val
,
'"Robot Super Course X"'
)
############# HELPERS ###############
############# HELPERS ###############
def
create_entry
(
key
,
value
):
def
assert_policy_entries
(
expected_keys
,
expected_values
,
assertLength
=
True
):
# Scroll down the page so the button is visible
key_css
=
'.key input.policy-key'
world
.
scroll_to_bottom
()
key_elements
=
css_find
(
key_css
)
css_click_at
(
'a.new-advanced-policy-item'
,
10
,
10
)
if
assertLength
:
new_key_css
=
'div#__new_advanced_key__ input'
assert_equal
(
len
(
expected_keys
),
len
(
key_elements
))
new_key_element
=
css_find
(
new_key_css
)
.
first
new_key_element
.
fill
(
key
)
# 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 fill does not remove existing text
new_value_css
=
'div.CodeMirror textarea'
css_find
(
new_value_css
)
.
last
.
fill
(
""
)
css_find
(
new_value_css
)
.
last
.
_element
.
send_keys
(
Keys
.
DELETE
,
Keys
.
DELETE
)
css_find
(
new_value_css
)
.
last
.
fill
(
value
)
# Add in a TAB key press because intermittently on ubuntu the
# last character of "value" above was not getting typed in
css_find
(
new_value_css
)
.
last
.
_element
.
send_keys
(
Keys
.
TAB
)
def
delete_entry
(
index
):
"""
Delete the nth entry where index is 0-based
"""
css
=
'a.delete-button'
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
delete_buttons
=
css_find
(
css
)
assert_true
(
len
(
delete_buttons
)
>
index
,
"no delete button exists for entry "
+
str
(
index
))
delete_buttons
[
index
]
.
click
()
value_css
=
'textarea.json'
for
counter
in
range
(
len
(
expected_keys
)):
index
=
get_index_of
(
expected_keys
[
counter
])
assert_false
(
index
==
-
1
,
"Could not find key: "
+
expected_keys
[
counter
])
assert_equal
(
expected_values
[
counter
],
css_find
(
value_css
)[
index
]
.
value
,
"value is incorrect"
)
def
assert_policy_entries
(
expected_keys
,
expected_values
):
assert_entries
(
'.key input.policy-key'
,
expected_keys
)
assert_entries
(
'textarea.json'
,
expected_values
)
def
get_index_of
(
expected_key
):
key_css
=
'.key input.policy-key'
for
counter
in
range
(
len
(
css_find
(
key_css
))):
# Sometimes get stale reference if I hold on to the array of elements
key
=
css_find
(
key_css
)[
counter
]
.
value
if
key
==
expected_key
:
return
counter
def
assert_entries
(
css
,
expected_values
):
return
-
1
webElements
=
css_find
(
css
)
assert_equal
(
len
(
expected_values
),
len
(
webElements
))
# Sometimes get stale reference if I hold on to the array of elements
for
counter
in
range
(
len
(
expected_values
)):
assert_equal
(
expected_values
[
counter
],
css_find
(
css
)[
counter
]
.
value
)
def
click_save
():
def
click_save
():
...
@@ -192,6 +131,7 @@ def click_save():
...
@@ -192,6 +131,7 @@ def click_save():
css_click_at
(
css
)
css_click_at
(
css
)
def
fill_last_field
(
value
):
def
get_display_name_value
():
newValue
=
css_find
(
'#__new_advanced_key__ input'
)
.
first
policy_value_css
=
'textarea.json'
newValue
.
fill
(
value
)
index
=
get_index_of
(
"display_name"
)
return
css_find
(
policy_value_css
)[
index
]
.
value
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment