@@ -39,7 +39,9 @@ beforeEach(() => {
3939} )
4040describe ( 'Slack access revocation' , ( ) => {
4141 it ( 'cancels only affected members without rotating the shared installation revision' , async ( ) => {
42- dbChainMockFns . returning . mockResolvedValueOnce ( [ { providerSubjectId : 'U1' } ] )
42+ dbChainMockFns . returning . mockResolvedValueOnce ( [
43+ { organizationId : 'org' , providerSubjectId : 'U1' } ,
44+ ] )
4345 await revokeSlackSearchAccess . execute ( {
4446 principal,
4547 input : { ...input , event : { type : 'tokens_revoked' , tokens : { oauth : [ 'U1' , 'U2' ] } } } ,
@@ -223,6 +225,33 @@ describe('Slack access revocation', () => {
223225 expect . objectContaining ( { left : credential . organizationId } )
224226 )
225227 } )
228+ it ( 'cancels stale-uninstall turns only for members revoked in the installation organization' , async ( ) => {
229+ queueReinstalledBot ( )
230+ dbChainMockFns . returning . mockResolvedValueOnce ( [
231+ { organizationId : 'org' , providerSubjectId : 'U1' } ,
232+ { organizationId : 'other-org' , providerSubjectId : 'U2' } ,
233+ ] )
234+ await revokeSlackSearchAccess . execute ( { principal, input } )
235+ expect ( dbChainMockFns . update . mock . calls . map ( ( [ table ] ) => table ) ) . toEqual ( [
236+ credential ,
237+ slackSearchTurn ,
238+ ] )
239+ expect ( dbChainMockFns . where ) . toHaveBeenLastCalledWith ( {
240+ type : 'and' ,
241+ conditions : [
242+ { type : 'eq' , left : slackSearchTurn . installationId , right : 'i1' } ,
243+ { type : 'inArray' , column : slackSearchTurn . status , values : [ 'pending' , 'running' ] } ,
244+ {
245+ type : 'inArray' ,
246+ column : expect . objectContaining ( {
247+ strings : [ '' , " #>> '{message,userId}'" ] ,
248+ values : [ slackSearchTurn . payload ] ,
249+ } ) ,
250+ values : [ 'U1' ] ,
251+ } ,
252+ ] ,
253+ } )
254+ } )
226255 it ( 'ignores a stale custom-app uninstall before any writes' , async ( ) => {
227256 m . app . mockResolvedValue ( {
228257 app : { id : 'A1' , kind : 'custom' , revision : 'r1' , organizationId : 'org' } ,
@@ -245,7 +274,9 @@ describe('Slack access revocation', () => {
245274 updatedAt : new Date ( input . event_time * 1000 + 1000 ) ,
246275 } ,
247276 ] )
248- dbChainMockFns . returning . mockResolvedValueOnce ( [ { providerSubjectId : 'U1' } ] )
277+ dbChainMockFns . returning . mockResolvedValueOnce ( [
278+ { organizationId : 'org' , providerSubjectId : 'U1' } ,
279+ ] )
249280 await revokeSlackSearchAccess . execute ( {
250281 principal,
251282 input : { ...input , event : { type : 'tokens_revoked' , tokens } } ,
0 commit comments