wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Disables the marks button when switching from editor and there is an active AI button

Open Jordi-PV opened this issue 1 year ago • 1 comments

Context

  • We want to ensure that the marker button remains disabled while an AI toast notification is active, regardless of the editor mode changes from visual to code and vice-versa.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where the highlighting marker button was incorrectly enabled when switching the editor mode from code to visual while the AI Optimize toast notification was still visible.

Relevant technical choices:

  • Moved out the logic to toggle the markers from post-scrapper and added to packages/js/src/ai-assessment-fixes/components/ai-assessment-fixes-button.js. This way it's centralized.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Have Yoast SEO premium activated.
  • Open or add a new post.
  • Add enough content and a keyphrase.
  • Click on one of the AI optimize buttons in the SEO analysis.
  • Confirm that when the AI optimize button is click, the highlighting mark buttons are disabled.
  • Make sure that the marks button remains disabled meanwhile the AI optimize toast notification is visible.
  • Switch to code editor without closing the AI optimize toast notification.
  • Confirm that the toast notification is still open and the marks button remains disabled.
  • Switch back to the visual editor.
  • Confirm that the toast notification is still open and the marks button also remains disabled.
  • Close or dismiss the notification and confirm that the highlighting marks button is now enabled.

Relevant test scenarios

  • [X] 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 (Default Block/Gutenberg/Classic/Elementor/other)
  • [X] Changes should be tested on different browsers
  • [ ] Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • [X] 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:

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

  • [X] I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • [X] I have tested this code to the best of my abilities.
  • [X] During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • [X] 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.
  • [X] I have written this PR in accordance with my team's definition of done.
  • [X] I have checked that the base branch is correctly set.

Innovation

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

Fixes #

Jordi-PV avatar Oct 18 '24 15:10 Jordi-PV

Pull Request Test Coverage Report for Build 1c565c44619df9d96cd54923fc66529f7579092e

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 49.42%

Files with Coverage Reduction New Missed Lines %
packages/js/src/initializers/post-scraper.js 1 0.0%
<!-- Total: 1
Totals Coverage Status
Change from base Build ad2c4b607f7daae862318f3d8e622f745e25b2c7: 0.01%
Covered Lines: 25673
Relevant Lines: 53667

💛 - Coveralls

coveralls avatar Oct 18 '24 16:10 coveralls

Early ACC before CR: I like the solution in general, but centralizing the code from post-scraper.js is not going to work, because you can turn off the AI feature altogether (in the Yoast SEO settings), and then the AI Optimize buttons will not be rendered.

mhkuu avatar Oct 21 '24 07:10 mhkuu

Early ACC before CR: I like the solution in general, but centralizing the code from post-scraper.js is not going to work, because you can turn off the AI feature altogether (in the Yoast SEO settings), and then the AI Optimize buttons will not be rendered.

Taking into account that we had setMarkerStatus and getEditorMode in the button code before so we didn't add more dependency - just move away from post-scrapper. So it looks good for me.

mykola avatar Oct 29 '24 08:10 mykola