From 620ba8a1640c8b6ec49528d78696b306b6d96ba4 Mon Sep 17 00:00:00 2001 From: "E. Kolpakov" Date: Mon, 29 Dec 2014 16:32:48 +0300 Subject: [PATCH] Test for warning message when no content is configured. --- .../xmodule/xmodule/library_content_module.py | 6 ++- .../studio/test_studio_library_container.py | 42 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/library_content_module.py b/common/lib/xmodule/xmodule/library_content_module.py index 49237c7881..fcbef1fc00 100644 --- a/common/lib/xmodule/xmodule/library_content_module.py +++ b/common/lib/xmodule/xmodule/library_content_module.py @@ -26,7 +26,6 @@ _ = lambda text: text ANY_CAPA_TYPE_VALUE = 'any' -CAPA_BLOCK_TYPE = 'problem' def enum(**enums): @@ -362,6 +361,9 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe return Response() def _validate_library_version(self, validation, lib_tools, version, library_key): + """ + Validates library version + """ latest_version = lib_tools.get_library_version(library_key) if latest_version is not None: if version is None or version != latest_version: @@ -423,7 +425,7 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe StudioValidationMessage.WARNING, _(u'There are no content matching configured filters in the selected libraries.'), action_class='edit-button', - action_label=_(u"Edit Library List") + action_label=_(u"Edit Problem Type Filter") ) ) diff --git a/common/test/acceptance/tests/studio/test_studio_library_container.py b/common/test/acceptance/tests/studio/test_studio_library_container.py index 42fdfc4dc5..747db98752 100644 --- a/common/test/acceptance/tests/studio/test_studio_library_container.py +++ b/common/test/acceptance/tests/studio/test_studio_library_container.py @@ -42,6 +42,14 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest): XBlockFixtureDesc("html", "Html1"), XBlockFixtureDesc("html", "Html2"), XBlockFixtureDesc("html", "Html3"), + + XBlockFixtureDesc( + "problem", "Dropdown", + data=""" + +

Dropdown

+ +
""") ) def populate_course_fixture(self, course_fixture): @@ -171,3 +179,37 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest): self.assertFalse(library_block.has_validation_message) #self.assertIn("4 matching components", library_block.author_content) # Removed this assert until a summary message is added back to the author view (SOL-192) + + def test_no_content_message(self): + """ + Scenario: Given I have a library, a course and library content xblock in a course + When I go to studio unit page for library content block + And I set Problem Type selector so that no libraries have matching content + Then I can see that "No matching content" warning is shown + """ + expected_text = 'There are no content matching configured filters in the selected libraries. ' \ + 'Edit Problem Type Filter' + + library_container = self._get_library_xblock_wrapper(self.unit_page.xblocks[0]) + + # precondition check - assert library has children matching filter criteria + self.assertFalse(library_container.has_validation_error) + self.assertFalse(library_container.has_validation_warning) + + edit_modal = StudioLibraryContentXBlockEditModal(library_container.edit()) + self.assertEqual(edit_modal.capa_type, "Any Type") # precondition check + edit_modal.capa_type = "Custom Evaluated Script" + + library_container.save_settings() + + self.assertTrue(library_container.has_validation_warning) + self.assertIn(expected_text, library_container.validation_warning_text) + + edit_modal = StudioLibraryContentXBlockEditModal(library_container.edit()) + self.assertEqual(edit_modal.capa_type, "Custom Evaluated Script") # precondition check + edit_modal.capa_type = "Dropdown" + library_container.save_settings() + + # Library should contain single Dropdown problem, so now there should be no errors again + self.assertFalse(library_container.has_validation_error) + self.assertFalse(library_container.has_validation_warning)