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

Updates the readability analysis when the client IDs of the blocks change #21953

Conversation

FAMarfuaty
Copy link
Contributor

@FAMarfuaty FAMarfuaty commented Jan 7, 2025

Context

  • Previously, after applying the AI suggestion for sentence length assessments to the editor, if the feedback still has a highlighting button and an AI Optimize button, both buttons don't work. Clicking on the highlighting button fails to highlight the relevant text in the editor. Additionally, the AI Optimize button is disabled as we could not detect blocks that contain long sentences.
  • The issue was apparently we failed to retrieve the relevant blocks that contain long sentences because we have an outdated readability analysis result. In the worker, we don't update the readability analysis result when there is a change in the list of Gutenberg blocks (including their client IDs that change after the action of applying AI suggestion). As a result, attempting to retrieve relevant blocks with outdated client IDs will fail.
  • The solution is to make sure that the readability analysis result is updated when there is a change in the list of Gutenberg blocks

Summary

This PR can be summarized in the following changelog entry:

  • [yoastseo] Updates the readability analysis result when there is a change in the list of Gutenberg blocks wpBlocks.
  • [wordpress-seo-premium] Fixes an unreleased bug where the highlighting button and AI Optimize button for sentence length assessment didn't work after applying AI suggestion to the editor.
  • Updates the readability analysis result when there is a change in the list of Gutenberg blocks wpBlocks.

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:

  • Install and activate Yoast SEO and Yoast SEO Premium.
    • Please refer to this page for guide on how to test the AI functionality
  • Set the site language to English
  • Create a post in Block/Gutenberg editor
  • Add the following text to the post:
If you're a bright and restless teenager in a small town in the American Midwest, you may well have one desire, and that is to get out, to go somewhere else. Hibbing, Minnesota, is one such town, and Robert "Bob" Zimmermann was one such young man.
In 1959, at the age of 18, Zimmermann left Hibbing to study English at the University of Minnesota in Minneapolis; but formal studies were not his thing. Bob was very much into folk music, and on campus and off it, soon became a popular performer at folk clubs and folk events. "Zimmermann" was a bit of a long name for a cool folk singer, so Bob adopted the name of the popular radical Welsh poet Dylan Thomas, who had died six years previously. Robert Zimmermann became Bob Dylan.

Big though it was, compared to Hibbing, Minneapolis was not the throbbing cultural capital of the United States, and within a year Bob had dropped out of university and made up his mind to pursue a career in music instead. It was a pretty big gamble; the terms "folk singing" and "career" rarely went together, and there were hardly a dozen successful folk singers in the USA at the time; there was the ageing [Woody Guthrie](https://linguapress.com/advanced/woody-guthrie.htm), the popular Pete Seeger, and the folksy Brothers Four. But Bob, now reborn as Bob Dylan, had talent, had a particular musical style, and an ambition to go with it.

From Minneapolis, Dylan made his way to the heart of the contemporary American folk music scene, Greenwich Village in New York, reaching the city by Greyhound Bus in January 1961 with little money in his pocket and no clear career plan in his head. It was however the start of a new chapter in his life, and at once he began performing in local clubs, gaining attention for his talent and unique style.

Performing in the coffeehouses and bars of Greenwich Village, playing both popular folk songs and some of his own compositions, Dylan soon built up a following. His distinctive nasal voice and original lyrics attracted the attention of music critics and fellow musicians. And just over three months after he arrived in New York, an enthusiastic article in The New York Times by Robert Shelton helped launch Bob Dylan on the road to success. Within weeks Columbia Records had signed him up for a recording contract.

Dylan's first album, simply titled "Bob Dylan", came out in March 1962, and included a mixture of traditional folk songs such as the House of the Rising Sun, and a couple of Dylan's own compositions. The album was a success, but just a foretaste of what was to follow. It was Dylan's second album "The Freewheelin' Bob Dylan", released in 1963, that really revealed his unique genius as a songwriter. It came out at a point in time when J.F.Kennedy was President of the USA, America was getting involved in Vietnam, and people were alarmed at the prospect of nuclear war. Songs like Blowin' in the Wind and A Hard Rain's A-Gonna Fall touched on the developing issues of the day.
  • Go to Sentence length assessment inside the Readability analysis tab
  • Click on the AI optimize button next to the feedback
  • When the AI request is successful, confirm that you see the AI suggestion previewed in the editor. The behavior when the suggestion is previewed should match what is described in this doc
  • When the suggestion is previewed, note the sentence length assessment score (and remember the percentage if there is any)
  • Click on "Apply" inside the AI Optimize notification component in the bottom left corner
  • Confirm that the suggestion is applied. The behavior when the suggestion is applied should match what is described in this doc
  • After the suggestion is applied, confirm the following:
    • The sentence length assessment score is the same as when the AI suggestion is previewed
    • If the assessment feedback has highlighting button, clicking on the button should highlight relevant long sentences in the editor
    • If the assessment feedback has AI Optimize button, the button should be enabled
  • Click on the AI Optimize button again
  • When the AI request is successful, confirm that the AI suggestion is still previewed correctly in the editor. The behavior when the suggestion is previewed should match what is described in this doc
  • Apply the suggestion and confirm that the suggestion is applied correctly to the editor

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 (Default Block/Gutenberg/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 further 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. 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

  • 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/2068

@FAMarfuaty FAMarfuaty added innovation Innovative issue. Relating to performance, memory or data-flow. changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog labels Jan 7, 2025
@FAMarfuaty FAMarfuaty added this to the 24.3 milestone Jan 7, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 60c59d75069e340fcf287e2f053bbd2a1994c6f4

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 54.621%

Totals Coverage Status
Change from base Build ab8946384bcd2d2862c1f035a0887b4e9557d64a: 0.004%
Covered Lines: 30086
Relevant Lines: 55455

💛 - Coveralls

@Jordi-PV
Copy link
Contributor

Jordi-PV commented Jan 8, 2025

It works like a charm 🙂

@Jordi-PV Jordi-PV merged commit 975bf4c into release/24.3 Jan 8, 2025
17 checks passed
@Jordi-PV Jordi-PV deleted the 496-ai-optimize-make-highlighting-and-ai-button-work-for-sentence-length-assessment-after-ai-suggestion-is-applied branch January 8, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog innovation Innovative issue. Relating to performance, memory or data-flow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants