PageAutoTestCase is an importable test case that provides an instantly high level of coverage for custom page types in a standard (non-headless) Wagtail project.
All developers need to do is:
Import PageAutoTestCase into a module where their test runner will pick it up
For each page type they want to test, define a PageFactory capable of creating fully functional instances
The edit-ability, serve-ability (for multiple routes), and preview-ability (for all preview modes) should then be tested for each type.
Developers can add autotest=False to the Meta class to exclude factories from these tests. For example,
where a factory is created as a 'base' for a series of subclasses, and isn't intended to be used directly.
What if my page types aren't a good fit?
If none of them are, simply don't import PageAutoTestCase into your project, and the tests should not run as part of your test suite.
If only a few page types are incompatible with PageAutoTestCase, you may wish to add autotest=False to the Meta class for those factories to exclude them.
Can I customise PageAutoTestCase?
PageAutoTestCase isn't designed to be subclassed. However, if you wanted to define something similar,, you could subclass PageFeaturesTestCase, which would give you access to the following assertions:
Dependant on #62 Resolves #45
PageAutoTestCase
is an importable test case that provides an instantly high level of coverage for custom page types in a standard (non-headless) Wagtail project.All developers need to do is:
The edit-ability, serve-ability (for multiple routes), and preview-ability (for all preview modes) should then be tested for each type.
Developers can add
autotest=False
to theMeta
class to exclude factories from these tests. For example, where a factory is created as a 'base' for a series of subclasses, and isn't intended to be used directly.What if my page types aren't a good fit?
If none of them are, simply don't import
PageAutoTestCase
into your project, and the tests should not run as part of your test suite.If only a few page types are incompatible with
PageAutoTestCase
, you may wish to addautotest=False
to theMeta
class for those factories to exclude them.Can I customise
PageAutoTestCase
?PageAutoTestCase
isn't designed to be subclassed. However, if you wanted to define something similar,, you could subclassPageFeaturesTestCase
, which would give you access to the following assertions:assertCanEditPageWithoutErrors(page: Page)
assertCanRenderPageWithoutErrors(page: Page, route_path: str = "/")
assertCanPreviewPageWithoutErrors(page: Page, preview_mode: str = "")