Skip to content

586 create a notification for when the sparks run out#22332

Merged
vraja-pro merged 13 commits intofeature/ai-generator-in-freefrom
586-create-a-notification-for-when-the-sparks-run-out
Jun 6, 2025
Merged

586 create a notification for when the sparks run out#22332
vraja-pro merged 13 commits intofeature/ai-generator-in-freefrom
586-create-a-notification-for-when-the-sparks-run-out

Conversation

@vraja-pro
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro commented Jun 6, 2025

Context

  • WIP

Summary

This PR can be summarized in the following changelog entry:

  • Refactors ai upsell modal, usage counter and spark notification.

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:

  • Edit a post ( on local env, use fake-ai-notification.patch)
  • Click on "Use AI".
  • Check you see the upsell, click on try for free button.
  • Grant consent.
  • Check you can use the AI generator.
  • Refresh and click on "Use AI".
  • Check you don't see the consent or the upsell.
  • Go to Yoast SEO->Settings->Site features
  • Disable "SEO analysis"
  • Edit a page or post and click on "Use AI"
  • Check you get an error message for the SEO analysis.
  • Go to profile page and look for "AI feature", click on "Revoke consent" and save.
  • Refresh and check it is saved.
  • Grant consent, refresh and check it is saved.
  • Enable SEO analysis and edit a post
  • Click on "Use AI"
  • You should see the AI generator with dummy suggestions from the fake API
  • Check you reached 10 sparks and the upsell notification is visible:
    Screenshot 2025-06-06 at 15 42 35
  • Revoke consent.
  • Edit a WooCommerce product and Click on "Use AI"
  • Check you see an upsell for WOO and premium bundle.
  • Activate Woo SEO and check the upsell button is for Premium.

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:

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 #

With a ternary the children are always a string. As required by the Label component.
An empty string is an invalid value for the Notification component.
Copying over the default value: "default"
* the counter makes no sense for the error
* refactor useSelect into a single one for performance (less subscriptions)
* move the MainModal declaration to before it is used
* specify the Premium/defaults in the hook already
* refactor to use a single useSelect for performance
* remove the hijacked title/isProductCopy from the type documentation
To also work for the upsell variant
* no need for the elaborate internal names
* add request status
* don't reset the count to zero before and on errors
* add selectors for ease of use (not sure if we keep them)
* move request transformation/validation to the generator function instead of in the reducer: resulting in an error if not the expected response
Let's not overcomplicate things with having to know the context before deciding which selector to use.
If you need to know: check isTerm.

Same for the Woo upsell. But not removing the term check as it is currently still being used in Premium.

Seems to be only used in this context, so taking the opportunity to refactor.
Left a potential rename alone: entityType
@vraja-pro vraja-pro added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jun 6, 2025
@vraja-pro vraja-pro force-pushed the 586-create-a-notification-for-when-the-sparks-run-out branch from fad2bc7 to 110d8b8 Compare June 6, 2025 10:59
I the spacing is the same, we can control it from one place.
@vraja-pro vraja-pro force-pushed the 586-create-a-notification-for-when-the-sparks-run-out branch from 055874f to 36b0fa1 Compare June 6, 2025 11:09
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build f568ea6d16855d8baf4bd7c470a1b50748131022

Details

  • 13 of 94 (13.83%) changed or added relevant lines in 11 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.6%) to 52.051%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/ai-generator/components/feature-error.js 0 1 0.0%
packages/js/src/ai-generator/components/introduction.js 0 1 0.0%
packages/js/src/ai-generator/components/app.js 2 4 50.0%
packages/js/src/redux/selectors/preferences.js 2 4 50.0%
packages/js/src/redux/selectors/editorContext.js 3 7 42.86%
packages/js/src/ai-optimizer/components/modal-content.js 0 6 0.0%
packages/js/src/ai-generator/components/upsell-modal-content.js 0 8 0.0%
packages/js/src/ai-generator/components/sparks-limit-notification.js 4 14 28.57%
packages/js/src/ai-generator/hooks/use-upsell-props.js 1 19 5.26%
packages/js/src/ai-generator/store/usage-count.js 0 29 0.0%
Files with Coverage Reduction New Missed Lines %
packages/js/src/ai-generator/store/usage-count.js 3 0.0%
Totals Coverage Status
Change from base Build 187b4783a3227c7395f1a38195ea655d03cf7741: 0.6%
Covered Lines: 29908
Relevant Lines: 58577

💛 - Coveralls

@vraja-pro vraja-pro added this to the feature/ai-generator-in-free milestone Jun 6, 2025
@vraja-pro vraja-pro merged commit b3a2d8d into feature/ai-generator-in-free Jun 6, 2025
42 checks passed
@vraja-pro vraja-pro deleted the 586-create-a-notification-for-when-the-sparks-run-out branch June 6, 2025 12:51
@pls78 pls78 mentioned this pull request Jul 15, 2025
18 tasks
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants