fix(documents): surface timeline density fetch failures via console.warn (#385)
Previously a 5xx, network blip, or JSON parse error all collapsed into the same silent "no buckets" rendering. The widget still degrades gracefully — failure should not block the document list — but operators and Sentry now see the failure in browser devtools instead of having to reverse-engineer a missing chart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -285,6 +285,29 @@ describe('fetchDensity', () => {
|
||||
|
||||
expect(result).toEqual({ density: [], minDate: null, maxDate: null });
|
||||
});
|
||||
|
||||
it('emits console.warn with the status when the response is non-ok', async () => {
|
||||
const fetch = vi.fn().mockResolvedValue({ ok: false, status: 503 });
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
|
||||
await fetchDensity(fetch, null, true);
|
||||
|
||||
expect(warn).toHaveBeenCalledTimes(1);
|
||||
expect(warn.mock.calls[0][0]).toContain('503');
|
||||
warn.mockRestore();
|
||||
});
|
||||
|
||||
it('emits console.warn with the caught error when fetch rejects', async () => {
|
||||
const error = new TypeError('Network down');
|
||||
const fetch = vi.fn().mockRejectedValue(error);
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
|
||||
await fetchDensity(fetch, null, true);
|
||||
|
||||
expect(warn).toHaveBeenCalledTimes(1);
|
||||
expect(warn.mock.calls[0]).toContain(error);
|
||||
warn.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('tickIndicesFor', () => {
|
||||
|
||||
Reference in New Issue
Block a user