@@ -93,9 +93,14 @@ describe("slack sent-thread-cache", () => {
9393 expect ( hasSlackThreadParticipation ( "A1" , "C123" , "1700000000.005000" ) ) . toBe ( true ) ;
9494 } ) ;
9595
96- it ( "writes and reads persistent thread participation when runtime state is available" , async ( ) => {
96+ it ( "restores persistent thread participation without extending its original expiry" , async ( ) => {
97+ const repliedAt = 1_711_406_400_000 ;
98+ const ttlMs = 24 * 60 * 60 * 1000 ;
99+ const now = vi . spyOn ( Date , "now" ) . mockReturnValue ( repliedAt ) ;
97100 const register = vi . fn ( ) . mockResolvedValue ( undefined ) ;
98- const lookup = vi . fn ( ) . mockResolvedValue ( { repliedAt : 123 } ) ;
101+ const lookup = vi
102+ . fn ( )
103+ . mockImplementation ( async ( ) => ( Date . now ( ) < repliedAt + ttlMs ? { repliedAt } : undefined ) ) ;
99104 const openKeyedStore = vi . fn ( ( ) => ( {
100105 register,
101106 lookup,
@@ -109,14 +114,14 @@ describe("slack sent-thread-cache", () => {
109114 logging : { getChildLogger : ( ) => ( { warn : vi . fn ( ) } ) } ,
110115 } as never ) ;
111116
112- vi . spyOn ( Date , "now" ) . mockReturnValue ( 1_711_406_400_000 ) ;
113117 recordSlackThreadParticipation ( "A1" , "C123" , "1700000000.000002" ) ;
114118
115119 await vi . waitFor ( ( ) => expect ( register ) . toHaveBeenCalledTimes ( 1 ) ) ;
116120 expect ( register ) . toHaveBeenCalledWith ( "A1:C123:1700000000.000002" , {
117- repliedAt : 1_711_406_400_000 ,
121+ repliedAt,
118122 } ) ;
119123
124+ now . mockReturnValue ( repliedAt + ttlMs - 1000 ) ;
120125 clearSlackThreadParticipationCache ( ) ;
121126 await expect (
122127 hasSlackThreadParticipationWithPersistence ( {
@@ -137,6 +142,16 @@ describe("slack sent-thread-cache", () => {
137142 } ) ,
138143 ) . resolves . toBe ( true ) ;
139144 expect ( lookup ) . not . toHaveBeenCalled ( ) ;
145+
146+ now . mockReturnValue ( repliedAt + ttlMs + 1000 ) ;
147+ await expect (
148+ hasSlackThreadParticipationWithPersistence ( {
149+ accountId : "A1" ,
150+ channelId : "C123" ,
151+ threadTs : "1700000000.000002" ,
152+ } ) ,
153+ ) . resolves . toBe ( false ) ;
154+ expect ( lookup ) . toHaveBeenCalledWith ( "A1:C123:1700000000.000002" ) ;
140155 } ) ;
141156
142157 it ( "falls back to in-memory thread participation when persistent state cannot open" , async ( ) => {
0 commit comments