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

Make sure that slug is available before trying to return it #20699

Conversation

FAMarfuaty
Copy link
Contributor

@FAMarfuaty FAMarfuaty commented Sep 29, 2023

Context

  • When editing a product with WooCommerce v8.2.0-beta.1, the slug would not set in the slug field of the snippet editor after the product is published. This is also the case when WooCommerce v8.1.1 is active accompanied by WordProof plugin.
  • The problem is WooCommerce makes available the "core/editor" store in 8.2.0, in earlier versions it did not do that. When fetching the slug for a saved/published post we first resort to the data from that store — but that’s empty for posts in classic editor (it’s filled only for saved/published posts in block editor).
    We could reproduce this same issue also with WordProof — which similarly makes that store available on posts in the classic editor.
  • This is the PR that introduced this code, which was intended to only fetch the slug from that store when Block editor is used — but because the store is made available in the classic editor by WooCommerce / WordProof, we arrive at this issue.
  • In this PR, we fix the above problem by adding an extra check before retrieving the slug from the "core/editor" store. We now make sure that slug is available in the store before trying to return it.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where the slug in the search appearance editor would not be set when published posts were edited in the classic editor and the "core/editor" store was available.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

Scenario 1: Test with WooCommerce v8.2.0-beta.1

  • Install and activate WooCommerce v8.2.0-beta.1
  • Install and activate Yoast SEO, Yoast SEO Premium and Yoast SEO for WooCommerce
  • Create a product
  • Add a title: Wayang kulit
  • Add a text to the product

Wayang kulit (Javanese: ꦮꦪꦁ​ꦏꦸꦭꦶꦠ꧀) is a traditional form of puppet-shadow play originally found in the cultures of Java and Bali in Indonesia.[1] In a wayang kulit performance, the puppet figures are rear-projected on a taut linen screen with a coconut-oil (or electric) light. The dalang (shadow artist) manipulates carved leather figures between the lamp and the screen to bring the shadows to life. The narratives of wayang kulit often have to do with the major theme of good vs. evil.

  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is populated with the title value: wayang-kulit
  • Add a keyphrase: wayang kulit
  • Confirm that the Keyphrase in slug assessment returns a green bullet 🍏
  • Save the product
  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is STILL populated with the title value: wayang-kulit
  • Confirm that the Keyphrase in slug assessment STILL returns a green bullet 🍏

Scenario 2: Test with WooCommerce v8.2.0-beta.1 + WordProof

  • Install and activate WordProof plugin
  • Install and activate WooCommerce v8.2.0-beta.1
  • Install and activate Yoast SEO, Yoast SEO Premium and Yoast SEO for WooCommerce
  • Create a product
  • Add a title: Wayang kulit
  • Add a text to the product

Wayang kulit (Javanese: ꦮꦪꦁ​ꦏꦸꦭꦶꦠ꧀) is a traditional form of puppet-shadow play originally found in the cultures of Java and Bali in Indonesia.[1] In a wayang kulit performance, the puppet figures are rear-projected on a taut linen screen with a coconut-oil (or electric) light. The dalang (shadow artist) manipulates carved leather figures between the lamp and the screen to bring the shadows to life. The narratives of wayang kulit often have to do with the major theme of good vs. evil.

  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is populated with the title value: wayang-kulit
  • Add a keyphrase: wayang kulit
  • Confirm that the Keyphrase in slug assessment returns a green bullet 🍏
  • Save the product
  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is STILL populated with the title value: wayang-kulit
  • Confirm that the Keyphrase in slug assessment STILL returns a green bullet 🍏

Scenario 3: Test with WooCommerce v8.1.1 + WordProof

  • Install and activate WordProof plugin
  • Install and activate WooCommerce v8.1.1
  • Install and activate Yoast SEO, Yoast SEO Premium and Yoast SEO for WooCommerce
  • Create a product
  • Add a title: Wayang kulit
  • Add a text to the product

Wayang kulit (Javanese: ꦮꦪꦁ​ꦏꦸꦭꦶꦠ꧀) is a traditional form of puppet-shadow play originally found in the cultures of Java and Bali in Indonesia.[1] In a wayang kulit performance, the puppet figures are rear-projected on a taut linen screen with a coconut-oil (or electric) light. The dalang (shadow artist) manipulates carved leather figures between the lamp and the screen to bring the shadows to life. The narratives of wayang kulit often have to do with the major theme of good vs. evil.

  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is populated with the title value: wayang-kulit
  • Add a keyphrase: wayang kulit
  • Confirm that the Keyphrase in slug assessment returns a green bullet 🍏
  • Save the product
  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is STILL populated with the title value: wayang-kulit
  • Confirm that the Keyphrase in slug assessment STILL returns a green bullet 🍏

Scenario 4: Test in a post/page/CPT in Classic editor + WordProof

  • Install and activate WordProof plugin
  • Install and activate Classic editor
  • Install and activate Yoast SEO and Yoast SEO Premium
  • Create a post/page/CPT (it does not really matter what you pick here, the same code is applied)
  • Add a title: Wayang kulit
  • Add a text to the post/page/CPT:

Wayang kulit (Javanese: ꦮꦪꦁ​ꦏꦸꦭꦶꦠ꧀) is a traditional form of puppet-shadow play originally found in the cultures of Java and Bali in Indonesia.[1] In a wayang kulit performance, the puppet figures are rear-projected on a taut linen screen with a coconut-oil (or electric) light. The dalang (shadow artist) manipulates carved leather figures between the lamp and the screen to bring the shadows to life. The narratives of wayang kulit often have to do with the major theme of good vs. evil.

  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is populated with the title value: wayang-kulit
  • Add a keyphrase: wayang kulit
  • Confirm that the Keyphrase in slug assessment returns a green bullet 🍏
  • Save the product
  • Scroll down to the snippet editor metabox
  • Confirm that the slug field is STILL populated with the title value: wayang-kulit
  • Confirm that the Keyphrase in slug assessment STILL returns a green bullet 🍏

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Block/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • No additional impact

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/plugins-automated-testing/issues/1046

@FAMarfuaty FAMarfuaty added this to the 21.3 milestone Sep 29, 2023
@FAMarfuaty FAMarfuaty added the changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog label Sep 29, 2023
@FAMarfuaty FAMarfuaty marked this pull request as ready for review September 29, 2023 10:22
@mhkuu
Copy link
Contributor

mhkuu commented Sep 29, 2023

CR: ✅
ACC: Works! 🎉

@mhkuu mhkuu merged commit 23b37a0 into release/21.3 Sep 29, 2023
15 checks passed
@mhkuu mhkuu deleted the 1046-keyphrase-analysis-not-working-properly-with-the-latest-betaupcoming-release-of-woocommerce branch September 29, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants