@@ -456,6 +456,46 @@ void deletePotSuccess() {
456456 assertThat (wateringLogRepository .findById (wateringLog .getId ())).isPresent ();
457457 }
458458
459+ @ Test
460+ @ DisplayName ("화분 삭제 시 수확 완료(isHarvested=true)된 PlantItem은 삭제되지 않고 도감 기록이 보존된다" )
461+ void deletePotPreservesHarvestedPlantItems () {
462+ // given
463+ User user = User .builder ()
464+ .email ("harvestpreserve@rootin.com" )
465+ .nickname ("수확보존자" )
466+ .build ();
467+ userRepository .save (user );
468+
469+ PotResponse createdPot = potService .createPot (
470+ user .getId (),
471+ PotCreateRequest .builder ().title ("도감보존 화분" ).build ()
472+ );
473+ Long potId = createdPot .getId ();
474+
475+ Plant defaultPlant = plantRepository
476+ .findFirstByNameAndGradeAndGrowthStage ("기본 씨앗" , Grade .COMMON , GrowthStage .SEED )
477+ .orElseThrow ();
478+
479+ // 수확 완료된 PlantItem 직접 저장 (도감 기록)
480+ PlantItem harvestedItem = PlantItem .builder ()
481+ .userId (user .getId ())
482+ .potId (potId )
483+ .plantId (defaultPlant .getId ())
484+ .isHarvested (true )
485+ .harvestedAt (java .time .LocalDateTime .now ().minusDays (1 ))
486+ .harvestedLevel (2 )
487+ .harvestedStageIndex (3 )
488+ .build ();
489+ PlantItem saved = plantItemRepository .save (harvestedItem );
490+
491+ // when
492+ potService .deletePot (potId , user .getId ());
493+
494+ // then — 화분은 삭제되고, 수확 완료 PlantItem(도감 기록)은 보존
495+ assertThat (potRepository .findById (potId )).isEmpty ();
496+ assertThat (plantItemRepository .findById (saved .getId ())).isPresent ();
497+ }
498+
459499 @ Test
460500 @ DisplayName ("타인의 화분을 삭제하려고 시도하면 FORBIDDEN 예외가 발생한다" )
461501 void deletePotForbidden () {
0 commit comments