@@ -353,4 +353,68 @@ describe('Cline', () => {
353353 } ) . toThrow ( 'Either historyItem or task/images must be provided' ) ;
354354 } ) ;
355355 } ) ;
356+
357+ describe ( 'getEnvironmentDetails' , ( ) => {
358+ let originalDate : DateConstructor ;
359+ let mockDate : Date ;
360+
361+ beforeEach ( ( ) => {
362+ originalDate = global . Date ;
363+ const fixedTime = new Date ( '2024-01-01T12:00:00Z' ) ;
364+ mockDate = new Date ( fixedTime ) ;
365+ mockDate . getTimezoneOffset = jest . fn ( ) . mockReturnValue ( 420 ) ; // UTC-7
366+
367+ class MockDate extends Date {
368+ constructor ( ) {
369+ super ( ) ;
370+ return mockDate ;
371+ }
372+ static override now ( ) {
373+ return mockDate . getTime ( ) ;
374+ }
375+ }
376+
377+ global . Date = MockDate as DateConstructor ;
378+
379+ // Create a proper mock of Intl.DateTimeFormat
380+ const mockDateTimeFormat = {
381+ resolvedOptions : ( ) => ( {
382+ timeZone : 'America/Los_Angeles'
383+ } ) ,
384+ format : ( ) => '1/1/2024, 5:00:00 AM'
385+ } ;
386+
387+ const MockDateTimeFormat = function ( this : any ) {
388+ return mockDateTimeFormat ;
389+ } as any ;
390+
391+ MockDateTimeFormat . prototype = mockDateTimeFormat ;
392+ MockDateTimeFormat . supportedLocalesOf = jest . fn ( ) . mockReturnValue ( [ 'en-US' ] ) ;
393+
394+ global . Intl . DateTimeFormat = MockDateTimeFormat ;
395+ } ) ;
396+
397+ afterEach ( ( ) => {
398+ global . Date = originalDate ;
399+ } ) ;
400+
401+ it ( 'should include timezone information in environment details' , async ( ) => {
402+ const cline = new Cline (
403+ mockProvider ,
404+ mockApiConfig ,
405+ undefined ,
406+ false ,
407+ undefined ,
408+ 'test task'
409+ ) ;
410+
411+ const details = await cline [ 'getEnvironmentDetails' ] ( false ) ;
412+
413+ // Verify timezone information is present and formatted correctly
414+ expect ( details ) . toContain ( 'America/Los_Angeles' ) ;
415+ expect ( details ) . toMatch ( / U T C - 7 : 0 0 / ) ; // Fixed offset for America/Los_Angeles
416+ expect ( details ) . toContain ( '# Current Time' ) ;
417+ expect ( details ) . toMatch ( / 1 \/ 1 \/ 2 0 2 4 .* 5 : 0 0 : 0 0 A M .* \( A m e r i c a \/ L o s _ A n g e l e s , U T C - 7 : 0 0 \) / ) ; // Full time string format
418+ } ) ;
419+ } ) ;
356420} ) ;
0 commit comments