Add TestCase that automatically test PageFactory subclasses #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 = "")