Skip to content

Conversation

9larsons
Copy link
Contributor

@9larsons 9larsons commented Aug 6, 2025

ref https://linear.app/ghost/issue/PROD-2415/add-redirect-for-dashboard-analytics

  • added redirect from Dashboard -> Analytics

This change helps preserve existing user bookmarks by simply pushing them towards the 'new dashboard'.

ref https://linear.app/ghost/issue/PROD-2415/add-redirect-for-dashboard-analytics
- added redirect from Dashboard -> Analytics

This change helps preserve existing user bookmarks by simply pushing them towards the 'new dashboard'.
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

The changes simplify the dashboard route by removing role-based conditional redirects and other lifecycle methods, leaving only an unconditional redirect to the 'stats-x' route in the beforeModel hook. The dashboard acceptance tests were refactored to remove all role-based and unauthenticated access tests, retaining only a single test that verifies an Owner user is redirected from /dashboard to /analytics. The test setup now includes mocking and cleanup of analytics apps, and session invalidation and user cleanup logic were removed. Additionally, search acceptance tests were updated to mock analytics apps and changed navigation from /dashboard to /analytics without modifying test assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a29939f and ded9eec.

📒 Files selected for processing (1)
  • ghost/admin/tests/acceptance/search-test.js (9 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: the pending activity utilities in the ghost activitypub module are covered by tests in the file `app...
Learnt from: mike182uk
PR: TryGhost/Ghost#22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in the Ghost ActivityPub module are covered by tests in the file `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`.

Applied to files:

  • ghost/admin/tests/acceptance/search-test.js
📚 Learning: in the ghost test framework, when testing csv exports via the admin api, the response `body` field i...
Learnt from: ErisDS
PR: TryGhost/Ghost#23588
File: ghost/core/test/e2e-api/admin/backup.test.js:136-148
Timestamp: 2025-05-29T10:37:26.369Z
Learning: In the Ghost test framework, when testing CSV exports via the admin API, the response `body` field is empty while the actual CSV data is provided through the `text` field. Tests should use `expectEmptyBody()` and then validate the CSV content via `.expect(({text}) => ...)` - this is not contradictory behavior.

Applied to files:

  • ghost/admin/tests/acceptance/search-test.js
📚 Learning: the pending activity utilities in ghost's activitypub module are thoroughly tested in `apps/admin-x-...
Learnt from: mike182uk
PR: TryGhost/Ghost#22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in Ghost's ActivityPub module are thoroughly tested in `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`, which covers `generatePendingActivityId`, `isPendingActivity`, and `generatePendingActivity` functions.

Applied to files:

  • ghost/admin/tests/acceptance/search-test.js
📚 Learning: in ghost project, app.js files under core/server/web are intentionally excluded from unit test cover...
Learnt from: ErisDS
PR: TryGhost/Ghost#23582
File: ghost/core/.c8rc.json:24-24
Timestamp: 2025-05-29T07:45:35.714Z
Learning: In Ghost project, app.js files under core/server/web are intentionally excluded from unit test coverage because they are not easily unit-testable due to being entry points with initialization code and side effects.

Applied to files:

  • ghost/admin/tests/acceptance/search-test.js
🔇 Additional comments (3)
ghost/admin/tests/acceptance/search-test.js (3)

3-3: LGTM: Analytics mocking setup is well-structured.

The analytics app mocking is properly implemented with consistent setup and cleanup across both test suites. This ensures test isolation and prevents interference between test runs.

Also applies to: 19-19, 24-24, 30-30, 37-37


69-69: LGTM: Systematic route updates align with application changes.

All test cases have been consistently updated to navigate to /analytics instead of /dashboard, perfectly reflecting the application's routing changes. The URL expectation is also properly updated to match the new route.

Also applies to: 74-75, 82-82, 92-92, 100-100, 108-108, 127-127, 138-138, 146-146, 154-154, 167-167, 175-175, 184-184, 192-192, 202-202


12-220: LGTM: Test coverage and structure properly preserved.

The changes maintain comprehensive test coverage for both search providers while adapting to the new routing structure. All original test scenarios remain intact, ensuring no regression in search functionality testing.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-redir-dashboard

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@9larsons 9larsons requested a review from peterzimon August 6, 2025 13:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ghost/admin/tests/acceptance/dashboard-test.js (1)

22-32: Consider adding a test for non-Owner roles to verify unconditional redirect.

While the current test verifies the redirect for an Owner, since the dashboard redirect is now unconditional for all authenticated users, consider adding at least one test with a different role (e.g., Editor or Author) to ensure the redirect works consistently across all user types.

Example additional test:

it('redirects Editor users to Analytics', async function () {
    let role = this.server.create('role', {name: 'Editor'});
    this.server.create('user', {roles: [role]});

    await authenticateSession();
    await visit('/dashboard');

    expect(currentURL()).to.equal('/analytics');
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f28fc1 and a29939f.

📒 Files selected for processing (2)
  • ghost/admin/app/routes/dashboard.js (1 hunks)
  • ghost/admin/tests/acceptance/dashboard-test.js (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: the pending activity utilities in the ghost activitypub module are covered by tests in the file `app...
Learnt from: mike182uk
PR: TryGhost/Ghost#22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in the Ghost ActivityPub module are covered by tests in the file `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`.

Applied to files:

  • ghost/admin/tests/acceptance/dashboard-test.js
📚 Learning: in ghost project, app.js files under core/server/web are intentionally excluded from unit test cover...
Learnt from: ErisDS
PR: TryGhost/Ghost#23582
File: ghost/core/.c8rc.json:24-24
Timestamp: 2025-05-29T07:45:35.714Z
Learning: In Ghost project, app.js files under core/server/web are intentionally excluded from unit test coverage because they are not easily unit-testable due to being entry points with initialization code and side effects.

Applied to files:

  • ghost/admin/tests/acceptance/dashboard-test.js
📚 Learning: in the ghost test framework, when testing csv exports via the admin api, the response `body` field i...
Learnt from: ErisDS
PR: TryGhost/Ghost#23588
File: ghost/core/test/e2e-api/admin/backup.test.js:136-148
Timestamp: 2025-05-29T10:37:26.369Z
Learning: In the Ghost test framework, when testing CSV exports via the admin API, the response `body` field is empty while the actual CSV data is provided through the `text` field. Tests should use `expectEmptyBody()` and then validate the CSV content via `.expect(({text}) => ...)` - this is not contradictory behavior.

Applied to files:

  • ghost/admin/tests/acceptance/dashboard-test.js
📚 Learning: the pending activity utilities in ghost's activitypub module are thoroughly tested in `apps/admin-x-...
Learnt from: mike182uk
PR: TryGhost/Ghost#22471
File: apps/admin-x-activitypub/src/utils/pending-activity.ts:13-71
Timestamp: 2025-03-13T09:00:20.205Z
Learning: The pending activity utilities in Ghost's ActivityPub module are thoroughly tested in `apps/admin-x-activitypub/test/unit/utils/pending-activity.ts`, which covers `generatePendingActivityId`, `isPendingActivity`, and `generatePendingActivity` functions.

Applied to files:

  • ghost/admin/tests/acceptance/dashboard-test.js
🧬 Code Graph Analysis (1)
ghost/admin/tests/acceptance/dashboard-test.js (5)
ghost/admin/tests/helpers/mock-analytics-apps.js (2)
  • mockAnalyticsApps (3-23)
  • cleanupMockAnalyticsApps (25-33)
ghost/admin/tests/acceptance/analytics-navigation-test.js (2)
  • role (15-15)
  • role (63-63)
ghost/admin/tests/acceptance/authentication-test.js (2)
  • role (134-134)
  • role (350-350)
ghost/admin/tests/acceptance/signup-test.js (1)
  • role (200-200)
ghost/admin/tests/acceptance/members/filter-test.js (1)
  • role (32-32)
🔇 Additional comments (2)
ghost/admin/app/routes/dashboard.js (1)

4-9: Confirmation: ‘stats-x’ routes to ‘/analytics’

  • Inspected ghost/admin/app/router.js:
    this.route('stats-x', {path: '/analytics'}, function () {
      this.route('stats-x', {path: '/*sub'});
    });
  • The dashboard’s transitionTo('stats-x') will indeed navigate to /analytics.
  • No further changes are needed.
ghost/admin/tests/acceptance/dashboard-test.js (1)

1-2: Good test isolation with mock analytics apps.

The addition of mock analytics apps setup and cleanup ensures proper test isolation and prevents actual component loading during tests. This is a good testing practice.

Also applies to: 14-20

@9larsons 9larsons merged commit 97c5c34 into main Aug 7, 2025
23 checks passed
@9larsons 9larsons deleted the add-redir-dashboard branch August 7, 2025 21:08
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.

2 participants