diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 776b9a21ab..00693230b9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -55,6 +55,7 @@ Changelog * Update React and related dependencies to latest versions (Janneke Janssen, Hugo van den Berg) * Remove Hallo editor `.richtext` CSS class in favour of more explicit extension points (Thibaud Colas) * Expose React-related dependencies as global variables for extension in the admin interface (Thibaud Colas) + * Added helper functions for constructing form data for use with `assertCanCreate` (Tim Heap, Matt Westcott) * Fix: Do not remove stopwords when generating slugs from non-ASCII titles, to avoid issues with incorrect word boundaries (Sævar Öfjörð Magnússon) * Fix: The PostgreSQL search backend now preserves ordering of the `QuerySet` when searching with `order_by_relevance=False` (Bertrand Bordage) * Fix: Using `modeladmin_register` as a decorator no longer replaces the decorated class with `None` (Tim Heap) diff --git a/docs/releases/2.0.rst b/docs/releases/2.0.rst index 8a8572318b..0b34d999f7 100644 --- a/docs/releases/2.0.rst +++ b/docs/releases/2.0.rst @@ -72,6 +72,7 @@ Other features * Simplified edit handler API (Florent Osmont, Bertrand Bordage) * Made 'add/change/delete collection' permissions configurable from the group edit page (Matt Westcott) * Expose React-related dependencies as global variables for extension in the admin interface (Thibaud Colas) + * Added helper functions for constructing form data for use with ``assertCanCreate``. See :ref:`form_data_test_helpers` (Tim Heap, Matt Westcott) Bug fixes @@ -216,6 +217,31 @@ The Draftail rich text editor has a substantially different API from Hallo.js, i } +Data format for rich text fields in ``assertCanCreate`` tests has been updated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``assertCanCreate`` test method (see :doc:`/advanced_topics/testing`) requires data to be passed in the same format that the page edit form would submit. The Draftail rich text editor posts this data in a non-HTML format, and so any existing ``assertCanCreate`` tests involving rich text fields will fail when Draftail is in use: + + .. code-block:: python + + self.assertCanCreate(root_page, ContentPage, { + 'title': 'About us', + 'body': '
Lorem ipsum dolor sit amet
', # will not work + }) + +Wagtail now provides a set of helper functions for constructing form data: see :ref:`form_data_test_helpers`. The above assertion can now be rewritten as: + + .. code-block:: python + + from wagtail.tests.utils.form_data import rich_text + + self.assertCanCreate(root_page, ContentPage, { + 'title': 'About us', + 'body': rich_text('Lorem ipsum dolor sit amet
'), + }) + + + Removed support for Elasticsearch 1.x ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~