Skip to content

Feat: add static-file serving e2e tests#115

Merged
VikramAditya33 merged 1 commit into
mainfrom
fix/test-static-file
May 11, 2026
Merged

Feat: add static-file serving e2e tests#115
VikramAditya33 merged 1 commit into
mainfrom
fix/test-static-file

Conversation

@VikramAditya33
Copy link
Copy Markdown
Collaborator

@VikramAditya33 VikramAditya33 commented May 11, 2026

Closes #114
Tests added:

  • Serving files with correct MIME types
  • Range requests (partial content)
  • ETag and conditional requests
  • 404 for missing files
  • Directory traversal prevention
  • Dotfile handling
  • A bit more

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end test suite for static file serving functionality, ensuring robust validation of MIME types, HTTP caching behavior, byte-range request handling, path traversal protection, conditional request support, proper URL encoding handling, correct route precedence when combined with API routes, dotfile access controls, and symlink security restrictions across various configuration scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fda9f03b-37be-455a-a153-ea198efe670f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-static-file

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.

@VikramAditya33 VikramAditya33 force-pushed the fix/test-static-file branch from 4da623f to c58e5d7 Compare May 11, 2026 07:22
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/http/static-file-serving.e2e.spec.ts (1)

1-1: 💤 Low value

Consider using more targeted TypeScript suppressions.

The @ts-nocheck directive disables all TypeScript checking for this file, which can hide genuine type errors. If only specific NestJS decorator patterns cause issues, consider using @ts-expect-error on those specific lines with explanatory comments, or investigate configuring TypeScript/Jest to handle decorators properly.

🤖 Prompt for 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.

In `@test/http/static-file-serving.e2e.spec.ts` at line 1, Replace the blanket
top-file "@ts-nocheck" with targeted suppressions: remove the directive at the
top of the test file and instead add "@ts-expect-error" directly above the
specific NestJS decorator usages (with a short comment explaining why the
suppression is needed), or alternatively update the Jest/tsconfig settings to
support decorators so no suppressions are necessary; search for decorator lines
in this test file to apply the targeted "@ts-expect-error" annotations and
explanatory comments near those symbols.
🤖 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 `@test/http/static-file-serving.e2e.spec.ts`:
- Around line 372-373: Move the fixture creation for the file named "space
test.txt" out of the test "should handle URL-encoded spaces in path" and into
the existing beforeAll hook where other test files are created: locate the
fs.writeFileSync(...) call in that test and add an equivalent write in the
beforeAll setup (alongside other fs.writeFileSync calls), then remove the
file-creation line from the test so the test only asserts behavior and relies on
the shared fixture created during beforeAll.
- Around line 271-277: The test "should return 200 for matching If-Match with
strong ETag" is using If-Match: * which always succeeds and doesn't validate
weak vs strong ETag semantics; update the test in
static-file-serving.e2e.spec.ts to either (A) verify the server generates weak
ETags by first calling httpGet('/test.txt') and asserting the returned ETag
header starts with 'W/' (to prove default weak ETags), or (B) test If-Match
conditional behavior by fetching the actual ETag (via httpGet('/test.txt')),
then calling httpGet('/test.txt', { 'If-Match': <that-etag-without-W/> }) to
assert failure for weak vs strong comparison or calling httpGet with the exact
returned ETag to assert success; use the existing test name and httpGet helper
to locate and modify the test.

---

Nitpick comments:
In `@test/http/static-file-serving.e2e.spec.ts`:
- Line 1: Replace the blanket top-file "@ts-nocheck" with targeted suppressions:
remove the directive at the top of the test file and instead add
"@ts-expect-error" directly above the specific NestJS decorator usages (with a
short comment explaining why the suppression is needed), or alternatively update
the Jest/tsconfig settings to support decorators so no suppressions are
necessary; search for decorator lines in this test file to apply the targeted
"@ts-expect-error" annotations and explanatory comments near those symbols.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b85aea96-efc7-40b1-84f1-9b5c3f497828

📥 Commits

Reviewing files that changed from the base of the PR and between dce7973 and c58e5d7.

📒 Files selected for processing (1)
  • test/http/static-file-serving.e2e.spec.ts

Comment thread test/http/static-file-serving.e2e.spec.ts
Comment thread test/http/static-file-serving.e2e.spec.ts Outdated
@VikramAditya33 VikramAditya33 force-pushed the fix/test-static-file branch from c58e5d7 to 0152c7f Compare May 11, 2026 07:34
@VikramAditya33 VikramAditya33 merged commit a3350f6 into main May 11, 2026
3 checks passed
@VikramAditya33 VikramAditya33 deleted the fix/test-static-file branch May 11, 2026 07:36
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.

Static File Serving E2E test

1 participant