Repair connectivity correctly v1
This commit is contained in:
@@ -300,6 +300,98 @@ describe('users reducer - status', () => {
|
||||
expect(state.entities['u3']?.cameraState?.isEnabled).toBe(false);
|
||||
expect(state.entities['u3']?.screenShareState?.isSharing).toBe(false);
|
||||
});
|
||||
|
||||
it('preserves voice state on user_left while live peer transport still exists', () => {
|
||||
const remoteUser = createUser({
|
||||
id: 'u4',
|
||||
oderId: 'u4',
|
||||
displayName: 'Transient Peer',
|
||||
presenceServerIds: ['s1'],
|
||||
status: 'online',
|
||||
voiceState: {
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: true,
|
||||
roomId: 'voice-1',
|
||||
serverId: 's1'
|
||||
},
|
||||
cameraState: { isEnabled: true }
|
||||
});
|
||||
const withUser = usersReducer(baseState, UsersActions.userJoined({ user: remoteUser }));
|
||||
const state = usersReducer(withUser, UsersActions.userLeft({
|
||||
userId: 'u4',
|
||||
serverId: 's1',
|
||||
connectedPeerIds: ['u4']
|
||||
}));
|
||||
|
||||
expect(state.entities['u4']?.presenceServerIds).toEqual(['s1']);
|
||||
expect(state.entities['u4']?.isOnline).toBe(true);
|
||||
expect(state.entities['u4']?.status).toBe('online');
|
||||
expect(state.entities['u4']?.voiceState?.isConnected).toBe(true);
|
||||
expect(state.entities['u4']?.voiceState?.roomId).toBe('voice-1');
|
||||
expect(state.entities['u4']?.cameraState?.isEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('matches live user_left transports by oderId and peerId', () => {
|
||||
const remoteUser = createUser({
|
||||
id: 'db-id-5',
|
||||
oderId: 'oder-5',
|
||||
peerId: 'peer-5',
|
||||
displayName: 'Peer Id Match',
|
||||
presenceServerIds: ['s1'],
|
||||
voiceState: {
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false,
|
||||
roomId: 'voice-1',
|
||||
serverId: 's1'
|
||||
}
|
||||
});
|
||||
const withUser = usersReducer(baseState, UsersActions.userJoined({ user: remoteUser }));
|
||||
const byOderId = usersReducer(withUser, UsersActions.userLeft({
|
||||
userId: 'db-id-5',
|
||||
serverId: 's1',
|
||||
connectedPeerIds: ['oder-5']
|
||||
}));
|
||||
const byPeerId = usersReducer(withUser, UsersActions.userLeft({
|
||||
userId: 'db-id-5',
|
||||
serverId: 's1',
|
||||
connectedPeerIds: ['peer-5']
|
||||
}));
|
||||
|
||||
expect(byOderId.entities['db-id-5']?.voiceState?.isConnected).toBe(true);
|
||||
expect(byPeerId.entities['db-id-5']?.voiceState?.isConnected).toBe(true);
|
||||
});
|
||||
|
||||
it('clears voice state on user_left when the peer transport is gone', () => {
|
||||
const remoteUser = createUser({
|
||||
id: 'u6',
|
||||
oderId: 'u6',
|
||||
displayName: 'Gone Peer',
|
||||
presenceServerIds: ['s1'],
|
||||
voiceState: {
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: true,
|
||||
roomId: 'voice-1',
|
||||
serverId: 's1'
|
||||
}
|
||||
});
|
||||
const withUser = usersReducer(baseState, UsersActions.userJoined({ user: remoteUser }));
|
||||
const state = usersReducer(withUser, UsersActions.userLeft({
|
||||
userId: 'u6',
|
||||
serverId: 's1',
|
||||
connectedPeerIds: []
|
||||
}));
|
||||
|
||||
expect(state.entities['u6']?.presenceServerIds).toBeUndefined();
|
||||
expect(state.entities['u6']?.isOnline).toBe(false);
|
||||
expect(state.entities['u6']?.voiceState?.isConnected).toBe(false);
|
||||
expect(state.entities['u6']?.voiceState?.roomId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('manual status overrides auto idle', () => {
|
||||
|
||||
Reference in New Issue
Block a user