fix: Fix multiple bugs with new authentication flow
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { VoiceState } from '../../../../shared-kernel';
|
||||
import {
|
||||
isLocalVoiceOwner,
|
||||
isVoiceOnAnotherClient,
|
||||
shouldTransmitVoice
|
||||
} from './client-voice-session.rules';
|
||||
|
||||
describe('client-voice-session.rules', () => {
|
||||
const localClientInstanceId = 'device-a';
|
||||
|
||||
it('treats the matching client instance as the local voice owner', () => {
|
||||
const voiceState: VoiceState = {
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false,
|
||||
clientInstanceId: localClientInstanceId
|
||||
};
|
||||
|
||||
expect(isLocalVoiceOwner(voiceState, localClientInstanceId)).toBe(true);
|
||||
expect(isVoiceOnAnotherClient(voiceState, localClientInstanceId)).toBe(false);
|
||||
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(true);
|
||||
});
|
||||
|
||||
it('treats a different client instance as passive voice', () => {
|
||||
const voiceState: VoiceState = {
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false,
|
||||
clientInstanceId: 'device-b'
|
||||
};
|
||||
|
||||
expect(isLocalVoiceOwner(voiceState, localClientInstanceId)).toBe(false);
|
||||
expect(isVoiceOnAnotherClient(voiceState, localClientInstanceId)).toBe(true);
|
||||
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(false);
|
||||
});
|
||||
|
||||
it('allows transmission when disconnected', () => {
|
||||
const voiceState: VoiceState = {
|
||||
isConnected: false,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false
|
||||
};
|
||||
|
||||
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user