Merge pull request #18850 from edx/awais/lett_2_bc_problem_editor_I
TE-2627: Problem Editor bokchoy tests
This commit is contained in:
@@ -2,28 +2,6 @@
|
||||
Feature: CMS.Problem Editor
|
||||
As a course author, I want to be able to create problems and edit their settings.
|
||||
|
||||
Scenario: User can view metadata
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
Then I see the advanced settings and their expected values
|
||||
And Edit High Level Source is not visible
|
||||
|
||||
# Safari is having trouble saving the values on sauce
|
||||
@skip_safari
|
||||
Scenario: User can modify String values
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
Then I can modify the display name
|
||||
And my display name change is persisted on save
|
||||
|
||||
# Safari is having trouble saving the values on sauce
|
||||
@skip_safari
|
||||
Scenario: User can specify special characters in String values
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
Then I can specify special characters in the display name
|
||||
And my special characters and persisted on save
|
||||
|
||||
Scenario: User can revert display name to unset
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
|
||||
76
common/test/acceptance/pages/studio/problem_editor.py
Normal file
76
common/test/acceptance/pages/studio/problem_editor.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""
|
||||
Studio Problem Editor
|
||||
"""
|
||||
from common.test.acceptance.pages.studio.xblock_editor import XBlockEditorView
|
||||
from common.test.acceptance.pages.common.utils import click_css
|
||||
from selenium.webdriver.support.ui import Select
|
||||
|
||||
|
||||
class ProblemXBlockEditorView(XBlockEditorView):
|
||||
"""
|
||||
Represents the rendered view of a Problem editor.
|
||||
"""
|
||||
|
||||
editor_mode_css = '.edit-xblock-modal .editor-modes .editor-button'
|
||||
settings_mode = '.settings-button'
|
||||
|
||||
def open_settings(self):
|
||||
"""
|
||||
Clicks on the settings button
|
||||
"""
|
||||
click_css(self, self.settings_mode)
|
||||
|
||||
def set_field_val(self, field_display_name, field_value):
|
||||
"""
|
||||
If editing, set the value of a field.
|
||||
"""
|
||||
selector = '.xblock-studio_view li.field label:contains("{}") + input'.format(field_display_name)
|
||||
script = "$(arguments[0]).val(arguments[1]).change();"
|
||||
self.browser.execute_script(script, selector, field_value)
|
||||
|
||||
def get_default_dropdown_value(self, css):
|
||||
"""
|
||||
Gets default value from the dropdown
|
||||
Arguments:
|
||||
css(string): css of the dropdown for which default value is required
|
||||
Returns:
|
||||
dropdown_value(string): Default dropdown value
|
||||
"""
|
||||
element = self.browser.find_element_by_css_selector(css)
|
||||
dropdown_default_selection = Select(element)
|
||||
value = dropdown_default_selection.first_selected_option.text
|
||||
return value
|
||||
|
||||
def get_settings(self):
|
||||
"""
|
||||
Default settings of problem
|
||||
Returns:
|
||||
settings_dict(dictionary): A dictionary of all the default settings
|
||||
"""
|
||||
settings_dict = {}
|
||||
number_of_settings = len(self.q(css='.wrapper-comp-setting'))
|
||||
css = '.list-input.settings-list .field.comp-setting-entry:nth-of-type({}) {}'
|
||||
|
||||
for index in range(1, number_of_settings + 1):
|
||||
key = self.q(css=css.format(index, "label")).text[0]
|
||||
if self.q(css=css.format(index, "input")).present:
|
||||
value = self.q(css=css.format(index, "input")).attrs('value')[0]
|
||||
elif self.q(css=css.format(index, "select")).present:
|
||||
value = self.get_default_dropdown_value(css.format(index, "select"))
|
||||
settings_dict[key] = value
|
||||
|
||||
return settings_dict
|
||||
|
||||
def is_latex_compiler_present(self):
|
||||
"""
|
||||
Checks for the presence of latex compiler settings
|
||||
Returns:
|
||||
bool: True if present
|
||||
"""
|
||||
return self.q(css='.launch-latex-compiler').present
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Clicks save button.
|
||||
"""
|
||||
click_css(self, '.action-save')
|
||||
@@ -0,0 +1,91 @@
|
||||
"""
|
||||
Acceptance tests for Problem component in studio
|
||||
"""
|
||||
from common.test.acceptance.tests.studio.base_studio_test import ContainerBase
|
||||
from common.test.acceptance.fixtures.course import XBlockFixtureDesc
|
||||
from common.test.acceptance.pages.studio.container import ContainerPage
|
||||
from common.test.acceptance.pages.studio.utils import add_component
|
||||
from common.test.acceptance.pages.studio.problem_editor import ProblemXBlockEditorView
|
||||
|
||||
|
||||
class ProblemComponentEditor(ContainerBase):
|
||||
"""
|
||||
Feature: CMS.Component Adding
|
||||
As a course author, I want to be able to add and edit Problem
|
||||
"""
|
||||
|
||||
def setUp(self, is_staff=True):
|
||||
"""
|
||||
Create a course with a section, subsection, and unit to which to add the component.
|
||||
"""
|
||||
super(ProblemComponentEditor, self).setUp(is_staff=is_staff)
|
||||
self.component = 'Blank Common Problem'
|
||||
self.unit = self.go_to_unit_page()
|
||||
self.container_page = ContainerPage(self.browser, None)
|
||||
# Add a Problem
|
||||
add_component(self.container_page, 'problem', self.component)
|
||||
self.component = self.unit.xblocks[1]
|
||||
self.container_page.edit()
|
||||
self.problem_editor = ProblemXBlockEditorView(self.browser, self.component.locator)
|
||||
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
"""
|
||||
Adds a course fixture
|
||||
"""
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Test Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Test Unit')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def test_user_can_view_metadata(self):
|
||||
"""
|
||||
Scenario: User can view metadata
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
Then I see the advanced settings and their expected values
|
||||
And Edit High Level Source is not visible
|
||||
"""
|
||||
expected_default_settings = {
|
||||
'Display Name': u'Blank Common Problem',
|
||||
'Matlab API key': u'',
|
||||
'Maximum Attempts': u'',
|
||||
'Problem Weight': u'',
|
||||
'Randomization': u'Never',
|
||||
'Show Answer': u'Finished',
|
||||
'Show Reset Button': u'False',
|
||||
'Timer Between Attempts': u'0'
|
||||
}
|
||||
self.problem_editor.open_settings()
|
||||
settings = self.problem_editor.get_settings()
|
||||
self.assertEqual(expected_default_settings, settings)
|
||||
self.assertFalse(self.problem_editor.is_latex_compiler_present())
|
||||
|
||||
def test_user_can_modify_string_values(self):
|
||||
"""
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
Then I can modify the display name
|
||||
And my display name change is persisted on save
|
||||
"""
|
||||
self.problem_editor.open_settings()
|
||||
self.problem_editor.set_field_val('Display Name', 'New Name')
|
||||
self.problem_editor.save()
|
||||
component_name = self.unit.xblock_titles[0]
|
||||
self.assertEqual(component_name, 'New Name')
|
||||
|
||||
def test_user_can_specify_special_characters(self):
|
||||
"""
|
||||
Scenario: User can specify special characters in String values
|
||||
Given I have created a Blank Common Problem
|
||||
When I edit and select Settings
|
||||
Then I can specify special characters in the display name
|
||||
And my special characters are persisted on save
|
||||
"""
|
||||
self.problem_editor.open_settings()
|
||||
self.problem_editor.set_field_val('Display Name', '&&&')
|
||||
self.problem_editor.save()
|
||||
component_name = self.unit.xblock_titles[0]
|
||||
self.assertEqual(component_name, '&&&')
|
||||
Reference in New Issue
Block a user