Commit 71a048a6 by Brian Jacobel

Add bok choy tests for discussions editor preview pane

parent d347492c
...@@ -723,3 +723,17 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin): ...@@ -723,3 +723,17 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
""" """
elements = self.q(css=".forum-new-post-form") elements = self.q(css=".forum-new-post-form")
return elements[0] if elements.visible and len(elements) == 1 else None 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]
...@@ -838,6 +838,40 @@ class DiscussionCommentEditTest(BaseDiscussionTestCase): ...@@ -838,6 +838,40 @@ class DiscussionCommentEditTest(BaseDiscussionTestCase):
@attr(shard=2) @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): class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMixin):
""" """
Tests for inline discussions Tests for inline discussions
......
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