@@ -96,9 +96,10 @@ void apply_poolCallbackSeedsPoolAndInsertsFirstQuestion() {
9696 }
9797
9898 @ Test
99- void apply_followupAutoEndsSessionAtMaxQuestions () {
99+ void apply_followupDoesNotCountOrAutoEnd () {
100100 InterviewSession session = sessionFixture (11L , SessionStatus .IN_PROGRESS );
101- // maxQuestions=5; total=4, then one follow-up reaches the limit.
101+ // 꼬리질문은 maxQuestions(메인질문 수) 한도에 포함되지 않으며, 도착해도 세션을
102+ // 끝내지 않는다(종료는 메인질문의 꼬리 사이클 후 advanceToNextGeneral 에서만).
102103 ReflectionTestUtils .setField (session , "totalQuestionCount" , 4 );
103104
104105 QuestionsCallbackEnvelope env = followupEnvelope (11L , 200L , "Follow-up?" );
@@ -114,8 +115,8 @@ void apply_followupAutoEndsSessionAtMaxQuestions() {
114115
115116 service .apply (env );
116117
117- assertThat (session .getStatus ()).isEqualTo (SessionStatus .COMPLETED );
118- assertThat (session .getTotalQuestionCount ()).isEqualTo (5 );
118+ assertThat (session .getStatus ()).isEqualTo (SessionStatus .IN_PROGRESS );
119+ assertThat (session .getTotalQuestionCount ()).isEqualTo (4 );
119120 }
120121
121122 @ Test
@@ -188,7 +189,7 @@ void apply_clarificationReExplainsWithoutCountingQuestion() {
188189 // ── 새 placeholder 경로 테스트 ─────────────────────────────────────────────
189190
190191 @ Test
191- void apply_followupNormal_updatesPlaceholderInPlaceAndCounts () {
192+ void apply_followupNormal_updatesPlaceholderInPlaceWithoutCounting () {
192193 InterviewSession session = sessionFixture (20L , SessionStatus .IN_PROGRESS );
193194 // placeholder: followupPlaceholder 의 sentinel content
194195 InterviewMessage placeholder = InterviewMessage .followupPlaceholder (
@@ -213,8 +214,8 @@ void apply_followupNormal_updatesPlaceholderInPlaceAndCounts() {
213214 // placeholder 가 in-place 로 업데이트되어야 함
214215 assertThat (placeholder .getContent ()).isEqualTo ("꼬리질문 내용?" );
215216 assertThat (placeholder .getStatus ()).isEqualTo (com .stackup .stackup .session .domain .MessageStatus .COMPLETED );
216- // 질문 수 카운트 증가
217- assertThat (session .getTotalQuestionCount ()).isEqualTo (1 );
217+ // 꼬리질문은 메인질문 카운트(maxQuestions 한도)에 포함되지 않는다.
218+ assertThat (session .getTotalQuestionCount ()).isEqualTo (0 );
218219 // save 는 placeholder 자체에 대해 호출됨 (새 InterviewMessage INSERT 아님)
219220 ArgumentCaptor <InterviewMessage > cap = ArgumentCaptor .forClass (InterviewMessage .class );
220221 verify (messageRepository ).save (cap .capture ());
@@ -281,6 +282,19 @@ void apply_followupDontKnow_deletesPlaceholderAndAdvances() {
281282 assertThat (session .getStatus ()).isEqualTo (SessionStatus .COMPLETED );
282283 }
283284
285+ @ Test
286+ void advanceToNextGeneral_endsWithMaxReached_whenMainQuestionsHitLimit () {
287+ InterviewSession session = sessionFixture (33L , SessionStatus .IN_PROGRESS );
288+ // maxQuestions=5; 메인질문 5개를 이미 던진 상태 → 다음 advance 에서 풀을 보지 않고 종료.
289+ ReflectionTestUtils .setField (session , "totalQuestionCount" , 5 );
290+ when (sessionRepository .findById (33L )).thenReturn (Optional .of (session ));
291+
292+ service .advanceToNextGeneral (33L );
293+
294+ assertThat (session .getStatus ()).isEqualTo (SessionStatus .COMPLETED );
295+ verify (poolRepository , never ()).findFirstBySessionIdAndUsedFalseOrderByIdxAsc (any ());
296+ }
297+
284298 private QuestionsCallbackEnvelope poolEnvelope (Long sessionId , List <GeneratedQuestion > questions ) {
285299 QuestionsCallbackPayload payload = new QuestionsCallbackPayload (
286300 sessionId , "POOL" , questions , null , null , null , null , null , null
0 commit comments