🐛 Fixed Portal crash when navigating via hash links on a page#26445
🐛 Fixed Portal crash when navigating via hash links on a page#26445kevinansfield merged 1 commit intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 WalkthroughApp.updateStateForPreviewLinks was changed to call 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4caaa93 to
a8f1d19
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/portal/test/portal-links.test.js (1)
388-413: Authenticated tests are nested inside the "unauthenticated account page access" describe block.These tests verify logged-in behavior but live under the
describe('unauthenticated account page access', ...)block (line 347). Consider moving them to their owndescribeor renaming the parent block (e.g., "hashchange account page access").🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/portal/test/portal-links.test.js` around lines 388 - 413, Tests using test.each(...) that assert logged-in behavior are currently placed inside the describe block named 'unauthenticated account page access'; move those tests out by either creating a new describe('hashchange account page access', ...) or renaming the parent describe so the context matches (e.g., change the parent describe name or cut the test.each(...) block and paste it into a new describe that sets up an authenticated context), ensuring the setup(...) call still uses FixtureMember.free and the assertions (expect(triggerButtonFrame)..., window.location.hash changes, and within(popupFrame.contentDocument).queryByText(expectedText)) remain unchanged.
🤖 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/portal-links.test.js`:
- Around line 388-413: Tests using test.each(...) that assert logged-in behavior
are currently placed inside the describe block named 'unauthenticated account
page access'; move those tests out by either creating a new describe('hashchange
account page access', ...) or renaming the parent describe so the context
matches (e.g., change the parent describe name or cut the test.each(...) block
and paste it into a new describe that sets up an authenticated context),
ensuring the setup(...) call still uses FixtureMember.free and the assertions
(expect(triggerButtonFrame)..., window.location.hash changes, and
within(popupFrame.contentDocument).queryByText(expectedText)) remain unchanged.
fixes https://github.com/TryGhost/Ghost/issues/XXXX `updateStateForPreviewLinks()` called `fetchLinkData()` without arguments, so `site` and `member` were undefined. This caused a crash when clicking portal hash links (e.g. `<a href="#/portal/account/profile">`) on an already-loaded page, while loading the full URL directly worked fine because the initial `fetchData()` path passed the arguments correctly.
a8f1d19 to
2be7ec0
Compare
…st#26445) closes https://linear.app/ghost/issue/ONC-1484/re-account-page-links-are-broken ## Summary - Portal's `updateStateForPreviewLinks()` (the `hashchange` event handler) called `fetchLinkData()` without arguments, leaving `site` and `member` as `undefined` - This caused a crash when clicking portal hash links (e.g. `<a href="#/portal/account/profile">`) on an already-loaded page - Loading the full URL directly (e.g. `http://localhost:2368/#/portal/account/profile`) worked fine because the initial `fetchData()` code path passed the arguments correctly - Fixed by passing `this.state.site` and `this.state.member` to `fetchLinkData()` in `updateStateForPreviewLinks()` - Added tests for both logged-in and logged-out hashchange navigation
Summary
updateStateForPreviewLinks()(thehashchangeevent handler) calledfetchLinkData()without arguments, leavingsiteandmemberasundefined<a href="#/portal/account/profile">) on an already-loaded pagehttp://localhost:2368/#/portal/account/profile) worked fine because the initialfetchData()code path passed the arguments correctlythis.state.siteandthis.state.membertofetchLinkData()inupdateStateForPreviewLinks()