Feature/add test coverage - #1231
Conversation
|
@m-hajjo is attempting to deploy a commit to the Mftee's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@m-hajjo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
mftee
left a comment
There was a problem hiding this comment.
@m-hajjo This PR currently has a merge conflict with the main branch (mergeable_state: dirty), so it can't be merged as-is. Could you please rebase or merge main into your branch and resolve the conflicting files? Requesting changes until this is resolved.
mftee
left a comment
There was a problem hiding this comment.
Conflict has been resolved and the branch is clean against main now. Good test coverage additions - approving.
PR Description
This pull request addresses several testing gaps in the backend service, significantly improving the project's test coverage and overall code quality. Each of the following tasks was completed and committed separately:
Enhanced Metrics Module Test Coverage
Moved metrics tests from the root-level mxllv.spec.ts to a dedicated backend/src/metrics/metrics.controller.spec.ts.
Implemented comprehensive tests for the MetricsController, including assertions for counter increment behavior and the validity of the Prometheus exposition format under concurrent requests.
Refactored the MetricsController to use prom-client for dynamic and accurate metric tracking.
Removed the outdated smoke test from mxllv.spec.ts, ensuring that all metrics-related tests are now centralized and robust.
Closes [BE-153] Metrics module test coverage beyond the placeholder smoke check #1118
Added Tamper-Detection and Wrong-Key Test Coverage for crypto.util
Created a new test suite for crypto.util in backend/src/common/crypto.util.spec.ts.
Added critical test cases to crypto.util.spec.ts to cover:
Tampered-ciphertext rejection: Ensures that decryptBuffer throws an error when the ciphertext has been altered.
Empty-buffer input: Verifies that the encryption and decryption processes correctly handle empty buffers.
Oversized input: Confirms that encryptBuffer throws an error when the input buffer is too large.
Removed the narrow roundtrip test from prismn.spec.ts, as it is now superseded by the more comprehensive test suite.
Closes [BE-154] crypto.util: no tamper-detection or wrong-key test coverage #1119
Implemented Test Coverage for HttpExceptionFilter
Created a new test suite for the HttpExceptionFilter in backend/src/common/filters/http-exception.filter.spec.ts.
Added tests to cover various exception types, including HttpException, generic Error, and BadRequestException from the validation pipe.
Asserted that the response body never includes stack traces or internal file paths, preventing the leakage of sensitive information.
Verified that status codes are preserved for HttpException and default to 500 for other errors, ensuring consistent and predictable error responses.
Closes [BE-155] No test coverage for HttpExceptionFilter's exception-to-response mapping #1120
Added Test Coverage for the Request Logger Middleware
Created a new test suite for the LoggerMiddleware in backend/src/common/middleware/logger.middleware.spec.ts.
Asserted that the correlation ID from correlation-id.middleware.ts is included in the logged output, improving traceability.
Ensured that sensitive headers, such as Authorization and Cookie, are not logged in plaintext, enhancing security.
Closes [BE-156] No test coverage for the request logger middleware #1121
These changes collectively improve the robustness and reliability of the backend service. I am now ready for any further instructions.