Repository navigation
test(node): add unit tests for change password and delete user - #4851
Conversation
|
Thanks for the PR. It is labeled If AI assistance was used to create this PR, you are required to run the Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4851 +/- ##
=========================================
Coverage 91.29% 91.29%
Complexity 4204 4204
=========================================
Files 1458 1458
Lines 340825 340825
Branches 272619 272618 -1
=========================================
+ Hits 311170 311173 +3
+ Misses 23439 23436 -3
Partials 6216 6216
🚀 New features to boost your workflow:
|
|
Thanks @Yasas-Sri, and welcome. The multi-byte password test is a good catch, since it fails if the check counts characters instead of bytes. As the bot notes, PRs that used AI need a team-review run, so could you add its result to the description? |
|
sorry for that late reply. i ran team-review (verdict: APPROVE), added the result to the description, and added the missing UTF-8 test for the current password. |
|
/skill team-review |
There was a problem hiding this comment.
Summary: The two new Node unit test files for change-password and delete-user assert wire bytes that match the command serializers, the identifier helper, and the Rust binary protocol. The UTF-8 rejection cases reach the byte-length checks, CI reports 25 checks as success and Node is not among the skipped checks, and the pre-existing ChangePassword.userId type narrowing stays outside this test-only diff.
This review was generated by Claude Code 2.1.310 on deepseek-flash[1m]. Review the output before you act on it.
Which issue does this PR address?
Closes #4796
Rationale
CHANGE_PASSWORD.serializeandDELETE_USER.serializehad no unit tests.client.socket.test.tscalls them through a mock server but never checks the bytes they produce.What changed?
There was no test that checked the wire bytes or the 1-255 byte password limit for these two commands.
Added
change-password.command.test.tsanddelete-user.command.test.ts, followingcreate-user.command.test.ts. They check the exact bytes for a numeric user id and both passwords, a 255-byte password being accepted, empty and 256-byte passwords being refused, and a multi-byte password (132 characters, 264 bytes) being refused. For delete user, they check the exact bytes for a numeric and a string identifier. Expected buffers are built by hand. The throw tests match the length check's error message, because a plainassert.throwswould also pass on theRangeErrorthatuint8ToBufthrows for a length above 255, even if the length check itself were broken.Local Execution
npm run test:unitandnpm run lintinforeign/nodeAI Usage
npm run test:unitandnpm run lint.Team review
Ran
/team-review 4851at 07f093b. Verdict: APPROVE.newPassword. Fixed in b160209: added the same case forcurrentPassword.deepEqualchecks both.userIdaccepts only a number, while other user commands acceptId. Not changed here, because it is outside this PR's scope.identifier.utils.test.tsalready covers it.