From ce5c7948fa27511193731676765050ff489ebb46 Mon Sep 17 00:00:00 2001 From: Matt Drayer Date: Wed, 21 Jan 2015 14:30:51 -0500 Subject: [PATCH] Added field to FILTERED_LIST plus a new bokchoy test --- .../models/settings/course_metadata.py | 6 +- .../pages/studio/settings_advanced.py | 71 +++++++++++++++++++ .../tests/studio/test_studio_settings.py | 16 +++++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/models/settings/course_metadata.py b/cms/djangoapps/models/settings/course_metadata.py index 5a7b979154..cbf4b92d60 100644 --- a/cms/djangoapps/models/settings/course_metadata.py +++ b/cms/djangoapps/models/settings/course_metadata.py @@ -15,8 +15,8 @@ class CourseMetadata(object): editable metadata. ''' # The list of fields that wouldn't be shown in Advanced Settings. - # Should not be used directly. Instead the filtered_list method should be used if the field needs to be filtered - # depending on the feature flag. + # Should not be used directly. Instead the filtered_list method should + # be used if the field needs to be filtered depending on the feature flag. FILTERED_LIST = [ 'xml_attributes', 'start', @@ -40,6 +40,8 @@ class CourseMetadata(object): 'entrance_exam_enabled', 'entrance_exam_minimum_score_pct', 'entrance_exam_id', + 'is_entrance_exam', + 'in_entrance_exam', ] @classmethod diff --git a/common/test/acceptance/pages/studio/settings_advanced.py b/common/test/acceptance/pages/studio/settings_advanced.py index a4614f8b10..d7138d4624 100644 --- a/common/test/acceptance/pages/studio/settings_advanced.py +++ b/common/test/acceptance/pages/studio/settings_advanced.py @@ -13,6 +13,7 @@ MANUAL_BUTTON_SELECTOR = ".action-item .action-cancel" 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" class AdvancedSettingsPage(CoursePage): @@ -126,3 +127,73 @@ class AdvancedSettingsPage(CoursePage): result_map[key] = val return result_map + + @property + def displayed_settings_names(self): + """ + Returns all settings displayed on the advanced settings page/screen/modal/whatever + We call it 'name', but it's really whatever is embedded in the 'id' element for each field + """ + query = self.q(css=SETTINGS_NAME_SELECTOR) + return query.attrs('id') + + @property + def expected_settings_names(self): + """ + Returns a list of settings expected to be displayed on the Advanced Settings screen + Should match the list of settings found in cms/djangoapps/models/settings/course_metadata.py + If a new setting is added to the metadata list, this test will fail and you must update it. + Basically this guards against accidental exposure of a field on the Advanced Settings screen + """ + return [ + 'advanced_modules', + 'allow_anonymous', + 'allow_anonymous_to_peers', + 'allow_public_wiki_access', + 'cert_name_long', + 'cert_name_short', + 'certificates_display_behavior', + 'cohort_config', + 'course_image', + 'advertised_start', + 'announcement', + 'display_name', + 'info_sidebar_name', + 'is_new', + 'ispublic', + 'max_student_enrollments_allowed', + 'no_grade', + 'display_coursenumber', + 'display_organization', + 'end_of_course_survey_url', + 'catalog_visibility', + 'chrome', + 'days_early_for_beta', + 'default_tab', + 'disable_progress_graph', + 'discussion_blackouts', + 'discussion_sort_alpha', + 'discussion_topics', + 'due', + 'due_date_display_format', + 'use_latex_compiler', + 'video_speed_optimizations', + 'enrollment_domain', + 'html_textbooks', + 'invitation_only', + 'lti_passports', + 'matlab_api_key', + 'max_attempts', + 'mobile_available', + 'rerandomize', + 'remote_gradebook', + 'annotation_token_secret', + 'showanswer', + 'show_calculator', + 'show_chat', + 'show_reset_button', + 'static_asset_path', + 'text_customization', + 'annotation_storage_url', + 'video_upload_pipeline' + ] diff --git a/common/test/acceptance/tests/studio/test_studio_settings.py b/common/test/acceptance/tests/studio/test_studio_settings.py index 72f22fe407..b7238cc4c4 100644 --- a/common/test/acceptance/tests/studio/test_studio_settings.py +++ b/common/test/acceptance/tests/studio/test_studio_settings.py @@ -290,3 +290,19 @@ class AdvancedSettingsValidationTest(StudioCourseTest): "Course Announcement Date": '"string"', } ) + + def test_only_expected_fields_are_displayed(self): + """ + Scenario: The Advanced Settings screen displays settings/fields not specifically hidden from + view by a developer. + Given I have a set of CourseMetadata fields defined for the course + When I view the Advanced Settings screen for the course + The total number of fields displayed matches the number I expect + And the actual fields displayed match the fields I expect to see + """ + expected_fields = self.advanced_settings.expected_settings_names + displayed_fields = self.advanced_settings.displayed_settings_names + self.assertEqual(len(expected_fields), len(displayed_fields)) + for field in displayed_fields: + if field not in expected_fields: + self.fail("Field '{}' not expected for Advanced Settings display.".format(field))