Add integration tests for packages/fresh/src/mod.ts (#863, #864, #865) - #988
Add integration tests for packages/fresh/src/mod.ts (#863, #864, #865)#988rewrite0w0 wants to merge 10 commits into
Conversation
✅ Deploy Preview for fedify-json-schema canceled.
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe Fresh adapter now includes integration tests for response handling and context-data propagation. The package adds a Deno test task for ChangesFresh integration helper tests
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
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/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
📒 Files selected for processing (1)
packages/fresh/src/mod.test.ts
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/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
📒 Files selected for processing (1)
packages/fresh/src/mod.test.ts
There was a problem hiding this comment.
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.
| const handler = integrateHandler(mockFederation, createContextData); | ||
| const response = await handler(ctx); | ||
|
|
||
| assertEquals(receivedContextData, expectedContextData); |
There was a problem hiding this comment.
This line never failed-unnecessary checks.
| const handler = integrateHandler(mockFederation, createContextData); | ||
| await handler(ctx); | ||
|
|
||
| assertEquals(receivedContextData, expectedContextData); |
There was a problem hiding this comment.
Thank you for the detailed feedback :D
Closes #863, Closes #864, Closes #865
Background
@fedify/freshprovides 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:@fedify/fresh#863): Ensures unhandled routes fall back to Fresh'sctx.next().@fedify/fresh#864): Ensures browser HTML requests render via Fresh first, returning406only when Fresh returns404.@fedify/fresh#865): Ensures application state in Fresh context flows intofederation.fetch()viacreateContextData.Changes
packages/fresh/src/mod.test.ts:integrateFetchOptions(): VerifyonNotFounddelegates toctx.next().integrateFetchOptions(): VerifyonNotAcceptablereturns Fresh response for non-404 results and returns406when Fresh returns404.integrateHandler(): VerifycreateContextDatais called with Fresh context and the result is forwarded tofederation.fetch().Testing
mise run check-each freshdeno 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.