Skip to content

Add delegation tests for @fedify/elysia - #993

Open
dktsudgg wants to merge 2 commits into
fedify-dev:mainfrom
dktsudgg:854-elysia-not-found-delegation-test
Open

Add delegation tests for @fedify/elysia#993
dktsudgg wants to merge 2 commits into
fedify-dev:mainfrom
dktsudgg:854-elysia-not-found-delegation-test

Conversation

@dktsudgg

@dktsudgg dktsudgg commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Closes #854

Summary

Adds two tests to packages/elysia/src/index.test.ts that verify the fedify() 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/html rules out JSON-LD,
so federation declines via onNotAcceptable and 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 elysia
  • mise run test-each elysia
  • deno test --allow-all ./packages/elysia
  • bun test ./packages/elysia
  • mise run test

AI assistance disclosure: Claude Code (claude-fable-5) helped write the tests, verify them across runtimes, and draft the commit messages and this description.

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
@dktsudgg
dktsudgg requested a review from dahlia as a code owner August 10, 2026 14:40
@netlify

netlify Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit dd84fe2
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a79e2e209a22500070a16e7

@dktsudgg

Copy link
Copy Markdown
Contributor Author

2) Not-acceptable delegation test goes slightly beyond the literal scope of issue #854,
but I added it because it is the sibling path of the same delegation contract.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Elysia fallback route tests

Layer / File(s) Summary
Fallback route validation
packages/elysia/src/index.test.ts
Added federation test setup and tests for onNotFound and onNotAcceptable fallbacks. The tests verify that Elysia preserves route status, custom headers, and response bodies.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

  • fedify-dev/fedify#969 — Adds tests for the same fedify() request-handling integration in packages/elysia/src/index.test.ts.
  • fedify-dev/fedify#988 — Adds related adapter integration tests for preserving route responses and handling 404/406 outcomes.

Suggested labels: integration/elysia

Suggested reviewers: dahlia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds package-level tests in the requested file and verifies that onNotFound delegation preserves application route responses.
Out of Scope Changes check ✅ Passed The changes are limited to related delegation tests for the @fedify/elysia integration and do not introduce unrelated code.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly identifies the addition of delegation tests for the @fedify/elysia package.
Description check ✅ Passed The description accurately explains the two delegation tests, their expected behavior, and the test commands that passed.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit 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.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Test not-found delegation in @fedify/elysia

1 participant