Skip to content

🐛 Refreshed cancel button state after retention offer flow#26735

Merged
mike182uk merged 2 commits into
mainfrom
cancel-link-helper-copy-update-BER-3417-mike
Mar 9, 2026
Merged

🐛 Refreshed cancel button state after retention offer flow#26735
mike182uk merged 2 commits into
mainfrom
cancel-link-helper-copy-update-BER-3417-mike

Conversation

@mike182uk

Copy link
Copy Markdown
Member

ref https://linear.app/ghost/issue/BER-3417

When a member cancelled via the retention offer path (Portal popup), the theme page's cancel button didn't update because no page reload occurred. The cancelSubscription and applyOffer actions now return reloadOnPopupClose: true, and the App component reloads the page when the popup closes with that flag set. The flag is cleared on each openPopup to prevent stale reloads.

@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f353a3f4-8db2-4017-bd20-95f3e9b3b8b3

📥 Commits

Reviewing files that changed from the base of the PR and between a591bf4 and 7819de0.

📒 Files selected for processing (2)
  • apps/portal/src/actions.js
  • apps/portal/test/actions.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/portal/test/actions.test.ts
  • apps/portal/src/actions.js

Walkthrough

The portal app version was bumped from 2.65.4 to 2.65.5. Four action functions now include a reloadOnPopupClose boolean: openPopup -> false; cancelSubscription -> true; continueSubscription -> true; applyOffer -> true. The app component now conditionally calls window.location.reload() when a popup closes and the reloadOnPopupClose flag is truthy. Tests were added to verify the new action return properties and the popup-close reload behavior for success, failure, and explicit false cases.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the cancel button state after a retention offer flow by implementing page reload functionality.
Description check ✅ Passed The description clearly explains the bug, the solution (reloadOnPopupClose flag), and how it prevents stale reloads, all of which align with the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cancel-link-helper-copy-update-BER-3417-mike

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/portal/test/app.test.js (1)

105-118: Test validates the expected behavior, but the comment is slightly misleading.

The comment on line 110 says "should clear any stale reloadOnPopupClose", but the test doesn't actually verify the clearing mechanism from openPopup. It verifies that when reloadOnPopupClose: false is set and the popup closes, no reload occurs—which is still a valid and useful test case.

Consider updating the test description or comment to more accurately reflect what's being tested.

📝 Suggested comment clarification
     test('does not reload on subsequent popup close after reloadOnPopupClose was previously set', () => {
         const app = new App({siteUrl: 'http://example.com'});

         window.location.reload = vi.fn();

-        // Simulate opening a new popup - should clear any stale reloadOnPopupClose
+        // State after openPopup action sets reloadOnPopupClose to false
         app.state = {...app.state, showPopup: true, reloadOnPopupClose: false};

-        // Close the popup without reloadOnPopupClose
+        // Close the popup - should not reload since flag is false
         app.state = {...app.state, showPopup: false};
         app.componentDidUpdate({}, {showPopup: true});

         expect(window.location.reload).not.toHaveBeenCalled();
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/portal/test/app.test.js` around lines 105 - 118, Update the test
description/comment to accurately reflect its behavior: change wording that
currently claims "should clear any stale reloadOnPopupClose" to indicate it
verifies that when reloadOnPopupClose is explicitly false on the App instance
(app.state.reloadOnPopupClose = false) and the popup closes
(app.componentDidUpdate invoked with previous showPopup true),
window.location.reload is not called. Reference the test(name), the App class,
app.state.reloadOnPopupClose, and componentDidUpdate (or openPopup if you add a
separate test for clearing) so readers know this test checks "no reload when
reloadOnPopupClose is false" rather than verifying openPopup's clearing logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/portal/test/app.test.js`:
- Around line 105-118: Update the test description/comment to accurately reflect
its behavior: change wording that currently claims "should clear any stale
reloadOnPopupClose" to indicate it verifies that when reloadOnPopupClose is
explicitly false on the App instance (app.state.reloadOnPopupClose = false) and
the popup closes (app.componentDidUpdate invoked with previous showPopup true),
window.location.reload is not called. Reference the test(name), the App class,
app.state.reloadOnPopupClose, and componentDidUpdate (or openPopup if you add a
separate test for clearing) so readers know this test checks "no reload when
reloadOnPopupClose is false" rather than verifying openPopup's clearing logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d55db170-4f1e-4b6a-846d-a0a7150b8447

📥 Commits

Reviewing files that changed from the base of the PR and between 90c7c03 and 2062771.

📒 Files selected for processing (5)
  • apps/portal/package.json
  • apps/portal/src/actions.js
  • apps/portal/src/app.js
  • apps/portal/test/actions.test.ts
  • apps/portal/test/app.test.js

ref https://linear.app/ghost/issue/BER-3417

When a member cancelled via the retention offer path (Portal popup),
the theme page's cancel button didn't update because no page reload
occurred. The `cancelSubscription` and `applyOffer` actions now return
`reloadOnPopupClose: true`, and the App component reloads the page
when the popup closes with that flag set. The flag is cleared on each
`openPopup` to prevent stale reloads.
@mike182uk mike182uk force-pushed the cancel-link-helper-copy-update-BER-3417-mike branch from 2062771 to a591bf4 Compare March 9, 2026 12:53
@ErisDS

ErisDS commented Mar 9, 2026

Copy link
Copy Markdown
Member

🤖 Velo CI Failure Analysis

Classification: 🔴 HARD FAIL

  • Workflow: CI
  • Failed Step: Log in to GitHub Container Registry
  • Run: View failed run
    What failed: Docker login to GitHub Container Registry timed out
    Why: The error message indicates a network issue - the Docker login to the GitHub Container Registry timed out, which is an infrastructure-related problem and not a code issue.
    Action:
    This is likely a temporary network issue or a problem with the GitHub Container Registry. Try rerunning the workflow or check the status of the GitHub Container Registry.

@sagzy sagzy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mike182uk mike182uk merged commit 6bdac95 into main Mar 9, 2026
28 checks passed
@mike182uk mike182uk deleted the cancel-link-helper-copy-update-BER-3417-mike branch March 9, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants