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

Avoid duplicate templates appearing on the Site Editor when the WooCommerce template and the theme template have been customized by the user #44000

Merged
merged 7 commits into from Jan 25, 2024

Conversation

Aljullu
Copy link
Contributor

@Aljullu Aljullu commented Jan 23, 2024

Changes proposed in this Pull Request:

Fixes #42220.

Blocks #43794.

As mentioned in #42220, if the user modified a WooCommerce templates twice, once using the WooCommerce template as the base and the other time using the theme templates as the base, we ended up with duplicate templates on the list.

This PR fixes that and adds some tests to verify we don't introduce regressions in the future.

How to test the changes in this Pull Request:

  1. Activate a theme without WooCommerce templates (ie: Twenty Twenty Four).
  2. Make a modification to a WooCommerce template. Ie: add a "Hello world" paragraph somewhere in the Single Product template.
  3. Now, switch your theme to a theme with WooCommerce templates (ie: Tsubaki).
  4. Make a modification to the same template from step 2. You will probably need to access it via the URL. Ie: /wp-admin/site-editor.php?postId=theme-tsubaki%2F%2Fsingle-product&postType=wp_template&canvas=edit. Note: the theme-tsubaki part of the URL might change depending on the ZIP file name that you uploaded. In case of doubt, go to Appearance > Editor > Templates > Template Catalog and look at the URL.
  5. Load the templates list: /wp-admin/site-editor.php?path=%2Fwp_template%2Fall.
  6. Verify there is only one template named "Single Product".

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

Avoid duplicate templates appearing on the Site Editor when the WooCommerce template and the theme template have been customized by the user

Comment

…mmerce template and the theme template have been customized by the user
@Aljullu Aljullu added focus: template Issue related to WooCommerce templates. team: Kirigami & Origami labels Jan 23, 2024
@Aljullu Aljullu self-assigned this Jan 23, 2024
@Aljullu Aljullu force-pushed the fix/42220-duplicate-templates-when-both-modified branch from 0b62dc5 to bc4fd29 Compare January 23, 2024 14:29
};
};

export const CUSTOMIZABLE_WC_TEMPLATES: TemplateCustomizationTest[] = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this constant is currently only used in one file (template-customization.block_theme.side_effects.spec.ts), my plan is to update template-user-customization.block_theme_with_templates.spec.ts and template-user-customization.block_theme.spec.ts to use it as well.

@Aljullu Aljullu force-pushed the fix/42220-duplicate-templates-when-both-modified branch from 9e082f0 to a27ca4a Compare January 23, 2024 14:34
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 23, 2024
Copy link
Contributor

github-actions bot commented Jan 23, 2024

Test Results Summary

Commit SHA: 18d70ce

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests28900702966m 15s

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 January 24, 2024 09:29
@woocommercebot woocommercebot requested review from a team and dinhtungdu and removed request for a team January 24, 2024 09:30
Copy link
Contributor

Hi @dinhtungdu,

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

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm issue is fixed following the testing instruction in my tests. The code also looks good to me. I left a minor but non blocking comment. Approving 🚢

@Aljullu Aljullu merged commit 66c3467 into trunk Jan 25, 2024
45 checks passed
@Aljullu Aljullu deleted the fix/42220-duplicate-templates-when-both-modified branch January 25, 2024 13:55
@github-actions github-actions bot added this to the 8.7.0 milestone Jan 25, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 25, 2024
@veljkho veljkho added needs: internal testing Indicates if the PR requires further testing conducted by Solaris 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 Jan 26, 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. needs: internal testing Indicates if the PR requires further testing conducted by Solaris 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.

BlockTemplatesController: Duplicate templates in the template list
3 participants