Skip to content

Commit d9e2bac

Browse files
committed
Add tests and changeset
1 parent f501c93 commit d9e2bac

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.changeset/ninety-candles-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Add the current time to the system prompt

src/core/__tests__/Cline.test.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/UTC-7:00/); // Fixed offset for America/Los_Angeles
416+
expect(details).toContain('# Current Time');
417+
expect(details).toMatch(/1\/1\/2024.*5:00:00 AM.*\(America\/Los_Angeles, UTC-7:00\)/); // Full time string format
418+
});
419+
});
356420
});

0 commit comments

Comments
 (0)