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
2cf71b7f
Commit
2cf71b7f
authored
Jun 14, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper method for typing in CodeMirror, make it robust to Mac and Unix.
parent
21dc4d86
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
25 deletions
+58
-25
cms/djangoapps/contentstore/features/advanced-settings.py
+3
-21
cms/djangoapps/contentstore/features/common.py
+12
-0
cms/djangoapps/contentstore/features/problem-editor.feature
+6
-0
cms/djangoapps/contentstore/features/problem-editor.py
+31
-4
common/djangoapps/terrain/ui_helpers.py
+6
-0
No files found.
cms/djangoapps/contentstore/features/advanced-settings.py
View file @
2cf71b7f
...
...
@@ -3,11 +3,7 @@
from
lettuce
import
world
,
step
from
nose.tools
import
assert_false
,
assert_equal
,
assert_regexp_matches
"""
http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver/selenium.webdriver.common.keys.html
"""
from
selenium.webdriver.common.keys
import
Keys
from
common
import
type_in_codemirror
KEY_CSS
=
'.key input.policy-key'
VALUE_CSS
=
'textarea.json'
...
...
@@ -37,13 +33,7 @@ def press_the_notification_button(step, 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 :)
"""
world
.
css_find
(
".CodeMirror"
)[
get_index_of
(
DISPLAY_NAME_KEY
)]
.
click
()
g
=
world
.
css_find
(
"div.CodeMirror.CodeMirror-focused > div > textarea"
)
g
.
_element
.
send_keys
(
Keys
.
ARROW_LEFT
,
' '
,
'X'
)
type_in_codemirror
(
get_index_of
(
DISPLAY_NAME_KEY
),
'X'
)
@step
(
u'I edit the value of a policy key and save$'
)
...
...
@@ -132,13 +122,5 @@ def change_display_name_value(step, new_value):
def
change_value
(
step
,
key
,
new_value
):
index
=
get_index_of
(
key
)
world
.
css_find
(
".CodeMirror"
)[
index
]
.
click
()
g
=
world
.
css_find
(
"div.CodeMirror.CodeMirror-focused > div > textarea"
)
current_value
=
world
.
css_find
(
VALUE_CSS
)[
index
]
.
value
g
.
_element
.
send_keys
(
Keys
.
CONTROL
+
Keys
.
END
)
for
count
in
range
(
len
(
current_value
)):
g
.
_element
.
send_keys
(
Keys
.
END
,
Keys
.
BACK_SPACE
)
# Must delete "" before typing the JSON value
g
.
_element
.
send_keys
(
Keys
.
END
,
Keys
.
BACK_SPACE
,
Keys
.
BACK_SPACE
,
new_value
)
type_in_codemirror
(
get_index_of
(
key
),
new_value
)
press_the_notification_button
(
step
,
"Save"
)
cms/djangoapps/contentstore/features/common.py
View file @
2cf71b7f
...
...
@@ -169,3 +169,14 @@ def open_new_unit(step):
step
.
given
(
'I have added a new subsection'
)
step
.
given
(
'I expand the first section'
)
world
.
css_click
(
'a.new-unit-item'
)
def
type_in_codemirror
(
index
,
text
):
world
.
css_find
(
".CodeMirror"
)[
index
]
.
click
()
g
=
world
.
css_find
(
"div.CodeMirror.CodeMirror-focused > div > textarea"
)
if
world
.
is_mac
():
g
.
_element
.
send_keys
(
Keys
.
COMMAND
+
'a'
)
else
:
g
.
_element
.
send_keys
(
Keys
.
CONTROL
+
'a'
)
g
.
_element
.
send_keys
(
Keys
.
DELETE
)
g
.
_element
.
send_keys
(
text
)
\ No newline at end of file
cms/djangoapps/contentstore/features/problem-editor.feature
View file @
2cf71b7f
...
...
@@ -65,3 +65,9 @@ Feature: Problem Editor
Given
I have created a LaTeX Problem
And
I edit and select Settings
Then
Edit High Level Source is visible
Scenario
:
High Level source is persisted for LaTeX problem (bug STUD-280)
Given
I have created a LaTeX Problem
And
I edit the High Level Source
Then
my change to the High Level Source is persisted
And
when I view the High Level Source I see my changes
cms/djangoapps/contentstore/features/problem-editor.py
View file @
2cf71b7f
...
...
@@ -3,6 +3,7 @@
from
lettuce
import
world
,
step
from
nose.tools
import
assert_equal
from
common
import
type_in_codemirror
DISPLAY_NAME
=
"Display Name"
MAXIMUM_ATTEMPTS
=
"Maximum Attempts"
...
...
@@ -135,12 +136,12 @@ def set_the_max_attempts(step, max_attempts_set, max_attempts_displayed, max_att
@step
(
'Edit High Level Source is not visible'
)
def
edit_high_level_source_not_visible
(
step
):
verify_high_level_source
(
step
,
False
)
verify_high_level_source
_links
(
step
,
False
)
@step
(
'Edit High Level Source is visible'
)
def
edit_high_level_source_visible
(
step
):
verify_high_level_source
(
step
,
True
)
def
edit_high_level_source_
links_
visible
(
step
):
verify_high_level_source
_links
(
step
,
True
)
@step
(
'If I press Cancel my changes are not persisted'
)
...
...
@@ -159,7 +160,33 @@ def create_latex_problem(step):
world
.
click_component_from_menu
(
"i4x://edx/templates/problem/Problem_Written_in_LaTeX"
,
'.xmodule_CapaModule'
)
def
verify_high_level_source
(
step
,
visible
):
@step
(
'I edit the High Level Source'
)
def
edit_latex_source
(
step
):
world
.
css_click
(
'a.edit-button'
)
world
.
css_find
(
'.launch-latex-compiler'
)
.
find_by_css
(
'a'
)
.
click
()
# Without the wait, the second code mirror is not yet clickable.
world
.
wait
(
1
)
type_in_codemirror
(
1
,
"hi"
)
world
.
css_click
(
'.hls-compile'
)
@step
(
'my change to the High Level Source is persisted'
)
def
high_level_source_persisted
(
step
):
def
verify_text
(
driver
):
return
world
.
css_find
(
'.problem'
)
.
text
==
'hi'
world
.
wait_for
(
verify_text
)
@step
(
'I view the High Level Source I see my changes'
)
def
high_level_source_in_editor
(
step
):
world
.
css_click
(
'a.edit-button'
)
world
.
css_find
(
'.launch-latex-compiler'
)
.
find_by_css
(
'a'
)
.
click
()
world
.
wait
(
2
)
assert_equal
(
'hi'
,
world
.
css_find
(
'.source-edit-box'
)
.
value
)
def
verify_high_level_source_links
(
step
,
visible
):
assert_equal
(
visible
,
world
.
is_css_present
(
'.launch-latex-compiler'
))
world
.
cancel_component
(
step
)
assert_equal
(
visible
,
world
.
is_css_present
(
'.upload-button'
))
...
...
common/djangoapps/terrain/ui_helpers.py
View file @
2cf71b7f
...
...
@@ -3,6 +3,7 @@
from
lettuce
import
world
import
time
import
platform
from
urllib
import
quote_plus
from
selenium.common.exceptions
import
WebDriverException
,
StaleElementReferenceException
from
selenium.webdriver.support
import
expected_conditions
as
EC
...
...
@@ -158,3 +159,8 @@ def click_tools():
tools_css
=
'li.nav-course-tools'
if
world
.
browser
.
is_element_present_by_css
(
tools_css
):
world
.
css_click
(
tools_css
)
@world.absorb
def
is_mac
():
return
platform
.
mac_ver
()[
0
]
is
not
''
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