-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add e2e test for template part block creation and insertion #21849
Conversation
Size Change: 0 B Total Size: 835 kB ℹ️ View Unchanged
|
await trashExistingPosts( 'wp_template_part' ); | ||
} ); | ||
afterAll( async () => { | ||
await disableExperimentalFeatures( requiredExperiments ); |
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.
Should we trash the test template and template part at teardown?
await disableExperimentalFeatures( requiredExperiments ); | |
await disableExperimentalFeatures( requiredExperiments ); | |
await trashExistingPosts( 'wp_template' ); | |
await trashExistingPosts( 'wp_template_part' ); |
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.
I wondered the same thing. But it seems the standard in these e2e tests in general is trashing in beforeAll
and not after. The beforeAll
defined to run for every test suite uses the standard trashExistingPosts
, and that function is neglected from the afterAll defined beneath it. I guess it would be more complete to do it after as well, but probably not necessary as we are mostly concerned with clearing the slate for the tests to run on?
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.
Sounds convincing, especially if we're following an established pattern here 👍
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.
Thanks @Addison-Stavlo, this is going to come in super handy!
I have only one (non-blocking) question 🙂
Block test files have the name of the block, e.g., |
@epiqueras - Gotcha! I see you recently added that file with a test in the site editor. Nice! These are a bit more centered towards the placeholder block as opposed to template part block itself as yours is. Do you think we should still share the same file with the standard template-part block, or create a |
They are still the same block. The placeholder is just a state of the block. I think prior art, e.g., the Image block tests, keep everything in the same file so we should do the same here. |
91f3bf1
to
34462b3
Compare
@epiqueras - Cool! I updated this to use that file as well. I was having some issues with your test passing locally (on master and on this PR) but it seems it passed with Travis. Just to document what I am seeing locally that was breaking the test: the first time I select a template part in the template selector (when selecting 'header' in the test), a React error gets thrown: the good old "Can't perform a React state update on an unmounted component." Travis isn't encountering this, so hopefully it's just a local problem at the moment. |
It sounds like a race condition with an effect on the site editor. I triggered another build just to be safe. Feel free to merge if it passes. |
Hrm, seems the build failed for another reason. It won't let me trigger it again atm, will check back later. |
It was just a network error while downloading WP in one of the jobs. I restarted it 🙂 |
Awesome, thank you for that! |
Description
Adds a basic e2e test flow for custom Template Part creation/insertion flow through the Template Part block.
This seems like it would be helpful to help catch any potential future regressions. Recently, template parts were not able to find matches as expected / be inserted (this was solved in #21766 ). Similarly, there was a recent regression in inner blocks (#21804) that would cause template parts to be inserted without their actual inner content.
e2e test flow:
How has this been tested?
Running e2e locally.
Types of changes
E2e tests.
Checklist: