Skip to content

Common module has no tests: request-id middleware and shared helpers are uncovered #1127

Description

@nanaf6203-bit

Common module has no tests: request-id middleware and shared helpers are uncovered

Labels / Complexity: testing · Medium Complexity — Medium

Problem

src/common/ (8 files, 0 *.spec.ts anywhere) holds the cross-cutting middleware and shared utilities every request passes through — including request-id.middleware.ts, which stamps X-Request-Id used for tracing and log correlation. None of it is pinned by tests: a regression that drops or duplicates request ids breaks log correlation silently across the whole app.

Why this is architecturally hard

  1. Middleware needs request-level tests. Testing middleware means constructing mock Request/Response/next objects or e2e assertions on response headers; the contributor picks the existing convention.
  2. Shared helpers are used everywhere. Any behavior change to helpers in src/common/ has repo-wide blast radius, which is exactly why their current behavior must be pinned first.

Acceptance criteria

  • Tests cover request-id assignment (present, absent, and already-set headers).
  • Shared helper functions in src/common/ have unit coverage.
  • Tests run in CI via npm test.

Out of scope

Changing middleware behavior.

Getting started

  • src/common/request-id.middleware.ts — the middleware to cover
  • src/common/ — the helpers

Commands: npm test, npm run test:cov.

Good first files to read: src/common/request-id.middleware.ts, test/unit/search-facets.service.spec.ts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions