@@ -2,10 +2,11 @@ import { PairingSession, PairingSlot } from '@models/PairingSession';
22import { CandidateType , InterviewFormat } from '@bot/enums' ;
33import { pairingSessionsRepo } from '@repos/pairingSessionsRepo' ;
44import { chatService } from '@/services/ChatService' ;
5- import { pairingSessionCloser , findConfirmedSlot } from '../PairingSessionCloser' ;
5+ import { pairingSessionCloser , findConfirmedSlots } from '../PairingSessionCloser' ;
66import { buildMockApp } from '@utils/slackMocks' ;
77import { App } from '@slack/bolt' ;
88import { reviewLockManager } from '@utils/reviewLockManager' ;
9+ import { userRepo } from '@repos/userRepo' ;
910
1011function makeSlot ( overrides : Partial < PairingSlot > = { } ) : PairingSlot {
1112 return {
@@ -44,19 +45,20 @@ describe('PairingSessionCloser', () => {
4445 pairingSessionsRepo . remove = jest . fn ( ) . mockResolvedValue ( undefined ) ;
4546 pairingSessionsRepo . getByThreadIdOrUndefined = jest . fn ( ) ;
4647 reviewLockManager . releaseLock = jest . fn ( ) ;
48+ userRepo . markNowAsLastReviewedDate = jest . fn ( ) . mockResolvedValue ( undefined ) ;
4749 } ) ;
4850
49- describe ( 'findConfirmedSlot ' , ( ) => {
50- it ( 'should return undefined when no slot has 2 interested teammates' , ( ) => {
51+ describe ( 'findConfirmedSlots ' , ( ) => {
52+ it ( 'should return empty array when no slot has 2 interested teammates' , ( ) => {
5153 const slot = makeSlot ( {
5254 interestedTeammates : [ { userId : 'u1' , acceptedAt : 1 , formats : [ InterviewFormat . REMOTE ] } ] ,
5355 } ) ;
5456 const interview = makeInterview ( { slots : [ slot ] } ) ;
5557
56- expect ( findConfirmedSlot ( interview ) ) . toBeUndefined ( ) ;
58+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ ] ) ;
5759 } ) ;
5860
59- it ( 'should return a slot with 2+ interested teammates for remote interviews' , ( ) => {
61+ it ( 'should return confirmed slots for remote interviews' , ( ) => {
6062 const slot = makeSlot ( {
6163 interestedTeammates : [
6264 { userId : 'u1' , acceptedAt : 1 , formats : [ InterviewFormat . REMOTE ] } ,
@@ -65,10 +67,30 @@ describe('PairingSessionCloser', () => {
6567 } ) ;
6668 const interview = makeInterview ( { format : InterviewFormat . REMOTE , slots : [ slot ] } ) ;
6769
68- expect ( findConfirmedSlot ( interview ) ) . toEqual ( slot ) ;
70+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ slot ] ) ;
6971 } ) ;
7072
71- it ( 'should return a slot with 2+ interested teammates for in-person interviews' , ( ) => {
73+ it ( 'should return all confirmed slots when multiple qualify' , ( ) => {
74+ const slot1 = makeSlot ( {
75+ id : 'slot-1' ,
76+ interestedTeammates : [
77+ { userId : 'u1' , acceptedAt : 1 , formats : [ InterviewFormat . REMOTE ] } ,
78+ { userId : 'u2' , acceptedAt : 2 , formats : [ InterviewFormat . REMOTE ] } ,
79+ ] ,
80+ } ) ;
81+ const slot2 = makeSlot ( {
82+ id : 'slot-2' ,
83+ interestedTeammates : [
84+ { userId : 'u1' , acceptedAt : 1 , formats : [ InterviewFormat . REMOTE ] } ,
85+ { userId : 'u2' , acceptedAt : 2 , formats : [ InterviewFormat . REMOTE ] } ,
86+ ] ,
87+ } ) ;
88+ const interview = makeInterview ( { format : InterviewFormat . REMOTE , slots : [ slot1 , slot2 ] } ) ;
89+
90+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ slot1 , slot2 ] ) ;
91+ } ) ;
92+
93+ it ( 'should return confirmed slots for in-person interviews' , ( ) => {
7294 const slot = makeSlot ( {
7395 interestedTeammates : [
7496 { userId : 'u1' , acceptedAt : 1 , formats : [ InterviewFormat . IN_PERSON ] } ,
@@ -77,7 +99,7 @@ describe('PairingSessionCloser', () => {
7799 } ) ;
78100 const interview = makeInterview ( { format : InterviewFormat . IN_PERSON , slots : [ slot ] } ) ;
79101
80- expect ( findConfirmedSlot ( interview ) ) . toEqual ( slot ) ;
102+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ slot ] ) ;
81103 } ) ;
82104
83105 describe ( 'hybrid interviews' , ( ) => {
@@ -90,7 +112,7 @@ describe('PairingSessionCloser', () => {
90112 } ) ;
91113 const interview = makeInterview ( { format : InterviewFormat . HYBRID , slots : [ slot ] } ) ;
92114
93- expect ( findConfirmedSlot ( interview ) ) . toBeUndefined ( ) ;
115+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ ] ) ;
94116 } ) ;
95117
96118 it ( 'should confirm a slot where at least 1 teammate is in-person capable' , ( ) => {
@@ -102,7 +124,7 @@ describe('PairingSessionCloser', () => {
102124 } ) ;
103125 const interview = makeInterview ( { format : InterviewFormat . HYBRID , slots : [ slot ] } ) ;
104126
105- expect ( findConfirmedSlot ( interview ) ) . toEqual ( slot ) ;
127+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ slot ] ) ;
106128 } ) ;
107129
108130 it ( 'should confirm a slot where both teammates are in-person capable' , ( ) => {
@@ -114,7 +136,7 @@ describe('PairingSessionCloser', () => {
114136 } ) ;
115137 const interview = makeInterview ( { format : InterviewFormat . HYBRID , slots : [ slot ] } ) ;
116138
117- expect ( findConfirmedSlot ( interview ) ) . toEqual ( slot ) ;
139+ expect ( findConfirmedSlots ( interview ) ) . toEqual ( [ slot ] ) ;
118140 } ) ;
119141 } ) ;
120142 } ) ;
@@ -154,6 +176,8 @@ describe('PairingSessionCloser', () => {
154176 'thread-1' ,
155177 expect . stringContaining ( '2026-03-31' ) ,
156178 ) ;
179+ expect ( userRepo . markNowAsLastReviewedDate ) . toHaveBeenCalledWith ( 'u1' ) ;
180+ expect ( userRepo . markNowAsLastReviewedDate ) . toHaveBeenCalledWith ( 'u2' ) ;
157181 expect ( pairingSessionsRepo . remove ) . toHaveBeenCalledWith ( 'thread-1' ) ;
158182 expect ( reviewLockManager . releaseLock ) . toHaveBeenCalledWith ( 'thread-1' ) ;
159183 } ) ;
0 commit comments