Merge pull request #18345 from edx/awais/lett_2_bc_advanced_settings
bokchoy conversion of advanced settings - Part1
This commit is contained in:
@@ -3,26 +3,6 @@ Feature: CMS.Advanced (manual) course policy
|
||||
In order to specify course policy settings for which no custom user interface exists
|
||||
I want to be able to manually enter JSON key /value pairs
|
||||
|
||||
|
||||
Scenario: A course author sees default advanced settings
|
||||
Given I have opened a new course in Studio
|
||||
When I select the Advanced Settings
|
||||
Then I see default advanced settings
|
||||
|
||||
Scenario: Add new entries, and they appear alphabetically after save
|
||||
Given I am on the Advanced Course Settings page in Studio
|
||||
Then the settings are alphabetized
|
||||
|
||||
# Sauce labs does not play nicely with CodeMirror
|
||||
@skip_sauce
|
||||
Scenario: Test cancel editing key value
|
||||
Given I am on the Advanced Course Settings page in Studio
|
||||
When I edit the value of a policy key
|
||||
And I press the "Cancel" notification button
|
||||
Then the policy key value is unchanged
|
||||
And I reload the page
|
||||
Then the policy key value is unchanged
|
||||
|
||||
# Sauce labs does not play nicely with CodeMirror
|
||||
@skip_sauce
|
||||
Scenario: Test editing key value
|
||||
|
||||
@@ -67,23 +67,6 @@ def create_value_not_in_quotes(step):
|
||||
change_display_name_value(step, 'quote me')
|
||||
|
||||
|
||||
@step('I see default advanced settings$')
|
||||
def i_see_default_advanced_settings(step):
|
||||
# Test only a few of the existing properties (there are around 34 of them)
|
||||
assert_policy_entries(
|
||||
[ADVANCED_MODULES_KEY, DISPLAY_NAME_KEY, "Show Calculator"], ["[]", DISPLAY_NAME_VALUE, "false"])
|
||||
|
||||
|
||||
@step('the settings are alphabetized$')
|
||||
def they_are_alphabetized(step):
|
||||
key_elements = world.css_find(KEY_CSS)
|
||||
all_keys = []
|
||||
for key in key_elements:
|
||||
all_keys.append(key.value)
|
||||
|
||||
assert_equal(sorted(all_keys), all_keys, "policy keys were not sorted")
|
||||
|
||||
|
||||
@step('it is displayed as formatted$')
|
||||
def it_is_formatted(step):
|
||||
assert_policy_entries(['Discussion Topic Mapping'], ['{\n "key": "value",\n "key_2": "value_2"\n}'])
|
||||
|
||||
@@ -18,6 +18,9 @@ MODAL_SELECTOR = ".validation-error-modal-content"
|
||||
ERROR_ITEM_NAME_SELECTOR = ".error-item-title strong"
|
||||
ERROR_ITEM_CONTENT_SELECTOR = ".error-item-message"
|
||||
SETTINGS_NAME_SELECTOR = ".is-not-editable"
|
||||
CONFIRMATION_MESSAGE_SELECTOR = "#alert-confirmation-title"
|
||||
DEPRECATED_SETTINGS_SELECTOR = ".field-group.course-advanced-policy-list-item.is-deprecated"
|
||||
DEPRECATED_SETTINGS_BUTTON_SELECTOR = ".deprecated-settings-label"
|
||||
|
||||
|
||||
class AdvancedSettingsPage(CoursePage):
|
||||
@@ -34,6 +37,20 @@ class AdvancedSettingsPage(CoursePage):
|
||||
EmptyPromise(_is_finished_loading, 'Finished rendering the advanced policy items.').fulfill()
|
||||
return self.q(css='body.advanced').present
|
||||
|
||||
@property
|
||||
def key_names(self):
|
||||
"""
|
||||
Returns a list of key names of all settings.
|
||||
"""
|
||||
return self.q(css=KEY_CSS).text
|
||||
|
||||
@property
|
||||
def deprecated_settings_button_text(self):
|
||||
"""
|
||||
Returns text for deprecated settings button
|
||||
"""
|
||||
return self.q(css=DEPRECATED_SETTINGS_BUTTON_SELECTOR).text[0]
|
||||
|
||||
def wait_for_modal_load(self):
|
||||
"""
|
||||
Wait for validation response from the server, and make sure that
|
||||
|
||||
@@ -19,7 +19,7 @@ from common.test.acceptance.pages.studio.overview import CourseOutlinePage
|
||||
from common.test.acceptance.pages.studio.settings import SettingsPage
|
||||
from common.test.acceptance.pages.studio.settings_advanced import AdvancedSettingsPage
|
||||
from common.test.acceptance.pages.studio.settings_group_configurations import GroupConfigurationsPage
|
||||
from common.test.acceptance.pages.studio.utils import get_input_value
|
||||
from common.test.acceptance.pages.studio.utils import get_input_value, type_in_codemirror
|
||||
from common.test.acceptance.tests.helpers import create_user_partition_json, element_has_text
|
||||
from xmodule.partitions.partitions import Group
|
||||
|
||||
@@ -291,6 +291,9 @@ class AdvancedSettingsValidationTest(StudioCourseTest):
|
||||
"""
|
||||
Tests for validation feature in Studio's advanced settings tab
|
||||
"""
|
||||
course_name_key = 'Course Display Name'
|
||||
course_name_value = 'Test Name'
|
||||
|
||||
def setUp(self):
|
||||
super(AdvancedSettingsValidationTest, self).setUp()
|
||||
self.advanced_settings = AdvancedSettingsPage(
|
||||
@@ -306,6 +309,81 @@ class AdvancedSettingsValidationTest(StudioCourseTest):
|
||||
# Before every test, make sure to visit the page first
|
||||
self.advanced_settings.visit()
|
||||
|
||||
def test_course_author_sees_default_advanced_settings(self):
|
||||
"""
|
||||
Scenario: Test that advanced settings have the default settings
|
||||
Given a staff logs in to studio
|
||||
When this user goes to advanced settings page
|
||||
Then this user sees 'Allow Anonymous Discussion Posts' as true
|
||||
And 'Enable Timed Exams' as false
|
||||
And 'Maximum Attempts' as null
|
||||
"""
|
||||
anonymous_discussion_setting = self.advanced_settings.get('Allow Anonymous Discussion Posts')
|
||||
timed_exam_settings = self.advanced_settings.get('Enable Timed Exams')
|
||||
max_attempts = self.advanced_settings.get('Maximum Attempts')
|
||||
page_default_settings = [
|
||||
anonymous_discussion_setting,
|
||||
timed_exam_settings,
|
||||
max_attempts
|
||||
]
|
||||
default_anonymous_discussion_setting = 'true'
|
||||
default_timed_exam_settings = 'false'
|
||||
default_max_attempts = 'null'
|
||||
expected_default_settings = [
|
||||
default_anonymous_discussion_setting,
|
||||
default_timed_exam_settings,
|
||||
default_max_attempts
|
||||
]
|
||||
self.assertEqual(
|
||||
page_default_settings,
|
||||
expected_default_settings
|
||||
)
|
||||
|
||||
def test_keys_appear_alphabetically(self):
|
||||
"""
|
||||
Scenario: Test that advanced settings have all the keys in alphabetic order
|
||||
Given a staff logs in to studio
|
||||
When this user goes to advanced settings page
|
||||
Then he sees all the advanced setting keys in alphabetic order
|
||||
"""
|
||||
|
||||
key_names = self.advanced_settings.key_names
|
||||
self.assertEqual(key_names, sorted(key_names))
|
||||
|
||||
def test_cancel_editing_key_value(self):
|
||||
"""
|
||||
Scenario: Test that advanced settings does not save the key value, if cancel
|
||||
is clicked from notification bar
|
||||
Given a staff logs in to studio
|
||||
When this user goes to advanced settings page and enters and new course name
|
||||
Then he clicks 'cancel' buttin when asked to save changes
|
||||
When this user reloads the page
|
||||
And then he does not see any change in the original course name
|
||||
"""
|
||||
|
||||
original_course_display_name = self.advanced_settings.get(self.course_name_key)
|
||||
new_course_name = 'New Course Name'
|
||||
type_in_codemirror(self.advanced_settings, 16, new_course_name)
|
||||
self.advanced_settings.cancel()
|
||||
self.advanced_settings.refresh_and_wait_for_load()
|
||||
self.assertNotEqual(
|
||||
original_course_display_name,
|
||||
new_course_name,
|
||||
('original course name:{} can not not be equal to unsaved course name {}'.format(
|
||||
original_course_display_name,
|
||||
new_course_name
|
||||
)
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
self.advanced_settings.get(self.course_name_key),
|
||||
original_course_display_name,
|
||||
('course name from the page should be same as original_course_display_name:{}'.format(
|
||||
original_course_display_name
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def test_modal_shows_one_validation_error(self):
|
||||
"""
|
||||
Test that advanced settings don't save if there's a single wrong input,
|
||||
|
||||
Reference in New Issue
Block a user