diff --git a/wagtail/wagtailadmin/tests/test_pages_views.py b/wagtail/wagtailadmin/tests/test_pages_views.py index 0985091e9c..62e11d978d 100644 --- a/wagtail/wagtailadmin/tests/test_pages_views.py +++ b/wagtail/wagtailadmin/tests/test_pages_views.py @@ -670,6 +670,24 @@ class TestPageCreation(TestCase, WagtailTestUtils): page = Page.objects.order_by('-id').first() self.assertEqual(page.seo_title, '') + def test_whitespace_is_stripped_from_titles(self): + post_data = { + 'title': " Hello ", + 'content': "Some content", + 'slug': 'hello-world', + 'action-submit': "Submit", + 'seo_title': ' hello SEO ' + } + response = self.client.post(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id)), post_data) + + # Should be successful, as both title and seo_title are non-empty after stripping + self.assertEqual(response.status_code, 302) + + # Whitespace should be automatically stripped from title and seo_title + page = Page.objects.order_by('-id').first() + self.assertEqual(page.title, 'Hello') + self.assertEqual(page.seo_title, 'hello SEO') + def test_long_slug(self): post_data = { 'title': "Hello world",