From d4475af79fcb9409626fa0c1958d0f4b94ae66c2 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Wed, 14 Feb 2018 17:17:22 +0000 Subject: [PATCH] Add release notes for form data helpers --- CHANGELOG.txt | 1 + docs/releases/2.0.rst | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e2f19e74c..314246e38 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -45,6 +45,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 90d0a1863..f93322e4a 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~