Skip to content

Comments

Add comprehensive tests for User API controllers#357

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1771366739-user-api-test-coverage
Open

Add comprehensive tests for User API controllers#357
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1771366739-user-api-test-coverage

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Feb 17, 2026

Add comprehensive edge case tests for User API controllers

Summary

Adds 24 new test cases across UsersApiTest and CurrentUserApiTest to improve coverage for validation errors, authentication scenarios, and error handling edge cases that were previously untested.

UsersApiTest (14 new tests):

  • Registration validation: blank email, blank password, missing individual fields, all blank fields simultaneously
  • Registration uniqueness: simultaneous duplicate email + username
  • Login validation: blank email, blank password, all blank, invalid email format, nonexistent email
  • Response structure: verify all expected fields (email, username, bio, image, token) present on successful registration and login

CurrentUserApiTest (10 new tests):

  • Update uniqueness: duplicate username, simultaneous duplicate email + username
  • Partial updates: bio-only, image-only
  • Auth: invalid token on PUT returns 401
  • Validation: invalid email format on update
  • Idempotent updates: user can submit own existing email/username without duplicate error
  • Response structure: verify all expected fields on GET and PUT

Also includes a trivial spotless auto-format change in DefaultJwtServiceTest.java (line wrapping only).

Review & Testing Checklist for Human

  • Verify the partial update tests (should_update_user_profile_with_only_bio/image) correctly mock empty-string defaults — these rely on UpdateUserParam's @Builder.Default values being "". If those defaults ever change, these tests will silently break.
  • Check that notNullValue() assertions (used for blank/missing email in registration) are acceptable. Exact message matching was avoided because both @NotBlank and @Email validators can fire, but this makes the assertions weaker.
  • Run ./gradlew test with Java 11 to confirm all 24 new + 15 existing tests pass end to end.

Notes


Open with Devin

- UsersApiTest: Add tests for blank email, blank password, missing fields,
  all blank fields, duplicated email+username combo, nonexistent email login,
  blank login fields, invalid email format login, response structure validation
- CurrentUserApiTest: Add tests for duplicate username on update, both email
  and username duplicate on update, partial updates (bio only, image only),
  invalid token on update, invalid email format on update, self-email/username
  update allowed, response structure validation for GET and PUT

Co-Authored-By: mason.batchelor@cognition.ai <masonbatchelor81@gmail.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants