Skip to content
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

Merged
merged 2 commits into from Feb 8, 2024

Conversation

Aljullu
Copy link
Contributor

@Aljullu Aljullu commented Feb 5, 2024

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.

  1. Verify e2e tests pass.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

Add automated tests to verify specific product block templates are rendered

@Aljullu Aljullu self-assigned this Feb 5, 2024
@Aljullu Aljullu added focus: template Issue related to WooCommerce templates. team: Kirigami & Origami labels Feb 5, 2024
@Aljullu Aljullu force-pushed the fix/44354-specific-product-templates-tests branch from 6ec239d to d4c14b1 Compare February 5, 2024 14:16
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 5, 2024
@Aljullu Aljullu force-pushed the fix/44354-specific-product-templates-tests branch from 394be53 to adadddc Compare February 5, 2024 14:25
Copy link
Contributor

github-actions bot commented Feb 5, 2024

Test Results Summary

Commit SHA: adadddc

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 36s
E2E Tests226008303095m 45s

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.

@Aljullu Aljullu marked this pull request as ready for review February 5, 2024 15:31
@woocommercebot woocommercebot requested review from a team and thealexandrelara and removed request for a team February 5, 2024 15:31
Copy link
Contributor

github-actions bot commented Feb 5, 2024

Hi @thealexandrelara,

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:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Comment on lines +60 to +69
// 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 );
Copy link
Contributor

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?

Copy link
Contributor Author

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? 🤔

Copy link
Contributor

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.

Copy link
Contributor Author

@Aljullu Aljullu Feb 8, 2024

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!

Comment on lines +44 to +54
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 );
Copy link
Contributor

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.

Copy link
Contributor

@thealexandrelara thealexandrelara left a 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!

@Aljullu Aljullu merged commit e0f4ed8 into trunk Feb 8, 2024
50 checks passed
@Aljullu Aljullu deleted the fix/44354-specific-product-templates-tests branch February 8, 2024 09:18
@github-actions github-actions bot added this to the 8.7.0 milestone Feb 8, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Feb 8, 2024
@veljkho veljkho added status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: template Issue related to WooCommerce templates. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Kirigami & Origami
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add automated tests to verify specific product templates are rendered correctly
3 participants