-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/be/check controller tests, #924 #929
Conversation
WalkthroughThis pull request introduces a comprehensive suite of unit tests for the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
Server/tests/controllers/checkController.test.js (2)
14-28
: Refactor repetitive test setup codeThe
beforeEach
blocks in multiple test suites contain duplicated code for setting upreq
,res
,next
, and stubs. Consider extracting common setup logic into shared helper functions or using a higher-levelbeforeEach
to reduce redundancy and improve maintainability.Also applies to: 91-105, 146-159, 200-212, 251-263, 304-324
27-27
: Remove unused stubhandleError
The stub
handleError
is declared but not used in the tests. Removing unused variables can help keep the code clean and readable.Apply this diff to remove the unused stub:
- handleError = sinon.stub();
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- Server/tests/controllers/checkController.test.js (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
Server/tests/controllers/checkController.test.js
[failure] 311-311: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.
|
||
req = { | ||
body: {}, | ||
headers: { authorization: "Bearer token" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using hard-coded authorization headers in tests
Using hard-coded credentials like "Bearer token"
can pose security risks and may lead to unintended behavior. Consider using a mock token or securely generating one for test purposes.
Apply this diff to replace the hard-coded token with a mocked token:
- headers: { authorization: "Bearer token" },
+ headers: { authorization: `Bearer ${mockedToken}` },
Where mockedToken
is a token generated or mocked appropriately for the test context.
Committable suggestion was skipped due to low confidence.
🧰 Tools
🪛 GitHub Check: CodeQL
[failure] 311-311: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coverage 100%? cool for check controller test
This PR adds unit tests to for the check controller