@@ -54,7 +54,7 @@ describe('acceptPairingSlot', () => {
5454 . mockResolvedValue ( makeInterview ( ) ) ;
5555 jest
5656 . spyOn ( PairingSessionCloserModule . pairingSessionCloser , 'closeIfComplete' )
57- . mockResolvedValue ( undefined ) ;
57+ . mockResolvedValue ( false ) ;
5858 userRepo . markNowAsLastReviewedDate = jest . fn ( ) . mockResolvedValue ( undefined ) ;
5959 chatService . updateDirectMessage = jest . fn ( ) . mockResolvedValue ( undefined ) ;
6060 } ) ;
@@ -123,6 +123,53 @@ describe('acceptPairingSlot', () => {
123123 expect ( userRepo . markNowAsLastReviewedDate ) . not . toHaveBeenCalled ( ) ;
124124 } ) ;
125125
126+ it ( 'should request the next teammate if the session is still active after accept' , async ( ) => {
127+ const requestNextSpy = jest
128+ . spyOn ( PairingRequestService . pairingRequestService , 'requestNextTeammate' )
129+ . mockResolvedValue ( undefined ) ;
130+
131+ const param = buildMockActionParam ( ) ;
132+ param . body . actions = [ { value : 'thread-1' , action_id : 'pairing-submit-slots' } as any ] ;
133+ param . body . user = { id : 'u1' , name : 'Alice' } as any ;
134+ param . body . message = { ts : 'msg-ts-1' } as any ;
135+ param . body . state = {
136+ values : {
137+ 'pairing-dm-slots' : {
138+ 'pairing-slot-selections' : { selected_options : [ { value : 'slot-1' } ] } ,
139+ } ,
140+ } ,
141+ } as any ;
142+
143+ await acceptPairingSlot . handleSubmitSlots ( param ) ;
144+
145+ expect ( requestNextSpy ) . toHaveBeenCalledWith ( app , expect . anything ( ) ) ;
146+ } ) ;
147+
148+ it ( 'should not request the next teammate if the session was closed' , async ( ) => {
149+ const requestNextSpy = jest
150+ . spyOn ( PairingRequestService . pairingRequestService , 'requestNextTeammate' )
151+ . mockResolvedValue ( undefined ) ;
152+ jest
153+ . spyOn ( PairingSessionCloserModule . pairingSessionCloser , 'closeIfComplete' )
154+ . mockResolvedValue ( true ) ;
155+
156+ const param = buildMockActionParam ( ) ;
157+ param . body . actions = [ { value : 'thread-1' , action_id : 'pairing-submit-slots' } as any ] ;
158+ param . body . user = { id : 'u1' , name : 'Alice' } as any ;
159+ param . body . message = { ts : 'msg-ts-1' } as any ;
160+ param . body . state = {
161+ values : {
162+ 'pairing-dm-slots' : {
163+ 'pairing-slot-selections' : { selected_options : [ { value : 'slot-1' } ] } ,
164+ } ,
165+ } ,
166+ } as any ;
167+
168+ await acceptPairingSlot . handleSubmitSlots ( param ) ;
169+
170+ expect ( requestNextSpy ) . not . toHaveBeenCalled ( ) ;
171+ } ) ;
172+
126173 it ( 'should call closeIfComplete after recording slot selections' , async ( ) => {
127174 const param = buildMockActionParam ( ) ;
128175 param . body . actions = [ { value : 'thread-1' , action_id : 'pairing-submit-slots' } as any ] ;
0 commit comments