🐛 Fixed comment counts for lazy loaded posts#28545
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe PR creates a single reusable Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration:no-coverage |
✅ Succeeded | 1m 59s | View ↗ |
nx run ghost:test:ci:e2e:no-coverage |
✅ Succeeded | 10m 17s | View ↗ |
nx run ghost:test:ci:integration |
✅ Succeeded | 1m 9s | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 3m 46s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 3m 32s | View ↗ |
nx build @tryghost/signup-form |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/admin-toolbar |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
Additional runs (10) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-12 09:48:04 UTC
ref https://linear.app/ghost/issue/ONC-1832/comment-counts-missing-for-post-cards-on-archive-pages Archive pagination inserts post cards after the initial page load. Their comment count markers were detected, but the mutation observer created a debounced fetch without invoking it, so the new counts were never requested.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ghost/core/test/unit/frontend/src/comment-counts.test.js`:
- Around line 23-25: The test uses the Mocha-style hook before(...) which Vitest
doesn't alias; change the hook call from before(...) to beforeAll(...) where
scriptContent is initialized (the before block that reads comment-counts.js) so
the file is loaded in a Vitest-compatible way; update any matching before(...)
reference in comment-counts.test.js that initializes scriptContent to
beforeAll(...) and keep the same callback and fs.readFileSync logic unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9c649096-ee3f-421f-8bcc-6aa9a804b6de
📒 Files selected for processing (2)
ghost/core/core/frontend/src/comment-counts/comment-counts.jsghost/core/test/unit/frontend/src/comment-counts.test.js
ref https://linear.app/ghost/issue/ONC-1832/comment-counts-missing-for-post-cards-on-archive-pages The regression now runs through the ghost/core Vitest unit suite instead of relying on the legacy Mocha single-test path.
b04fa70 to
aa585c0
Compare

What changed
Why
Archive pagination inserts post cards after the initial page load. The mutation observer detected those new comment count markers, but it created a debounced fetch function without invoking it, so the counts for lazy loaded posts were never requested.
Testing
CI=true pnpm --dir ghost/core test:single test/unit/frontend/src/comment-counts.test.jsref https://linear.app/ghost/issue/ONC-1832/comment-counts-missing-for-post-cards-on-archive-pages