Add docs & unit tests for assertCanCreate with publish (#9458)

- Builds on #9458
pull/9465/head
DokuaAsiedu 2022-10-23 22:59:09 +00:00 zatwierdzone przez LB (Ben Johnston)
rodzic 857981355d
commit af9f7ecbb3
5 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ Changelog
* Remove unsquashed `testapp` migrations (Matt Westcott)
* Switch to using Willow instead of Pillow for images (Darrel O'Pry)
* Add documentation for how to get started with contributing translations for the Wagtail admin (Ogunbanjo Oluwadamilare)
* Test assertion util `WagtailPageTestCase.assertCanCreate` now supports the kwarg `publish=True` to check publish redirection (Harry Percival, Akua Dokua Asiedu)
* Fix: Make sure workflow timeline icons are visible in high-contrast mode (Loveth Omokaro)
* Fix: Ensure authentication forms (login, password reset) have a visible border in Windows high-contrast mode (Loveth Omokaro)
* Fix: Ensure visual consistency between buttons and links as buttons in Windows high-contrast mode (Albina Starykova)

Wyświetl plik

@ -653,6 +653,7 @@ Contributors
* Ogunbanjo Oluwadamilare
* Damee Zivah Olawuyi
* Harry Percival
* Akua Dokua Asiedu
Translators
===========

Wyświetl plik

@ -140,11 +140,13 @@ def test_cant_create_under_event_page(self):
self.assertCanNotCreateAt(EventPage, ContentPage)
```
**assertCanCreate(_parent, child_model, data, msg=None_)**
**assertCanCreate(_parent, child_model, data, msg=None_, publish=True)**
Assert that a child of the given Page type can be created under the parent, using the supplied POST data.
`parent` should be a Page instance, and `child_model` should be a Page subclass. `data` should be a dict that will be POSTed at the Wagtail admin Page creation method.
`publish` specifies whether the page being created should be published or not, default is `False`. When `True`, it checks if the response url includes the url of the Wagtail Explorer Page, displaying an error if does not include that url. Otherwise it checks that the correct edit page loads.
```python
from wagtail.test.utils.form_data import nested_form_data, streamfield

Wyświetl plik

@ -18,6 +18,7 @@ depth: 1
* Wagtail's documentation (v2.9 to v4.0) has been updated on [Dash user contributions](https://github.com/Kapeli/Dash-User-Contributions) for [Dash](https://kapeli.com/dash) or [Zeal](https://zealdocs.org/) offline docs applications (Damilola Oladele, (Mary Ayobami)
* Switch to using [Willow](https://github.com/wagtail/Willow/) instead of Pillow for images (Darrel O'Pry)
* Add documentation for how to get started with [contributing translations](contributing_translations) for the Wagtail admin (Ogunbanjo Oluwadamilare)
* Test assertion [`WagtailPageTestCase.assertCanCreate`](testing_reference) now supports the kwarg `publish=True` to check publish redirection (Harry Percival, Akua Dokua Asiedu)
### Bug fixes

Wyświetl plik

@ -172,6 +172,14 @@ class TestWagtailPageTests(WagtailPageTests):
},
)
def test_assert_can_create_for_page_with_publish(self):
self.assertCanCreate(
self.root,
SimplePage,
{"title": "Simple Lorem Page", "content": "Lorem ipsum dolor sit amet"},
publish=True,
)
def test_assert_can_create_with_form_helpers(self):
# same as test_assert_can_create, but using the helpers from wagtail.test.utils.form_data
# as an end-to-end test