From fb75faa69439102eb05c97c921c8165a96bb3ce1 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 4 Aug 2017 00:28:51 +0200 Subject: [PATCH] Fix rich text feature tests Now that the 'p' element (handled by halloheadings) is always-on, we can't use the presence or absence of halloheadings to test whether the default plugins are in force or have been overridden. Check for 'hallolists' instead. --- wagtail/wagtailadmin/tests/test_rich_text.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/wagtail/wagtailadmin/tests/test_rich_text.py b/wagtail/wagtailadmin/tests/test_rich_text.py index 74f55738dc..8774c75088 100644 --- a/wagtail/wagtailadmin/tests/test_rich_text.py +++ b/wagtail/wagtailadmin/tests/test_rich_text.py @@ -240,7 +240,7 @@ class TestRichTextValue(TestCase): 'WIDGET': 'wagtail.wagtailadmin.rich_text.HalloRichTextArea', 'OPTIONS': { 'plugins': { - 'halloheadings': {'formatBlocks': ['p']}, + 'halloheadings': {'formatBlocks': ['p', 'h2']}, } } }, @@ -264,7 +264,7 @@ class TestHalloJsWithCustomPluginOptions(BaseRichTextEditHandlerTestCase, Wagtai self.assertEqual(response.status_code, 200) # Check that the custom plugin options are being passed in the hallo initialiser - self.assertContains(response, 'makeHalloRichTextEditable("id_body", {"halloheadings": {"formatBlocks": ["p"]}});') + self.assertContains(response, 'makeHalloRichTextEditable("id_body", {"halloheadings": {"formatBlocks": ["p", "h2"]}});') def test_custom_editor_in_rich_text_block(self): block = RichTextBlock(editor='custom') @@ -272,7 +272,7 @@ class TestHalloJsWithCustomPluginOptions(BaseRichTextEditHandlerTestCase, Wagtai form_html = block.render_form(block.to_python("

hello

"), 'body') # Check that the custom plugin options are being passed in the hallo initialiser - self.assertIn('makeHalloRichTextEditable("body", {"halloheadings": {"formatBlocks": ["p"]}});', form_html) + self.assertIn('makeHalloRichTextEditable("body", {"halloheadings": {"formatBlocks": ["p", "h2"]}});', form_html) class TestHalloJsWithFeaturesKwarg(BaseRichTextEditHandlerTestCase, WagtailTestUtils): @@ -296,7 +296,7 @@ class TestHalloJsWithFeaturesKwarg(BaseRichTextEditHandlerTestCase, WagtailTestU # Check that the custom plugin options are being passed in the hallo initialiser self.assertContains(response, '"halloblockquote":') self.assertContains(response, '"hallowagtailembeds":') - self.assertNotContains(response, '"halloheadings":') + self.assertNotContains(response, '"hallolists":') self.assertNotContains(response, '"hallowagtailimage":') # check that media (js/css) from the features is being imported @@ -314,7 +314,7 @@ class TestHalloJsWithFeaturesKwarg(BaseRichTextEditHandlerTestCase, WagtailTestU # Check that the custom plugin options are being passed in the hallo initialiser self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailembeds":', form_html) - self.assertNotIn('"halloheadings":', form_html) + self.assertNotIn('"hallolists":', form_html) self.assertNotIn('"hallowagtailimage":', form_html) # check that media (js/css) from the features is being imported @@ -360,7 +360,7 @@ class TestHalloJsWithCustomFeatureOptions(BaseRichTextEditHandlerTestCase, Wagta # Check that the custom plugin options are being passed in the hallo initialiser self.assertContains(response, '"halloblockquote":') self.assertContains(response, '"hallowagtailimage":') - self.assertNotContains(response, '"halloheadings":') + self.assertNotContains(response, '"hallolists":') self.assertNotContains(response, '"hallowagtailembeds":') # a 'features' list passed on the RichTextField (as we do in richtextfieldwithfeaturespage) @@ -371,7 +371,7 @@ class TestHalloJsWithCustomFeatureOptions(BaseRichTextEditHandlerTestCase, Wagta self.assertEqual(response.status_code, 200) self.assertContains(response, '"halloblockquote":') self.assertContains(response, '"hallowagtailembeds":') - self.assertNotContains(response, '"halloheadings":') + self.assertNotContains(response, '"hallolists":') self.assertNotContains(response, '"hallowagtailimage":') # check that media (js/css) from the features is being imported @@ -390,7 +390,7 @@ class TestHalloJsWithCustomFeatureOptions(BaseRichTextEditHandlerTestCase, Wagta self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailimage":', form_html) self.assertNotIn('"hallowagtailembeds":', form_html) - self.assertNotIn('"halloheadings":', form_html) + self.assertNotIn('"hallolists":', form_html) # a 'features' list passed on the RichTextBlock # should override the list in OPTIONS @@ -401,7 +401,7 @@ class TestHalloJsWithCustomFeatureOptions(BaseRichTextEditHandlerTestCase, Wagta self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailembeds":', form_html) self.assertNotIn('"hallowagtailimage":', form_html) - self.assertNotIn('"halloheadings":', form_html) + self.assertNotIn('"hallolists":', form_html) # check that media (js/css) from the features is being imported media_html = str(block.media)