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 automated tests to verify specific product block templates are rendered #44363
Conversation
6ec239d
to
d4c14b1
Compare
394be53
to
adadddc
Compare
Test Results SummaryCommit SHA: adadddc
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
// Revert edition. | ||
await admin.visitAdminPage( | ||
'site-editor.php', | ||
`path=/${ testData.templateType }/all` | ||
); | ||
await editorUtils.revertTemplateCreation( testData.templateName ); | ||
await page.goto( testData.permalink ); | ||
|
||
// Verify the edits are no longer visible. | ||
await expect( page.getByText( userText ) ).toHaveCount( 0 ); |
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.
Is the purpose of this code to ensure the functionality of excluding the template, or is it just doing a test cleanup? If the latter, maybe it would be best to move this to an afterAll
or afterEach
hook. WDYT?
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.
It has a double purpose: to revert the edition for a test cleanup but also to verify that the "Revert edition" has worked correctly. Even though inside editorUtils.revertTemplateCreation()
we check that a success notice is shown, I think it's a good idea to test that the template was, in fact, reverted.
I don't have a strong opinion about moving it into an afterAll
/afterEach
, but given that there is an expect()
, I thought it made more sense to keep it inside the test? 🤔
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.
That makes sense! I don't have a strong opinion on this either; I just pointed this out because if it was just a test cleanup and, for some reason, the test failed before the editorUtils.revertTemplateCreation()
was called, then the templates will still exist after the test run, which could impact other tests that were not expecting these newly created templates.
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.
Good call! It happened to me a few times that a failing test messed up my test site and I had to restart it from scratch. So it's definitely something that would be worth investigating.
As we have some other test files with the same issue, I'll merge this PR as-is and investigate possible improvements in a separate PR, so we can tackle all test files at once. I opened an issue here: #44445.
Thanks for the suggestion!
await admin.visitAdminPage( | ||
'site-editor.php', | ||
`path=/${ testData.templateType }/all` | ||
); | ||
await editorUtils.revertTemplateCustomizations( testData.templateName ); | ||
await page.goto( testData.permalink ); | ||
|
||
await expect( | ||
page.getByText( themeTemplateText ).first() | ||
).toBeVisible(); | ||
await expect( page.getByText( userText ) ).toHaveCount( 0 ); |
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 have the same question as above.
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.
All e2e tests are passing. I left a question in the code, and considering it is not a blocker I'm approving this PR. Great work!
Changes proposed in this Pull Request:
Closes #44354.
How to test the changes in this Pull Request:
Note: no need to test this for the release.
Changelog entry
Significance
Type
Message
Comment
Add automated tests to verify specific product block templates are rendered