Commit 522a3c8e by E. Kolpakov

Integration test for display_name and question text

parent 7635328f
...@@ -28,12 +28,14 @@ class BaseIntegrationTest(SeleniumTest): ...@@ -28,12 +28,14 @@ class BaseIntegrationTest(SeleniumTest):
header1 = self.browser.find_element_by_css_selector('h1') header1 = self.browser.find_element_by_css_selector('h1')
self.assertEqual(header1.text, 'XBlock scenarios') self.assertEqual(header1.text, 'XBlock scenarios')
def go_to_page(self, page_name, css_selector='div.mentoring'): def go_to_page(self, page_name, css_selector='section.xblock--drag-and-drop'):
""" """
Navigate to the page `page_name`, as listed on the workbench home Navigate to the page `page_name`, as listed on the workbench home
Returns the DOM element on the visited page located by the `css_selector` Returns the DOM element on the visited page located by the `css_selector`
""" """
self.browser.get(self.live_server_url) self.browser.get(self.live_server_url)
self.browser.find_element_by_link_text(page_name).click() self.browser.find_element_by_link_text(page_name).click()
mentoring = self.browser.find_element_by_css_selector(css_selector) return self.browser.find_element_by_css_selector(css_selector)
return mentoring
\ No newline at end of file def get_element_html(self, element):
return element.get_attribute('innerHTML').strip()
\ No newline at end of file
from xml.sax.saxutils import escape
from nose_parameterized import parameterized
from workbench import scenarios
from tests.integration.test_base import BaseIntegrationTest from tests.integration.test_base import BaseIntegrationTest
class TestBlockParameters(BaseIntegrationTest): class TestBlockParameters(BaseIntegrationTest):
def test_test(self): @parameterized.expand([
pass ("plain1", 'title1', 'question1'),
("plain2", 'title2', 'question2'),
("html1", 'title with <b>HTML</b>', '<span style="color:red">Span title</span>'),
("html2", 'Q: <b>HTML</b>?', '<span style="color:red">Span question</span>'),
])
def test_block_parameters(self, _, display_name, question_text):
const_page_name = "Test block parameters"
const_page_id = 'test_block_title'
scenarios.add_xml_scenario(
const_page_id, const_page_name,
"""
<vertical_demo><drag-and-drop-v2
display_name='{display_name}' question_text='{question_text}'
/></vertical_demo>
""".format(display_name=escape(display_name), question_text=escape(question_text))
)
self.addCleanup(scenarios.remove_scenario, const_page_id)
page = self.go_to_page(const_page_name)
problem_header = page.find_element_by_css_selector('h2.problem-header')
self.assertEqual(self.get_element_html(problem_header), display_name)
question = page.find_element_by_css_selector("section.problem > p")
self.assertEqual(self.get_element_html(question), question_text)
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