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
add4d3bc
Commit
add4d3bc
authored
Aug 12, 2016
by
Brian Jacobel
Committed by
GitHub
Aug 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13214 from edx/bjacobel/TNL-5198
Fix discussion markdown previews
parents
09ae2fc0
71a048a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletions
+50
-1
common/static/common/js/discussion/utils.js
+2
-1
common/test/acceptance/pages/lms/discussion.py
+14
-0
common/test/acceptance/tests/discussion/test_discussion.py
+34
-0
No files found.
common/static/common/js/discussion/utils.js
View file @
add4d3bc
...
...
@@ -321,7 +321,8 @@
imageUploadUrl
=
this
.
urlFor
(
'upload'
);
_processor
=
function
(
self
)
{
return
function
(
text
)
{
return
self
.
postMathJaxProcessor
(
text
);
// HTML returned by Markdown is assumed to be safe to render
return
self
.
postMathJaxProcessor
(
edx
.
HtmlUtils
.
HTML
(
text
)).
toString
();
};
};
editor
=
Markdown
.
makeWmdEditor
(
elem
,
appended_id
,
imageUploadUrl
,
_processor
(
this
));
...
...
common/test/acceptance/pages/lms/discussion.py
View file @
add4d3bc
...
...
@@ -723,3 +723,17 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
"""
elements
=
self
.
q
(
css
=
".forum-new-post-form"
)
return
elements
[
0
]
if
elements
.
visible
and
len
(
elements
)
==
1
else
None
def
set_new_post_editor_value
(
self
,
new_body
):
"""
Set the Discussions new post editor (wmd) with the content in new_body
"""
self
.
q
(
css
=
".wmd-input"
)
.
fill
(
new_body
)
def
get_new_post_preview_value
(
self
):
"""
Get the rendered preview of the contents of the Discussions new post editor
Waits for content to appear, as the preview is triggered on debounced/delayed onchange
"""
self
.
wait_for_element_visibility
(
".wmd-preview > *"
,
"WMD preview pane has contents"
,
timeout
=
10
)
return
self
.
q
(
css
=
".wmd-preview"
)
.
html
[
0
]
common/test/acceptance/tests/discussion/test_discussion.py
View file @
add4d3bc
...
...
@@ -838,6 +838,40 @@ class DiscussionCommentEditTest(BaseDiscussionTestCase):
@attr
(
shard
=
2
)
class
DiscussionEditorPreviewTest
(
UniqueCourseTest
):
def
setUp
(
self
):
super
(
DiscussionEditorPreviewTest
,
self
)
.
setUp
()
CourseFixture
(
**
self
.
course_info
)
.
install
()
AutoAuthPage
(
self
.
browser
,
course_id
=
self
.
course_id
)
.
visit
()
self
.
page
=
DiscussionTabHomePage
(
self
.
browser
,
self
.
course_id
)
self
.
page
.
visit
()
self
.
page
.
click_new_post_button
()
def
test_text_rendering
(
self
):
"""When I type plain text into the editor, it should be rendered as plain text in the preview box"""
self
.
page
.
set_new_post_editor_value
(
"Some plain text"
)
self
.
assertEqual
(
self
.
page
.
get_new_post_preview_value
(),
"<p>Some plain text</p>"
)
def
test_markdown_rendering
(
self
):
"""When I type Markdown into the editor, it should be rendered as formatted Markdown in the preview box"""
self
.
page
.
set_new_post_editor_value
(
"Some markdown
\n
"
"
\n
"
"- line 1
\n
"
"- line 2"
)
self
.
assertEqual
(
self
.
page
.
get_new_post_preview_value
(),
(
"<p>Some markdown</p>
\n
"
"
\n
"
"<ul>
\n
"
"<li>line 1</li>
\n
"
"<li>line 2</li>
\n
"
"</ul>"
))
@attr
(
shard
=
2
)
class
InlineDiscussionTest
(
UniqueCourseTest
,
DiscussionResponsePaginationTestMixin
):
"""
Tests for inline discussions
...
...
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