+19
-3
@@ -164,15 +164,14 @@ test('harness bridge recovers streamed text when final envelope is empty after a
|
||||
assert.equal(reply.text, 'Your computer is ready.');
|
||||
});
|
||||
|
||||
test('ask with no spoken text after tools returns to listening without a Reply', async () => {
|
||||
test('ask with no spoken text reports failure and returns to listening', async () => {
|
||||
const daemon = new JarvisDaemon();
|
||||
daemon.harness = { ask: async () => ({ ok: true, text: '', reason: 'stop' }), cancel() {}, close: async () => {} };
|
||||
daemon.voiceLoop = null;
|
||||
const replies = [];
|
||||
daemon.on('Reply', (text) => replies.push(text));
|
||||
try {
|
||||
const result = await daemon.ask('status');
|
||||
assert.equal(result, '');
|
||||
await assert.rejects(daemon.ask('status'), /no spoken answer/);
|
||||
assert.deepEqual(replies, []);
|
||||
assert.equal(daemon.state, 'LISTENING');
|
||||
} finally {
|
||||
@@ -345,3 +344,20 @@ test('mute ignores arm and does not return to listening after speech', async ()
|
||||
assert.equal(daemon.state, 'ARMED');
|
||||
} finally { await daemon.close(); }
|
||||
});
|
||||
|
||||
for (const empty of [false, true]) {
|
||||
test(`failed inference keeps conversation listening and reports the failure (empty=${empty})`, async () => {
|
||||
const daemon = new JarvisDaemon();
|
||||
daemon.settings = { ...daemon.settings, listeningMode: 'conversation' };
|
||||
daemon.listenEnabled = true;
|
||||
daemon.harness.ask = async () => { if (empty) return { text: '' }; throw new Error('inference unavailable'); };
|
||||
const errors = [];
|
||||
daemon.on('Error', (code, message) => errors.push([code, message]));
|
||||
try {
|
||||
await assert.rejects(daemon.ask('Read the page.'), empty ? /no spoken answer/ : /inference unavailable/);
|
||||
assert.equal(daemon.state, 'LISTENING');
|
||||
assert.equal(daemon.voice.state, 'LISTENING');
|
||||
assert.ok(errors.some(([code]) => code === 'QVAC'));
|
||||
} finally { await daemon.close(); }
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user