This commit is contained in:
chk
2026-06-14 13:41:02 +02:00
parent 8a669f23d3
commit 83cef32a37
5 changed files with 127 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ describe('InputWS FCode-Routing', () => {
expect(robot.sendCommand).toHaveBeenCalled();
});
test('Fileservice-Fehler → machine-readable FILE_ERROR an Sender', async () => {
test('Fileservice-Fehler → spezifischer Fehlercode wird an Sender durchgereicht', async () => {
const err = Object.assign(new Error('not found'), { code: 'PROGRAM_NOT_FOUND' });
FCodeClient.handle.mockRejectedValue(err);
await setup();
@@ -89,7 +89,17 @@ describe('InputWS FCode-Routing', () => {
ws.send('FLoad nichtda');
const msg = JSON.parse(await replyP);
expect(msg.type).toBe('error');
expect(msg.code).toBe('FILE_ERROR');
expect(msg.code).toBe('PROGRAM_NOT_FOUND'); // err.code wird durchgereicht (nicht pauschal FILE_ERROR)
expect(msg.input).toBe('FLoad nichtda');
});
test('Fehler ohne code → Fallback FILE_ERROR', async () => {
FCodeClient.handle.mockRejectedValue(new Error('kaputt'));
await setup();
const replyP = nextMessage(ws);
ws.send('FShow');
const msg = JSON.parse(await replyP);
expect(msg.type).toBe('error');
expect(msg.code).toBe('FILE_ERROR');
});
});