Skip to content

Fix #598: type Deno HTTP test fixture#607

Merged
flyingrobots merged 1 commit into
mainfrom
fix-598-deno-test-fixture
Jun 4, 2026
Merged

Fix #598: type Deno HTTP test fixture#607
flyingrobots merged 1 commit into
mainfrom
fix-598-deno-test-fixture

Conversation

@flyingrobots

@flyingrobots flyingrobots commented Jun 3, 2026

Copy link
Copy Markdown
Member

Closes #598.

Summary

  • replaces the loose Deno test harness with typed captured handler/options/server fixtures
  • installs and restores globalThis.Deno through a narrow helper
  • removes broad as any handler-call inspection and uses typed mock calls instead

Validation

  • npm exec vitest run test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts
  • npm run typecheck:test
  • npm run lint -- test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts
  • git diff --check
  • WARP_QUICK_PUSH=1 git push -u origin fix-598-deno-test-fixture

Summary by CodeRabbit

Release Notes

  • Tests
    • Refactored adapter test suite with improved type-safe mock runtime for enhanced test reliability and consistency
    • Strengthened request/response bridging validation and assertions
    • Enhanced streaming body-size enforcement test coverage with improved isolation and cleanup mechanisms

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c50af32f-88f6-42e2-8be2-7a0e090d5e52

📥 Commits

Reviewing files that changed from the base of the PR and between ab2e006 and a1cfbd4.

📒 Files selected for processing (1)
  • test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts

📝 Walkthrough

Walkthrough

This PR refactors the DenoHttpAdapter test harness to eliminate cast-heavy mocking and introduce typed fixtures. The infrastructure now captures handler/options with proper types, provides helpers to install/restore globalThis.Deno, and replaces raw handler.mock.calls access with a typed firstRequestFrom helper. All test cases are updated to use async handlers and the new mock setup, and body-limit tests are rewritten with a streaming Request class.

Changes

DenoHttpAdapter test harness type safety

Layer / File(s) Summary
Test infrastructure and mock helpers
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 1–123)
Introduces typed Deno serve fixture (handler/options capture), installDenoRuntime/restoreDenoRuntime helpers, firstRequestFrom request extraction, and refactored createMockDenoServe to eliminate any casts and provide typed mock inspection.
Constructor and listen tests
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 144–186)
Updates constructor/listen tests across hostname, port, and basic server start scenarios to use async handlers, leveraging the new typed infrastructure for server creation.
Deno.serve failure simulation
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 196–229)
Reworks error path tests to simulate Deno.serve failures via mockImplementationOnce instead of direct globalThis.Deno mutation; converts handler to async and consolidates "without callback" and failure-without-callback scenarios.
Request/response bridging assertions
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 252–288)
Updates bridging test assertions to use firstRequestFrom helper instead of raw handler.mock.calls access, validating captured bridged request normalization (method, URL, lowercased headers, body as Uint8Array) and empty-body/default-status handling.
Handler error and rejection paths
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 299–345)
Converts error response tests (handler throws, promise rejection, logger calls) from sync handlers to async handlers, maintaining 500 status assertions and logging verification.
Shutdown and close behavior tests
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 355–432)
Refactors close/shutdown tests across normal shutdown, error propagation, closing without start, and state nullification scenarios, converting all to use async handlers and the typed mock infrastructure.
Body-size enforcement with streaming validation
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 437–482)
Rewrites body-limit tests to use async handlers and introduces StreamingLimitRequest class that streams a ReadableStream while overriding arrayBuffer() to enforce that streaming is used instead of buffer reads.
Address info validation with null guards
test/unit/infrastructure/adapters/DenoHttpAdapter.test.ts (lines 492–526)
Updates address tests to use async handlers and adds explicit null guard in IPv6 case before asserting family and address.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A test harness, typed and true,
No casts of any left to do,
Mock Deno now stands clean and clear,
Each boundary bounces without fear,
Streaming requests, addresses verified—
Type safety's triumph, finally applied! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references issue #598 and accurately describes the main refactoring objective of the test fixture.
Description check ✅ Passed The description includes summary, issue reference (#598), and test plan, though it lacks some ADR check sections from template.
Linked Issues check ✅ Passed The PR fully addresses issue #598 objectives: replaces loosely typed harness with typed fixtures, removes broad 'as any' casts, adds narrow install/restore helpers, and uses typed mock calls.
Out of Scope Changes check ✅ Passed All changes are confined to the test file and directly address the typing weaknesses identified in issue #598, with no out-of-scope modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-598-deno-test-fixture

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 and usage tips.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Release Preflight

  • package version: 18.0.0
  • prerelease: false
  • npm dist-tag on release: latest
  • npm pack dry-run: passed
  • jsr publish dry-run: passed

If you tag this commit as v18.0.0, release workflow will publish.

@flyingrobots

flyingrobots commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

@codex Code Lawyer Activity Summary

Issue Severity Source File Outcome
No actionable self-discovered issue found in this PR diff. None Self PR diff against origin/main No code changes made.

Validation:

Check Result
GraphQL review-thread audit 0 unresolved, non-outdated review threads
GraphQL review audit 0 Changes Requested reviews
git diff --check origin/main...origin/fix-598-deno-test-fixture Pass
Added hard-ban token scan Hard-ban diff scan found no actionable additions.

@flyingrobots flyingrobots merged commit 0345294 into main Jun 4, 2026
18 checks passed
@flyingrobots flyingrobots deleted the fix-598-deno-test-fixture branch June 4, 2026 05:20
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.

DenoHttpAdapter test harness is still cast-heavy

1 participant