Skip to content

Add context data tests for @fedify/elysia#969

Merged
dahlia merged 2 commits into
fedify-dev:mainfrom
dktsudgg:852-elysia-context-data-test
Jul 26, 2026
Merged

Add context data tests for @fedify/elysia#969
dahlia merged 2 commits into
fedify-dev:mainfrom
dktsudgg:852-elysia-context-data-test

Conversation

@dktsudgg

@dktsudgg dktsudgg commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Closes #852

Summary

Task 1) mise run check-each elysia failed because Deno could not resolve the elysia import, so I added an elysia dependency to the root deno.json file.

Task 2) I also gave the fedify() function in ./packages/elysia/src/index.ts an explicit type signature, so its public API keeps the TContextData inference.

Task 3) Added tests for issue #852.


for Task 1:
image

for Task 2:
image

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 implement and verify the change.

dktsudgg added 2 commits July 25, 2026 14:52
`mise run check-each elysia` failed because Deno could not resolve
the bare `elysia` import.  The package declares elysia only in
`peerDependencies`, which Deno ignores, and no import map listed it.
Every type error the task reported traced back to that one
unresolved import.

This commit includes the following changes:

- Added `elysia` to the root deno.json imports, pointing at
  `npm:elysia@^1.3.8`, the same range as the pnpm catalog.  This
  only affects the development environment: the published package
  still declares elysia through `peerDependencies`, so nothing
  changes for users.
- Regenerated deno.lock to match.
- Switched the `fedify()` signature to `AnyElysia` with an explicit
  return type.  The public API no longer depends on Elysia's
  internal generics, and TypeScript still links each `federation`
  to its `contextDataFactory`.

Assisted-by: Claude Code:claude-fable-5
This commit includes the following changes:

- Added two tests with a minimal fake federation: fedify() calls the
  context data factory when handling a request, and the factory's
  return value reaches federation.fetch() as its contextData option.
- Added the test and test:bun scripts to package.json because
  `mise run test-each elysia` did not pick up the new tests without
  them.  The tests now run on Node.js and Bun, the runtimes Elysia
  targets.

Assisted-by: Claude Code:claude-fable-5
@dktsudgg
dktsudgg requested a review from dahlia as a code owner July 26, 2026 05:08
@netlify

netlify Bot commented Jul 26, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

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

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 62faf835-aa88-4fe9-aded-afda5596c152

📥 Commits

Reviewing files that changed from the base of the PR and between 5936534 and 541aef5.

⛔ Files ignored due to path filters (1)
  • deno.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • deno.json
  • packages/elysia/package.json
  • packages/elysia/src/index.test.ts
  • packages/elysia/src/index.ts

📝 Walkthrough

Walkthrough

The Elysia plugin now uses AnyElysia in its decorator typing and explicitly types federation responses. New tests cover context data creation and propagation, with Node/Bun test scripts and a Deno import mapping added.

Changes

Elysia integration

Layer / File(s) Summary
Update Elysia plugin contract
packages/elysia/src/index.ts
fedify() now accepts and returns AnyElysia, and the federation response is explicitly typed as Response.
Validate context data handling
packages/elysia/src/index.test.ts, packages/elysia/package.json, deno.json
Tests verify context data factory invocation and propagation to federation.fetch(). Node/Bun test scripts and a Deno elysia import are added.

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

Suggested labels: runtime/node, runtime/bun, component/integration, dependencies

Suggested reviewers: dahlia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding context data tests for @fedify/elysia.
Description check ✅ Passed The description is related to the PR and mentions the linked issue and validation command.
Linked Issues check ✅ Passed The new test in packages/elysia/src/index.test.ts verifies both contextDataFactory invocation and passing its result to federation.fetch().
Out of Scope Changes check ✅ Passed The extra config and typing updates support the test work and the stated objective of making the Elysia check pass.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
packages/elysia/src/index.ts 57.50% <100.00%> (ø)

... and 2 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.

@dahlia dahlia self-assigned this Jul 26, 2026
@dahlia dahlia added the integration/elysia Elysia integration (@fedify/elysia) label Jul 26, 2026
@dahlia dahlia added this to the Fedify 2.4 milestone Jul 26, 2026

@dahlia dahlia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@dahlia
dahlia merged commit 09cd70e into fedify-dev:main Jul 26, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration/elysia Elysia integration (@fedify/elysia)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a context data test for @fedify/elysia

2 participants