This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Add mock theme with Woo Templates for E2E tests #5920
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sunyatasattva
added
skip-changelog
PRs that you don't want to appear in the changelog.
category: tests
focus: FSE
Work related to prepare WooCommerce for FSE.
labels
Feb 22, 2022
Size Change: 0 B Total Size: 817 kB ℹ️ View Unchanged
|
tjcafferkey
approved these changes
Mar 2, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @sunyatasattva, I really like the useTheme
hook and how you've considered it enough to only activate the specified theme just for the suite of tests it's being used in to prevent the chances of its usage breaking any subsequent test suites.
All the checks seem to be passing, and the code LGTM so I'm going to approve this.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
focus: FSE
Work related to prepare WooCommerce for FSE.
skip-changelog
PRs that you don't want to appear in the changelog.
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.
This PR adds a block-enabled theme with templates for WooCommerce which is intended to be used when testing the more complex scenarios described in #5660. In order to test our logic, we need two templates:
Both themes are required. Tests for scenario 1 where added in #5722, #5748, #5820 and #5888. This PR does not add any test, but merely the basis for further E2E test scenarios.
Additionally, since theme-dependent logic seems to be becoming more and more useful (see #5913), this PR also adds a utility function used to explicitly declare theme dependencies of a test. Said function will activate the theme before running a given suite and then reactivate the previous theme, as to make sure to not have any side-effects (such as the ones described in #5913 above).
Closes #5660
@dinhtungdu I refactored my previous code to not activate TT1 once done, but to reactivate the previously active theme (as discussed here).
If you come across tests which are dependent on a specific theme activation, I suggest you refactor / create those using the code introduced in this PR. It's a simple test "hook", just using it at the top level of your
describe
closure should do the trick of activating the required theme and reactivating the previous one on teardown, like so: