fix: Prevent microphone auto-disconnect during calls and restore the removed microphone connected condition (#2597)

- Closes: #2590
This commit is contained in:
Dermot Duffy
2026-07-22 16:12:31 -07:00
committed by GitHub
parent 8c36637092
commit 5a549c0326
14 changed files with 520 additions and 346 deletions
@@ -44,4 +44,74 @@ describe('microphone condition', () => {
evaluator.evaluate({ microphone: createMicrophoneState({ muted: false }) }).result,
).toBeTruthy();
});
it('should match when connected is true', () => {
const evaluator = createConditionEvaluator(
{ condition: 'microphone' as const, connected: true },
createEvaluatorContext(),
);
expect(evaluator.evaluate({}).result).toBeFalsy();
expect(
evaluator.evaluate({ microphone: createMicrophoneState({ connected: true }) })
.result,
).toBeTruthy();
expect(
evaluator.evaluate({ microphone: createMicrophoneState({ connected: false }) })
.result,
).toBeFalsy();
});
it('should match when connected is false', () => {
const evaluator = createConditionEvaluator(
{ condition: 'microphone' as const, connected: false },
createEvaluatorContext(),
);
expect(evaluator.evaluate({}).result).toBeFalsy();
expect(
evaluator.evaluate({ microphone: createMicrophoneState({ connected: true }) })
.result,
).toBeFalsy();
expect(
evaluator.evaluate({ microphone: createMicrophoneState({ connected: false }) })
.result,
).toBeTruthy();
});
it('should require both connected and muted to match when both are given', () => {
const evaluator = createConditionEvaluator(
{ condition: 'microphone' as const, connected: true, muted: false },
createEvaluatorContext(),
);
expect(
evaluator.evaluate({
microphone: createMicrophoneState({ connected: true, muted: false }),
}).result,
).toBeTruthy();
expect(
evaluator.evaluate({
microphone: createMicrophoneState({ connected: true, muted: true }),
}).result,
).toBeFalsy();
expect(
evaluator.evaluate({
microphone: createMicrophoneState({ connected: false, muted: false }),
}).result,
).toBeFalsy();
});
it('should match any microphone state when neither parameter is given', () => {
const evaluator = createConditionEvaluator(
{ condition: 'microphone' as const },
createEvaluatorContext(),
);
expect(evaluator.evaluate({}).result).toBeTruthy();
expect(
evaluator.evaluate({ microphone: createMicrophoneState({ connected: true }) })
.result,
).toBeTruthy();
});
});