Commit 663ccf7d by Awais Jibran

Merge pull request #690 from edx/aj/tnl1755-fix-latex-button-on-ORA

'Preview in Latex' was not working in ORA.
parents 2911bc00 349570d7
......@@ -96,7 +96,7 @@ OpenAssessment.ResponseView.prototype = {
function(eventObject) {
eventObject.preventDefault();
// extract typed-in response and replace newline with br
var preview_text = sel.find('#submission__answer__value').val();
var preview_text = sel.find('.submission__answer__part__text__value').val();
var preview_container = sel.find('#preview_content');
preview_container.html(preview_text.replace(/\r\n|\r|\n/g,"<br />"));
......
......@@ -71,10 +71,36 @@ class SubmissionPage(OpenAssessmentPage):
BrokenPromise: The response was not submitted successfully.
"""
self.q(css="textarea#submission__answer__value").fill(response_text)
self.wait_for_element_visibility("textarea.submission__answer__part__text__value", "Textarea is present")
self.q(css="textarea.submission__answer__part__text__value").fill(response_text)
self.submit()
EmptyPromise(lambda: self.has_submitted, 'Response is completed').fulfill()
def fill_latex(self, latex_query):
"""
Fill the latex expression
Args:
latex_query (unicode): Latex expression text
"""
self.wait_for_element_visibility("textarea.submission__answer__part__text__value", "Textarea is present")
self.q(css="textarea.submission__answer__part__text__value").fill(latex_query)
def preview_latex(self):
# Click 'Preview in Latex' button on the page.
self.q(css="button#submission__preview").click()
self.wait_for_element_visibility("#preview_content .MathJax", "Verify Preview Latex expression")
@property
def latex_preview_button_is_disabled(self):
"""
Check if 'Preview in Latex' button is disabled
Returns:
bool
"""
preview_latex_button_class = self.q(css="button#submission__preview").attrs('class')
return 'is--disabled' in preview_latex_button_class
@property
def has_submitted(self):
"""
......
......@@ -55,6 +55,7 @@ class OpenAssessmentTest(WebAppTest):
}
SUBMISSION = u"This is a test submission."
LATEX_SUBMISSION = u"[mathjaxinline]( \int_{0}^{1}xdx \)[/mathjaxinline]"
OPTIONS_SELECTED = [1, 2]
EXPECTED_SCORE = 6
......@@ -106,6 +107,20 @@ class SelfAssessmentTest(OpenAssessmentTest):
# Check browser scrolled back to top
self.assertTrue(self.self_asmnt_page.is_on_top)
@retry()
@attr('acceptance')
def test_latex(self):
self.auto_auth_page.visit()
# 'Preview in Latex' button should be disabled at the page load
self.assertTrue(self.submission_page.latex_preview_button_is_disabled)
# Fill latex expression, & Verify if 'Preview in Latex is enabled'
self.submission_page.visit().fill_latex(self.LATEX_SUBMISSION)
self.assertFalse(self.submission_page.latex_preview_button_is_disabled)
# Click 'Preview in Latex' button & Verify if it was rendered
self.submission_page.preview_latex()
class PeerAssessmentTest(OpenAssessmentTest):
"""
......
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