Skip to content

Add tests for the deprecation middleware Sunset and Link header emission #514

Description

@mikewheeleer

Test the deprecation header middleware

Description

The deprecation middleware in src/middleware/deprecation.js implements RFC 8594 by setting Deprecation: true, an optional Sunset header (parsed from an ISO-8601 string, silently skipped when unparseable), and an optional Link header pointing at migration docs. It is used to mark legacy unversioned routes ahead of the /v1 namespace, yet there is no dedicated test asserting the exact header values and the skip-on-invalid-date behavior. This issue adds comprehensive coverage of the middleware's header contract.

Requirements and context

  • Repository scope: Liquifact/Liquifact-backend only.
  • Assert Deprecation: true is always set, that a valid sunset produces a correctly-formatted Sunset UTC header, and that an invalid/unparseable sunset is silently omitted (no malformed header).
  • Assert the Link header is <url>; rel="deprecation" when link is provided and absent otherwise.
  • Cover the no-options case (only Deprecation set) and confirm next() is always called.
  • Keep the tests pure middleware-level; no production change unless a real gap surfaces.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/deprecation-10-header-coverage
  • Implement changes
    • Write code in: test-only changes unless a real header bug surfaces.
    • Write comprehensive tests in: src/__tests__/deprecation.test.js.
    • Add documentation: summarize the header contract in the PR description.
    • Add comments on the date fixtures.
    • Validate security: no caller-controlled value is reflected unescaped into a header.
  • Test and commit

Test and commit

  • Run npm test and npm run lint.
  • Cover edge cases: valid sunset, invalid sunset, link present/absent, no options, next always called.
  • Include the full npm test output and a short notes section in the PR description.

Example commit message

test(deprecation): cover Sunset/Link header emission and invalid-date skip

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the Liquifact community on Discord for questions, reviews, and faster merges: https://discord.gg/JrGPH4V3
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions