Skip to content

Add regression test for unpublish publish with inlines#14134

Draft
tomkins wants to merge 1 commit intowagtail:mainfrom
tomkins:inline-unpublish-publish-test
Draft

Add regression test for unpublish publish with inlines#14134
tomkins wants to merge 1 commit intowagtail:mainfrom
tomkins:inline-unpublish-publish-test

Conversation

@tomkins
Copy link
Copy Markdown
Contributor

@tomkins tomkins commented Apr 13, 2026

Fixes #13332
Fixes #13701 (duplicate)
See: wagtail/django-modelcluster#207

Description

Adds a test for Wagtail to the following scenario:

  • Publish page
  • Publish second version with an inline (revision has 'pk': None for this inline)
  • Unpublish page
  • Publish page

For this particular test we see a duplicate without the fix (#13701), if there's inlines with unique constraints then you'll get an IntegrityError (#13332). To avoid adding more models to the test app, I've just kept it to an existing model/inline, so we're just testing to avoid duplicate inlines.

To test:

./runtests.py --postgres wagtail.admin.tests.pages.test_edit_page.TestPublishUnpublishPublish

Results in:

======================================================================
FAIL: test_publish_unpublish_republish_with_inlines (wagtail.admin.tests.pages.test_edit_page.TestPublishUnpublishPublish.test_publish_unpublish_republish_with_inlines)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/tomkins/Python/wagtail/wagtail/admin/tests/pages/test_edit_page.py", line 5391, in test_publish_unpublish_republish_with_inlines
    self.assertQuerySetEqual(
    ~~~~~~~~~~~~~~~~~~~~~~~~^
        self.page.advert_placements.all().values_list("colour", flat=True),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ["Red"],
        ^^^^^^^^
    )
    ^
AssertionError: Lists differ: ['Red', 'Red'] != ['Red']

First list contains 1 additional elements.
First extra element 1:
'Red'

- ['Red', 'Red']
+ ['Red']

Then:

pip install -e django-modelcluster@git+https://github.com/tomkins/django-modelcluster.git@fix-clusterform-save
./runtests.py --postgres wagtail.admin.tests.pages.test_edit_page.TestPublishUnpublishPublish

Success!

Anyway, this all assumes that wagtail/django-modelcluster#207 is the right fix, and a new version of django-modelcluster is needed before this PR can be merged.

Additional testing instructions in that PR which can be done for a Wagtail project.

AI usage

Used Claude Haiku a while ago on this to get started, but it's probably significantly rewritten since then

@tomkins tomkins marked this pull request as draft April 14, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

ParentalKey bug with revisions IntegrityError after unpublishing a page with inline objects on base Page model and saving

1 participant