@@ -238,6 +238,44 @@ void searchActiveUsers_byIdOrNickname() {
238238 assertThat (repo .countSearchActiveUsers ("or-" , charlie .getId ())).isEqualTo (3 );
239239 }
240240
241+ @ Test @ DisplayName ("searchActiveUsers - 닉네임 null인 활성 사용자도 ID로 검색됨" )
242+ void searchActiveUsers_byIdAllowsNullNickname () {
243+ User profileRequired = user ("profile-required@example.com" , null );
244+ profileRequired .setSignupStatus (SignupStatusType .PROFILE_REQUIRED );
245+ em .flush (); em .clear ();
246+
247+ List <User > users = repo .searchActiveUsers (null , profileRequired .getId (), 0 , 20 );
248+
249+ assertThat (users ).extracting (User ::getId ).containsExactly (profileRequired .getId ());
250+ assertThat (repo .countSearchActiveUsers (null , profileRequired .getId ())).isEqualTo (1 );
251+ }
252+
253+ @ Test @ DisplayName ("searchActiveUsers - 닉네임 검색에는 null 닉네임 사용자 제외" )
254+ void searchActiveUsers_nicknameQueryExcludesNullNickname () {
255+ User withNickname = user ("with-nick@example.com" , "with-nick-target" );
256+ withNickname .setSignupStatus (SignupStatusType .COMPLETED );
257+ User noNickname = user ("no-nick@example.com" , null );
258+ noNickname .setSignupStatus (SignupStatusType .PROFILE_REQUIRED );
259+ em .flush (); em .clear ();
260+
261+ List <User > users = repo .searchActiveUsers ("nick-target" , null , 0 , 20 );
262+
263+ assertThat (users ).extracting (User ::getNickname ).containsExactly ("with-nick-target" );
264+ }
265+
266+ @ Test @ DisplayName ("searchActiveUsers - 쿼리 없을 때 닉네임 null 사용자 제외" )
267+ void searchActiveUsers_noQueryExcludesNullNickname () {
268+ User withNickname = user ("default-nick@example.com" , "default-nick" );
269+ withNickname .setSignupStatus (SignupStatusType .COMPLETED );
270+ User noNickname = user ("default-no-nick@example.com" , null );
271+ noNickname .setSignupStatus (SignupStatusType .PROFILE_REQUIRED );
272+ em .flush (); em .clear ();
273+
274+ List <User > users = repo .searchActiveUsers (null , null , 0 , 20 );
275+
276+ assertThat (users ).extracting (User ::getNickname ).containsExactly ("default-nick" );
277+ }
278+
241279 @ Test @ DisplayName ("searchActiveUsers - 탈퇴/삭제 사용자는 ID 검색에서도 제외" )
242280 void searchActiveUsers_byIdExcludesInactive () {
243281 User withdrawn = user ("inactive-withdrawn@example.com" , "withdrawn-user" );
0 commit comments