Add delegation tests for @fedify/elysia - #993
Conversation
The fedify() plugin relies on the onNotFound callback of Federation.fetch() to let non-federation requests fall through to the app's own Elysia routes. Add a test that registers no dispatcher, so the request reports not-found via onNotFound, and verifies the status, headers, and body all come from the app's own Elysia route rather than from Fedify. Assisted-by: Claude Code:claude-fable-5
The fedify() plugin also delegates via the onNotAcceptable callback. When a request matches a federation route but its Accept header rules out JSON-LD (ex: Accept: text/html), the response must come from the app's own Elysia routes. Add a test that registers an actor dispatcher so the route matches, asks for text/html, and verifies the status, headers, and body all come from the app's own Elysia route rather than from Fedify. Assisted-by: Claude Code:claude-fable-5
✅ Deploy Preview for fedify-json-schema canceled.
|
|
|
📝 WalkthroughWalkthroughThe Elysia integration tests now cover route delegation when federation returns not-found or not-acceptable responses. The tests verify preservation of route status, headers, and body. ChangesElysia fallback route tests
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Closes #854
Summary
Adds two tests to
packages/elysia/src/index.test.tsthat verify thefedify()plugin does not return a Fedify response when federation delegates the request back to the app.1) Not-found delegation test
A federation with no dispatcher registered reports not-found via
onNotFound,and the status, headers, and body all come from the app's own Elysia route.
2) Not-acceptable delegation test
A request matches the actor route while
Accept: text/htmlrules out JSON-LD,so federation declines via
onNotAcceptableand the app's own Elysia route serves the response.Test Plan
Tested with the commands below, and all of them passed.
mise run check-each elysiamise run test-each elysiadeno test --allow-all ./packages/elysiabun test ./packages/elysiamise run testAI assistance disclosure: Claude Code (claude-fable-5) helped write the tests, verify them across runtimes, and draft the commit messages and this description.