Skip to content

Used promises for async Handlebars function in tests#27586

Merged
EvanHahn merged 1 commit intomainfrom
promisify-hbs-cachepartials-tests
Apr 27, 2026
Merged

Used promises for async Handlebars function in tests#27586
EvanHahn merged 1 commit intomainfrom
promisify-hbs-cachepartials-tests

Conversation

@EvanHahn
Copy link
Copy Markdown
Contributor

ref 30ab483

This test-only cleanup should have no user impact.

ref 30ab483

This test-only cleanup should have no user impact.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Walkthrough

This change converts test setup across four Handlebars helper test files from callback-driven Mocha patterns to async/await patterns. Specifically, hbs.cachePartials calls are wrapped with promisify and awaited in before hooks instead of using the done callback parameter. The modifications affect the cancel-link, content, navigation, and pagination test files, standardizing their partial-caching synchronization to use modern promise-based control flow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Used promises for async Handlebars function in tests' accurately and specifically describes the main change across all four test files.
Description check ✅ Passed The description references a commit hash and indicates this is a test-only cleanup with no user impact, which directly relates to the changeset of converting test setup code.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch promisify-hbs-cachepartials-tests

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

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

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
ghost/core/test/unit/frontend/helpers/content.test.js (1)

17-22: LGTM — optional: consider extracting a small helper.

All three before hooks are correctly converted. Since the same promisify(hbs.cachePartials.bind(hbs)) snippet now appears in four test files, you could optionally extract a tiny helper (e.g., in test/utils) like cacheHbsPartials = () => promisify(hbs.cachePartials.bind(hbs))() to DRY it up. Not blocking.

Also applies to: 87-96, 224-232

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/core/test/unit/frontend/helpers/content.test.js` around lines 17 - 22,
Extract the repeated promisify(hbs.cachePartials.bind(hbs)) call into a small
helper function (e.g., cacheHbsPartials) and replace the inline usage in the
before hooks (where hbs.express4 is called and cachePartials is awaited) with a
single call to that helper; specifically create a function cacheHbsPartials = ()
=> promisify(hbs.cachePartials.bind(hbs))() and call await cacheHbsPartials() in
place of the repeated snippet in tests that reference hbs.cachePartials and
promisify so all occurrences (including the ones around the before hooks) use
the DRY helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ghost/core/test/unit/frontend/helpers/content.test.js`:
- Around line 17-22: Extract the repeated promisify(hbs.cachePartials.bind(hbs))
call into a small helper function (e.g., cacheHbsPartials) and replace the
inline usage in the before hooks (where hbs.express4 is called and cachePartials
is awaited) with a single call to that helper; specifically create a function
cacheHbsPartials = () => promisify(hbs.cachePartials.bind(hbs))() and call await
cacheHbsPartials() in place of the repeated snippet in tests that reference
hbs.cachePartials and promisify so all occurrences (including the ones around
the before hooks) use the DRY helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fe3eab0a-747e-4286-9a42-f4446a5d8f32

📥 Commits

Reviewing files that changed from the base of the PR and between cd186f5 and a1035bd.

📒 Files selected for processing (4)
  • ghost/core/test/unit/frontend/helpers/cancel-link.test.js
  • ghost/core/test/unit/frontend/helpers/content.test.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
  • ghost/core/test/unit/frontend/helpers/pagination.test.js

@EvanHahn EvanHahn enabled auto-merge (squash) April 27, 2026 20:30
@EvanHahn EvanHahn merged commit c30d940 into main Apr 27, 2026
43 checks passed
@EvanHahn EvanHahn deleted the promisify-hbs-cachepartials-tests branch April 27, 2026 20:50
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.

1 participant