Add an async context data test for @fedify/express - #985
Conversation
integrateFederation() accepts a contextDataFactory that may return either a plain value or a Promise, but only the synchronous path was covered. Add a test that verifies the middleware waits for an async factory to resolve and passes the resolved value to federation.fetch(). Also wire up the test script/task in package.json and deno.json so mise run test:node and test-each actually run it. Changelog: none Assisted-by: Claude Code:claude-sonnet-5
✅ Deploy Preview for fedify-json-schema canceled.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Express package adds Deno and Node test commands. New middleware tests verify that ChangesExpress async context test
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
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 `@packages/express/src/index.test.ts`:
- Around line 65-88: Update the async contextDataFactory test to use a deferred
promise and track federation.fetch invocation; assert fetch remains uncalled
before resolving the promise, then resolve it and verify the existing response
and middleware behavior after completion.
🪄 Autofix
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: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 67407354-e127-4371-939c-d560137a9e46
📒 Files selected for processing (3)
packages/express/deno.jsonpackages/express/package.jsonpackages/express/src/index.test.ts
The previous test only checked the resolved value, not that federation.fetch() stays uncalled until the async contextDataFactory promise resolves. Use a deferred promise to assert the ordering directly, per CodeRabbit's review on fedify-dev#985. Changelog: none Assisted-by: Claude Code:claude-sonnet-5
sij411
left a comment
There was a problem hiding this comment.
Since integrateFederation() only assigns send, json, and removeHeader and never calls their existing implementations, could these methods be omitted from the initial response mock?
2chanhaeng
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Please check my comment.
| "prepack": "pnpm build", | ||
| "prepublish": "pnpm build" | ||
| "prepublish": "pnpm build", | ||
| "test": "node --experimental-transform-types --test" |
Summary
integrateFederation()'scontextDataFactorymay return a plain value or aPromise, but only the synchronous path had test coverage.This adds a regression test for the async path, verifying the middleware waits for the factory to resolve and passes the resolved value to
federation.fetch().Also adds the missing
testscript (package.json) andtesttask (deno.json) for@fedify/expressso the suite actually runs undermise run test:node/test-each.Fixes #855
Test plan
mise run check-each expressdeno test --allow-all(packages/express)node --experimental-transform-types --test(packages/express)AI disclosure
This change was written with assistance from Claude Code (
claude-sonnet-5), reviewed and verified by me.