Skip to content

Add integration tests for packages/fresh/src/mod.ts (#863, #864, #865) - #988

Open
rewrite0w0 wants to merge 10 commits into
fedify-dev:mainfrom
rewrite0w0:test/fresh-integration-tests
Open

Add integration tests for packages/fresh/src/mod.ts (#863, #864, #865)#988
rewrite0w0 wants to merge 10 commits into
fedify-dev:mainfrom
rewrite0w0:test/fresh-integration-tests

Conversation

@rewrite0w0

@rewrite0w0 rewrite0w0 commented Aug 8, 2026

Copy link
Copy Markdown

Closes #863, Closes #864, Closes #865

Background

@fedify/fresh provides middleware integration between Fedify and Fresh. To protect the baseline coexistence of standard Fresh pages and Fedify federation endpoints, dedicated regression tests were added for core integration behaviors:

  1. Not Found Delegation (Test not-found delegation in @fedify/fresh #863): Ensures unhandled routes fall back to Fresh's ctx.next().
  2. Not Acceptable Fallback (Test not-acceptable fallback in @fedify/fresh #864): Ensures browser HTML requests render via Fresh first, returning 406 only when Fresh returns 404.
  3. Context Data Flow (Test context data flow in @fedify/fresh #865): Ensures application state in Fresh context flows into federation.fetch() via createContextData.

Changes

  • Add unit tests in packages/fresh/src/mod.test.ts:
    • integrateFetchOptions(): Verify onNotFound delegates to ctx.next().
    • integrateFetchOptions(): Verify onNotAcceptable returns Fresh response for non-404 results and returns 406 when Fresh returns 404.
    • integrateHandler(): Verify createContextData is called with Fresh context and the result is forwarded to federation.fetch().

Testing

  • mise run check-each fresh
  • deno test --allow-all src/mod.test.ts (5 passed, 0 failed)

AI assistance

This PR description and test implementations were drafted with AI assistance (Gemini) and finalized after human review and testing.

@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

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

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Fresh adapter now includes integration tests for response handling and context-data propagation. The package adds a Deno test task for src/mod.test.ts.

Changes

Fresh integration helper tests

Layer / File(s) Summary
Fetch option response handling
packages/fresh/src/mod.test.ts
Adds a reusable Fresh context and tests onNotFound delegation plus onNotAcceptable handling for non-404 and 404 responses.
Handler context data flow
packages/fresh/src/mod.test.ts, packages/fresh/deno.json
Tests synchronous and asynchronous context-data factories, request forwarding, and response propagation through federation.fetch(). Adds a Deno task for the test file.

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

Possibly related issues

Possibly related PRs

  • fedify-dev/fedify#985 — Adds integration tests and a package test task for async context-data propagation in the Express adapter.

Suggested reviewers: dahlia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the added integration tests and the affected Fresh module.
Description check ✅ Passed The description directly explains the regression tests, linked issues, affected behaviors, and validation results.
Linked Issues check ✅ Passed The tests cover all objectives from issues #863, #864, and #865, including delegation, fallback responses, and context data flow.
Out of Scope Changes check ✅ Passed The changes are limited to Fresh integration tests and a related Deno test task; no unrelated code changes are identified.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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/fresh/src/mod.test.ts`:
- Around line 19-22: Update the ctx.next mock in the test to a regular method
that asserts its receiver is ctx, rather than an arrow function that ignores
this. Keep the existing nextCalled tracking and Response result, so the test
verifies onNotFound invokes ctx.next with the correct bound receiver.
🪄 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: db4cc5d4-d8ca-4bd9-a2c2-f07083d4696e

📥 Commits

Reviewing files that changed from the base of the PR and between 15ad151 and dc5b53e.

📒 Files selected for processing (1)
  • packages/fresh/src/mod.test.ts

Comment thread packages/fresh/src/mod.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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/fresh/src/mod.test.ts`:
- Around line 38-39: Update the assertions in the test around the forwarded
request and returned response to use strict identity checks: replace value
equality for passedRequest/request and response status validation with
assertStrictEquals(passedRequest, request) and assertStrictEquals(response,
notFoundResponse), preserving the delegation expectations.
🪄 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: 34835d92-f2f0-4e19-88c0-1659fe75f446

📥 Commits

Reviewing files that changed from the base of the PR and between dc5b53e and 13668e4.

📒 Files selected for processing (1)
  • packages/fresh/src/mod.test.ts

Comment thread packages/fresh/src/mod.test.ts Outdated

@2chanhaeng 2chanhaeng 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.

The test task is missing, and some comments are written in Korean. As stated in CONTRIBUTING.md, this repository requires human checking for contributions. Please check the changes carefully before submitting a PR. And especially, if the PR is about tests, please test on your local machine before submitting a PR.

Comment thread packages/fresh/src/mod.test.ts Outdated
const handler = integrateHandler(mockFederation, createContextData);
const response = await handler(ctx);

assertEquals(receivedContextData, expectedContextData);

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.

This line never failed-unnecessary checks.

Comment thread packages/fresh/src/mod.test.ts Outdated
const handler = integrateHandler(mockFederation, createContextData);
await handler(ctx);

assertEquals(receivedContextData, expectedContextData);

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.

This line also never failed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the detailed feedback :D

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 context data flow in @fedify/fresh Test not-acceptable fallback in @fedify/fresh Test not-found delegation in @fedify/fresh

2 participants