forked from Blendman974/faceclaw
Fix spuriously failing unit tests
This commit is contained in:
1 parent
e15098c96e
commit
50c608c26b
2 files changed
+7
-4
No files matched your search
@@ -366,7 +366,7 @@ test('iOS preview voice uses the phone microphone, while connected capture stays
|
|||||||
test('iOS continuous capture is shared by windows and restarts after a disconnect, a lock or backgrounding', async () => {
|
test('iOS continuous capture is shared by windows and restarts after a disconnect, a lock or backgrounding', async () => {
|
||||||
const calls = [], claims = [], providers = [];
|
const calls = [], claims = [], providers = [];
|
||||||
// Models the bridge's continuous state: listening on a source, or draining after a stop.
|
// Models the bridge's continuous state: listening on a source, or draining after a stop.
|
||||||
const bridge = { source: null, draining: false, recording: '',
|
const bridge = { source: null, draining: false, recording: '', rawSession: undefined,
|
||||||
supportsContinuous: voice => voice.provider !== 'onboard',
|
supportsContinuous: voice => voice.provider !== 'onboard',
|
||||||
get continuousSource() { return this.source; },
|
get continuousSource() { return this.source; },
|
||||||
get continuousActive() { return !!this.source || this.draining; },
|
get continuousActive() { return !!this.source || this.draining; },
|
||||||
@@ -378,7 +378,8 @@ test('iOS continuous capture is shared by windows and restarts after a disconnec
|
|||||||
stopContinuousCapture: async () => { calls.push(['stop']); bridge.drain(); },
|
stopContinuousCapture: async () => { calls.push(['stop']); bridge.drain(); },
|
||||||
handleSessionEnded() { if (bridge.source === 'glasses') bridge.drain(); },
|
handleSessionEnded() { if (bridge.source === 'glasses') bridge.drain(); },
|
||||||
stopPhoneCapture() { if (bridge.source === 'phone') bridge.drain(); },
|
stopPhoneCapture() { if (bridge.source === 'phone') bridge.drain(); },
|
||||||
recordTo: name => { bridge.recording = name; } };
|
recordTo: name => { bridge.recording = name; },
|
||||||
|
setRawSession: session => { bridge.rawSession = session; } };
|
||||||
const settings = { ...voiceSettings, voiceProviderSetting: { get: () => 'whisper-server' },
|
const settings = { ...voiceSettings, voiceProviderSetting: { get: () => 'whisper-server' },
|
||||||
whisperServerUrlSetting: { get: () => 'http://whisper.local:8000' }, whisperServerLanguageSetting: { get: () => 'en' },
|
whisperServerUrlSetting: { get: () => 'http://whisper.local:8000' }, whisperServerLanguageSetting: { get: () => 'en' },
|
||||||
saveTranscribeAudioSetting: { get: () => true } };
|
saveTranscribeAudioSetting: { get: () => true } };
|
||||||
@@ -427,11 +428,13 @@ test('iOS continuous capture is shared by windows and restarts after a disconnec
|
|||||||
session('connected'); await settle();
|
session('connected'); await settle();
|
||||||
assert.deepEqual(calls, [['glasses', true]]);
|
assert.deepEqual(calls, [['glasses', true]]);
|
||||||
|
|
||||||
// Locking drains; unlocking resumes.
|
// Locking drains; unlocking resumes. EvenHub apps' raw mic tap follows the lock too.
|
||||||
calls.length = 0; host.setGlassesLocked(true); drained(); await settle();
|
calls.length = 0; host.setGlassesLocked(true); drained(); await settle();
|
||||||
assert.deepEqual(calls, []);
|
assert.deepEqual(calls, []);
|
||||||
|
assert.equal(bridge.rawSession, null, 'locking unbinds the raw mic session');
|
||||||
host.setGlassesLocked(false); await settle();
|
host.setGlassesLocked(false); await settle();
|
||||||
assert.deepEqual(calls, [['glasses', true]]);
|
assert.deepEqual(calls, [['glasses', true]]);
|
||||||
|
assert.equal(bridge.rawSession, host.communicator, 'unlocking rebinds it to the connected session');
|
||||||
|
|
||||||
// A failed capture is not retried in a loop, only on the next session.
|
// A failed capture is not retried in a loop, only on the next session.
|
||||||
calls.length = 0; bridge.source = null; drained(); await settle();
|
calls.length = 0; bridge.source = null; drained(); await settle();
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ function fixture() {
|
|||||||
"../native/compass.ios": { bindCompassSession() {}, receiveCompassEvent() {} },
|
"../native/compass.ios": { bindCompassSession() {}, receiveCompassEvent() {} },
|
||||||
'@nativescript/core': { File: { fromPath: () => ({ writeTextSync() {} }) },
|
'@nativescript/core': { File: { fromPath: () => ({ writeTextSync() {} }) },
|
||||||
knownFolders: { documents: () => ({ path: '/tmp' }) }, path },
|
knownFolders: { documents: () => ({ path: '/tmp' }) }, path },
|
||||||
'../native/ios-voice-input': { iosVoiceInput: { handleSessionEnded() {}, stopPhoneCapture() {}, onSpeechEnd: () => () => {} } },
|
'../native/ios-voice-input': { iosVoiceInput: { handleSessionEnded() {}, stopPhoneCapture() {}, setRawSession() {}, onSpeechEnd: () => () => {} } },
|
||||||
'../native/cloud-stt-provider': { transcriptionKey: voice => voice.provider },
|
'../native/cloud-stt-provider': { transcriptionKey: voice => voice.provider },
|
||||||
'../ui/shell/voice-activity': { voiceActivity: { setActive() {}, isActive: () => false, subscribe: () => () => {} } },
|
'../ui/shell/voice-activity': { voiceActivity: { setActive() {}, isActive: () => false, subscribe: () => () => {} } },
|
||||||
'../native/faceclaw-communicator.ios': { FaceclawCommunicatorBridge, resolveIosPeripherals: async addresses => addresses },
|
'../native/faceclaw-communicator.ios': { FaceclawCommunicatorBridge, resolveIosPeripherals: async addresses => addresses },
|
||||||
|
|||||||
Reference in new issue
Block a user