EDUCATOR-283 Old mathjax not load in preview box.

This commit is contained in:
attiyaishaque
2017-05-08 18:43:57 +05:00
parent 424d3b40bf
commit 9188dbdb47
3 changed files with 25 additions and 4 deletions

View File

@@ -202,7 +202,7 @@
var $general;
this.$('.forum-new-post-form')[0].reset();
DiscussionUtil.clearFormErrors(this.$('.post-errors'));
this.$('.wmd-preview p').html('');
this.$('.wmd-preview').html('');
if (this.isTabMode()) {
$general = this.$('.post-topic option:contains(General)');
this.topicView.setTopic($general || this.$('button.topic-title').first());

View File

@@ -718,12 +718,12 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
"""
self.q(css=".wmd-input").fill(new_body)
def get_new_post_preview_value(self):
def get_new_post_preview_value(self, selector=".wmd-preview > *"):
"""
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)
self.wait_for_element_visibility(selector, "WMD preview pane has contents", timeout=10)
return self.q(css=".wmd-preview").html[0]
def get_new_post_preview_text(self):

View File

@@ -11,7 +11,7 @@ from pytz import UTC
from flaky import flaky
from common.test.acceptance.tests.discussion.helpers import BaseDiscussionTestCase
from common.test.acceptance.tests.helpers import UniqueCourseTest
from common.test.acceptance.tests.helpers import UniqueCourseTest, get_modal_alert
from common.test.acceptance.pages.lms.auto_auth import AutoAuthPage
from common.test.acceptance.pages.lms.courseware import CoursewarePage
from common.test.acceptance.pages.lms.discussion import (
@@ -997,6 +997,27 @@ class DiscussionEditorPreviewTest(UniqueCourseTest):
self.assertEqual(self.page.get_new_post_preview_text(), 'Text line 1\nText line 2')
def test_mathjax_not_rendered_after_post_cancel(self):
"""
Tests that mathjax is not rendered when we cancel the post
When user types the mathjax expression into discussion editor, it will appear in te preview
box, and when user cancel it and again click the "Add new post" button, mathjax will not
appear in the preview box
"""
self.page.set_new_post_editor_value(
'\\begin{equation}'
'\\tau_g(\omega) = - \\frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) '
'\\end{equation}'
)
self.assertIsNotNone(self.page.get_new_post_preview_text())
self.page.click_element(".cancel")
alert = get_modal_alert(self.browser)
alert.accept()
self.assertIsNotNone(self.page.new_post_button)
self.page.click_new_post_button()
self.assertEqual(self.page.get_new_post_preview_value('.wmd-preview'), "")
@attr(shard=2)
class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMixin):