Increase code coverage for core packages (#12872)

This commit is contained in:
Megha Bansal
2025-11-11 20:06:43 -08:00
committed by GitHub
parent e8038c727f
commit 11a0a9b911
18 changed files with 2265 additions and 47 deletions
@@ -394,6 +394,15 @@ describe('ClearcutLogger', () => {
},
expected: 'devin',
},
{
name: 'unidentified',
env: {
GITHUB_SHA: undefined,
TERM_PROGRAM: undefined,
SURFACE: undefined,
},
expected: 'SURFACE_NOT_SET',
},
])(
'logs the current surface as $expected from $name',
({ env, expected }) => {
@@ -943,6 +952,33 @@ describe('ClearcutLogger', () => {
});
});
describe('flushIfNeeded', () => {
it('should not flush if the interval has not passed', () => {
const { logger } = setup();
const flushSpy = vi
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.spyOn(logger!, 'flushToClearcut' as any)
.mockResolvedValue({ nextRequestWaitMs: 0 });
logger!.flushIfNeeded();
expect(flushSpy).not.toHaveBeenCalled();
});
it('should flush if the interval has passed', async () => {
const { logger } = setup();
const flushSpy = vi
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.spyOn(logger!, 'flushToClearcut' as any)
.mockResolvedValue({ nextRequestWaitMs: 0 });
// Advance time by more than the flush interval
await vi.advanceTimersByTimeAsync(1000 * 60 * 2);
logger!.flushIfNeeded();
expect(flushSpy).toHaveBeenCalled();
});
});
describe('logWebFetchFallbackAttemptEvent', () => {
it('logs an event with the proper name and reason', () => {
const { logger } = setup();