@@ -134,7 +134,7 @@ describe('generic live search dates', () => {
134134 const result = await searchSlack ( api , input )
135135 expect ( api . json ) . toHaveBeenCalledTimes ( 1 )
136136 expect ( api . json . mock . calls [ 0 ] ?. [ 1 ] . body ) . toMatchObject ( {
137- modifiers : 'after:2026-09-21 before:2026-09-24 ' ,
137+ modifiers : 'after:2026-09-20 before:2026-09-25 ' ,
138138 after : Date . parse ( filters . startDate ) / 1000 - 1 ,
139139 before : Date . parse ( filters . endDate ) / 1000 ,
140140 sort : 'timestamp' ,
@@ -166,3 +166,29 @@ describe('generic live search dates', () => {
166166 expect ( api . json ) . toHaveBeenCalledTimes ( 3 )
167167 } )
168168} )
169+
170+ describe ( 'Slack date windows' , ( ) => {
171+ const DAY = 86_400_000
172+ const HOUR = 3_600_000
173+ /** Slack reads `after:`/`before:` days in the member's zone, which may be UTC-12 to UTC+14. */
174+ const firstIncludedInstant = ( afterDay : string ) => Date . parse ( afterDay ) + DAY + 12 * HOUR
175+ const firstExcludedInstant = ( beforeDay : string ) => Date . parse ( beforeDay ) - 14 * HOUR
176+
177+ it . each ( [
178+ [ 'UTC midnight' , '2026-09-22T00:00:00Z' , '2026-09-23T00:00:00Z' ] ,
179+ [ 'midnight ahead of UTC' , '2026-09-22T00:00:00+09:00' , '2026-09-23T00:00:00+09:00' ] ,
180+ [ 'midnight behind UTC' , '2026-09-22T00:00:00-11:00' , '2026-09-23T00:00:00-11:00' ] ,
181+ ] ) (
182+ 'day modifiers never narrow a window starting at %s in any member zone' ,
183+ async ( _ , startDate , endDate ) => {
184+ const api = client ( )
185+ api . json . mockResolvedValue ( { ok : true , results : { messages : [ ] } } )
186+ await searchSlack ( api , { ...input , filters : { startDate, endDate } } )
187+ const modifiers = String ( api . json . mock . calls [ 0 ] ?. [ 1 ] . body . modifiers )
188+ const after = modifiers . match ( / a f t e r : ( \S + ) / ) ?. [ 1 ] ?? ''
189+ const before = modifiers . match ( / b e f o r e : ( \S + ) / ) ?. [ 1 ] ?? ''
190+ expect ( firstIncludedInstant ( after ) ) . toBeLessThanOrEqual ( Date . parse ( startDate ) )
191+ expect ( firstExcludedInstant ( before ) ) . toBeGreaterThanOrEqual ( Date . parse ( endDate ) )
192+ }
193+ )
194+ } )
0 commit comments