Simplify instance details and clarify diagnostics
This commit is contained in:
@@ -184,3 +184,28 @@ describe('log refresh controls', () => {
|
||||
expect(onLoading).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the last tail on a non-JSON gateway failure and can recover with a retry', async () => {
|
||||
const { fetcher, onData, onError } = setup();
|
||||
fetcher.mockResolvedValueOnce(response('saved'))
|
||||
.mockResolvedValueOnce(new Response('<html>Bad Gateway</html>', { status: 502 }))
|
||||
.mockResolvedValueOnce(response('recovered'));
|
||||
controller.configure(target, false, 5000);
|
||||
await controller.refresh();
|
||||
await controller.refresh();
|
||||
expect(onError).toHaveBeenLastCalledWith('HTTP 502: Expected a JSON log response.');
|
||||
expect(onData).toHaveBeenCalledTimes(1);
|
||||
expect(onData).toHaveBeenLastCalledWith('console', expect.objectContaining({ lines: ['saved'] }));
|
||||
await controller.refresh();
|
||||
expect(onError).toHaveBeenLastCalledWith('');
|
||||
expect(onData).toHaveBeenLastCalledWith('console', expect.objectContaining({ lines: ['recovered'] }));
|
||||
});
|
||||
|
||||
it('rejects malformed successful log payloads before they reach the renderer', async () => {
|
||||
const { fetcher, onData, onError } = setup();
|
||||
fetcher.mockResolvedValue(new Response(JSON.stringify({ ok: true, lines: [42] })));
|
||||
controller.configure(target, false, 5000);
|
||||
await controller.refresh();
|
||||
expect(onData).not.toHaveBeenCalled();
|
||||
expect(onError).toHaveBeenLastCalledWith('Invalid log response: expected an array of lines.');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user