Refactor upsell logic to include premium subscription validation#23200
Merged
JorPV merged 3 commits intofeature/content-plannerfrom Apr 28, 2026
Merged
Conversation
Coverage Report for CI Build 67199Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.002%) to 53.473%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 2 files lost coverage.
Coverage Stats💛 - Coveralls |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the AI Content Planner’s upsell gating so that reaching the spark usage limit no longer triggers the upsell flow for users with a valid Premium subscription, aligning behavior with the AI Generator.
Changes:
- Add Premium subscription validation (
selectPremiumSubscription) to Content Planner upsell decisions. - Bypass “usage limit reached” early-exit paths when a valid Premium subscription is present in
useFetchContentSuggestions. - Add/adjust unit tests around the approve modal behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/js/src/ai-content-planner/hooks/use-fetch-content-suggestions.js | Adds Premium subscription check to avoid blocking suggestion fetching when limit is reached for Premium users. |
| packages/js/src/ai-content-planner/containers/approve-modal.js | Updates isUpsell computation to factor in valid Premium subscription state. |
| packages/js/tests/ai-content-planner/components/approve-modal.test.js | Adds tests related to Premium/upsell rendering in the approve modal component. |
Comments suppressed due to low confidence (1)
packages/js/src/ai-content-planner/hooks/use-fetch-content-suggestions.js:65
- The
useCallbackdependency array is missingsetContentSuggestionsStatus, even though it’s used inside the callback. This can lead to a stale closure and also violates the usual hooks dependency conventions in this file (other dispatch fns are included). AddsetContentSuggestionsStatusto the dependency list (or restructure so it’s not captured).
}, [ endpoint,
postType,
contentLocale,
editorApiValue,
isUsageCountLimitReached,
hasValidPremiumSubscription,
usageCountEndpoint,
fetchContentPlannerSuggestions,
addUsageCount,
fetchUsageCount,
setFeatureModalStatus ] );
…test.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
|
CR + ACC ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
count >= limitwithout considering whether the user holds a valid Premium subscription. The AI Generator (ai-generator/components/app.js) already handles this correctly viacheckSubscriptions(). This fix applies the same pattern to the Content Planner by adding aselectPremiumSubscription()check alongsideisUsageCountLimitReachedin both the approve modal container and theuseFetchContentSuggestionshook.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
wp.data.dispatch( "yoast-seo/ai-generator").setUsageCount(100)in the browser console to simulate a high usage countRelevant test scenarios
Test instructions for QA when the code is in the RC
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:
Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand commited the results, if my PR introduces new images or SVGs.Innovation
innovationlabel.Fixes #