mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(voice): resolve follow-up review edge cases
This commit is contained in:
1 parent
1594db9497
commit
b5cb75bcf9
13 files changed
+232
-16
No files matched your search
@@ -1,5 +1,10 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
initialVoiceCardState,
|
||||
reduceVoiceCard,
|
||||
voiceCardView,
|
||||
} from './voiceCardPresentation.js';
|
||||
import { createVoiceSession } from './session.js';
|
||||
import { realtimeSessionEvent } from './realtimeEvents.js';
|
||||
import { createVoiceCommands } from './sessionCommands.js';
|
||||
@@ -373,3 +378,58 @@ test('action events carry the call id; progress after cancellation is dropped',
|
||||
report({ step: 'outline' });
|
||||
assert.equal(events.filter((e) => e.type === 'progress').length, 1);
|
||||
});
|
||||
|
||||
test('a rejected current action settles its card and preserves the rejection', async () => {
|
||||
const failure = new Error('Unknown panel');
|
||||
const f = fixture(async () => {
|
||||
throw failure;
|
||||
});
|
||||
let card = initialVoiceCardState();
|
||||
const events = [];
|
||||
f.session.subscribe((event) => {
|
||||
events.push(event);
|
||||
card = reduceVoiceCard(card, event);
|
||||
});
|
||||
await f.session.start();
|
||||
await assert.rejects(
|
||||
f.hooks.runAction(
|
||||
'set_panel_open',
|
||||
{ panelId: 'missing' },
|
||||
{ callId: 'failed-call' },
|
||||
),
|
||||
(error) => error === failure,
|
||||
);
|
||||
f.hooks.emit({ type: 'completion', status: 'completed' });
|
||||
assert.equal(voiceCardView(card).busy, false);
|
||||
assert.equal(card.steps[0].status, 'failed');
|
||||
const result = events.find((event) => event.type === 'action-result');
|
||||
assert.equal(result.callId, 'failed-call');
|
||||
assert.equal(result.result.ok, false);
|
||||
f.session.destroy();
|
||||
});
|
||||
|
||||
test('a late rejection cannot settle a newer turn card', async () => {
|
||||
let reject;
|
||||
const f = fixture(
|
||||
() =>
|
||||
new Promise((_, fail) => {
|
||||
reject = fail;
|
||||
}),
|
||||
);
|
||||
const events = [];
|
||||
f.session.subscribe((event) => events.push(event));
|
||||
await f.session.start();
|
||||
const pending = f.hooks.runAction(
|
||||
'set_panel_open',
|
||||
{},
|
||||
{ callId: 'old-call' },
|
||||
);
|
||||
f.hooks.emit({ type: 'interruption', reason: 'user-speech' });
|
||||
reject(new Error('late failure'));
|
||||
await assert.rejects(pending, /late failure/);
|
||||
assert.equal(
|
||||
events.some((event) => event.type === 'action-result'),
|
||||
false,
|
||||
);
|
||||
f.session.destroy();
|
||||
});
|
||||
Reference in new issue
Block a user