Add failing test for page model defined before wagtail.admin is loaded

pull/12750/head
Matt Westcott 2025-01-03 15:43:49 +00:00 zatwierdzone przez Sage Abdullah
rodzic a2407c0027
commit 09e26c3c2b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
6 zmienionych plików z 76 dodań i 0 usunięć

Wyświetl plik

@ -1,4 +1,5 @@
import datetime
import unittest
from unittest import mock
from django.contrib.auth.models import Group, Permission
@ -427,6 +428,27 @@ class TestPageCreation(WagtailTestUtils, TestCase):
)
self.assertRedirects(response, "/admin/")
@unittest.expectedFailure
def test_create_page_defined_before_admin_load(self):
"""
Test that a page model defined before wagtail.admin is loaded has all fields present
"""
response = self.client.get(
reverse(
"wagtailadmin_pages:add",
args=("earlypage", "earlypage", self.root_page.id),
)
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/pages/create.html")
# Title field should be present and have TitleFieldPanel behaviour
# including syncing with slug
self.assertContains(response, 'data-w-sync-target-value="#id_slug"')
# SEO title should be present in promote tab
self.assertContains(
response, "The name of the page displayed on search engine results"
)
def test_create_simplepage_post(self):
post_data = {
"title": "New page!",

Wyświetl plik

@ -0,0 +1,37 @@
# Generated by Django 5.1.4 on 2025-01-03 15:30
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("wagtailcore", "0094_alter_page_locale"),
]
operations = [
migrations.CreateModel(
name="EarlyPage",
fields=[
(
"page_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="wagtailcore.page",
),
),
("intro", models.TextField(blank=True)),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
]

Wyświetl plik

@ -0,0 +1,14 @@
# This module DOES NOT import from wagtail.admin -
# this tests that we are able to define Page models before wagtail.admin is loaded.
from django.db import models
from wagtail.models import Page
class EarlyPage(Page):
intro = models.TextField(blank=True)
content_panels = Page.content_panels + [
"intro",
]

Wyświetl plik

@ -135,6 +135,9 @@ MIDDLEWARE = (
)
INSTALLED_APPS = [
# Place wagtail.test.earlypage first, to test the behaviour of page models
# that are defined before wagtail.admin is loaded
"wagtail.test.earlypage",
# Install wagtailredirects with its appconfig
# There's nothing special about wagtailredirects, we just need to have one
# app which uses AppConfigs to test that hooks load properly