fix(call): test the ring chat lookup without starting a call
- The accept path started a demo call whose net thread tripped the test scheduler on Windows CI - The lookup is its own function; the test covers 1:1 and group rings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -1337,11 +1337,7 @@ impl AppState {
1337
1337
let _ = held.commands.send(CallCommand::Hangup);
1338
1338
}
1339
1339
self.signal_ring(ring_id, RingSignal::Accept, cx);
1340
let conversation_id = entry.ring.thread_id.clone().or_else(|| {
1341
(!entry.ring.is_group)
1342
.then(|| self.one_on_one_chat_with_mri(&entry.ring.caller.mri))
1343
.flatten()
1344
});
1340
let conversation_id = self.conversation_of_ring(&entry.ring);
1345
1341
let title = conversation_id
1346
1342
.as_deref()
1347
1343
.and_then(|id| self.sidebar.chats.iter().find(|chat| chat.id == id))
@@ -1396,6 +1392,14 @@ impl AppState {
1396
1392
self.one_on_one_chat_with_mri(&missed.caller_mri)
1397
1393
}
1398
1394
1395
fn conversation_of_ring(&self, ring: &calling::IncomingRing) -> Option<String> {
1396
ring.thread_id.clone().or_else(|| {
1397
(!ring.is_group)
1398
.then(|| self.one_on_one_chat_with_mri(&ring.caller.mri))
1399
.flatten()
1400
})
1401
}
1402
1399
1403
fn one_on_one_chat_with_mri(&self, mri: &str) -> Option<String> {
1400
1404
self.one_on_one_chat_with(mri.strip_prefix(ORGID_PREFIX)?)
1401
1405
}
@@ -2792,7 +2796,7 @@ mod tests {
2792
2796
fn an_accepted_one_on_one_ring_gets_the_chat_with_the_caller(cx: &mut TestAppContext) {
2793
2797
let app = app_with_chats(cx);
2794
2798
cx.update(|cx| {
2795
app.update(cx, |state, cx| {
2799
app.update(cx, |state, _| {
2796
2800
let ring = calling::IncomingRing {
2797
2801
caller: calling::Caller {
2798
2802
mri: "8:orgid:bea-id".into(),
@@ -2801,13 +2805,15 @@ mod tests {
2801
2805
thread_id: None,
2802
2806
..demo_ring()
2803
2807
};
2804
let ring_id = ring.ring_id;
2805
state.push_ring(ring, true, cx);
2806
state.accept_ring(ring_id, calling::AcceptMode::Audio, cx);
2807
2808
assert_eq!(
2808
state.call.as_ref().unwrap().chat_thread(),
2809
state.conversation_of_ring(&ring).as_deref(),
2809
2810
Some("19:dm@unq.gbl.spaces")
2810
2811
);
2812
let group = calling::IncomingRing {
2813
is_group: true,
2814
..ring
2815
};
2816
assert_eq!(state.conversation_of_ring(&group), None);
2811
2817
})
2812
2818
});
2813
2819
}
@@ -1337,11 +1337,7 @@ impl AppState {1337
let _ = held.commands.send(CallCommand::Hangup);1337
let _ = held.commands.send(CallCommand::Hangup);1338
}1338
}1339
self.signal_ring(ring_id, RingSignal::Accept, cx);1339
self.signal_ring(ring_id, RingSignal::Accept, cx);1340
let conversation_id = entry.ring.thread_id.clone().or_else(|| {1340
let conversation_id = self.conversation_of_ring(&entry.ring);1341
(!entry.ring.is_group)1342
.then(|| self.one_on_one_chat_with_mri(&entry.ring.caller.mri))1343
.flatten()1344
});1345
let title = conversation_id1341
let title = conversation_id1346
.as_deref()1342
.as_deref()1347
.and_then(|id| self.sidebar.chats.iter().find(|chat| chat.id == id))1343
.and_then(|id| self.sidebar.chats.iter().find(|chat| chat.id == id))@@ -1396,6 +1392,14 @@ impl AppState {1396
self.one_on_one_chat_with_mri(&missed.caller_mri)1392
self.one_on_one_chat_with_mri(&missed.caller_mri)1397
}1393
}1398
1394
1395
fn conversation_of_ring(&self, ring: &calling::IncomingRing) -> Option<String> {1396
ring.thread_id.clone().or_else(|| {1397
(!ring.is_group)1398
.then(|| self.one_on_one_chat_with_mri(&ring.caller.mri))1399
.flatten()1400
})1401
}1402
1399
fn one_on_one_chat_with_mri(&self, mri: &str) -> Option<String> {1403
fn one_on_one_chat_with_mri(&self, mri: &str) -> Option<String> {1400
self.one_on_one_chat_with(mri.strip_prefix(ORGID_PREFIX)?)1404
self.one_on_one_chat_with(mri.strip_prefix(ORGID_PREFIX)?)1401
}1405
}@@ -2792,7 +2796,7 @@ mod tests {2792
fn an_accepted_one_on_one_ring_gets_the_chat_with_the_caller(cx: &mut TestAppContext) {2796
fn an_accepted_one_on_one_ring_gets_the_chat_with_the_caller(cx: &mut TestAppContext) {2793
let app = app_with_chats(cx);2797
let app = app_with_chats(cx);2794
cx.update(|cx| {2798
cx.update(|cx| {2795
app.update(cx, |state, cx| {2799
app.update(cx, |state, _| {2796
let ring = calling::IncomingRing {2800
let ring = calling::IncomingRing {2797
caller: calling::Caller {2801
caller: calling::Caller {2798
mri: "8:orgid:bea-id".into(),2802
mri: "8:orgid:bea-id".into(),@@ -2801,13 +2805,15 @@ mod tests {2801
thread_id: None,2805
thread_id: None,2802
..demo_ring()2806
..demo_ring()2803
};2807
};2804
let ring_id = ring.ring_id;2805
state.push_ring(ring, true, cx);2806
state.accept_ring(ring_id, calling::AcceptMode::Audio, cx);2807
assert_eq!(2808
assert_eq!(2808
state.call.as_ref().unwrap().chat_thread(),2809
state.conversation_of_ring(&ring).as_deref(),2809
Some("19:dm@unq.gbl.spaces")2810
Some("19:dm@unq.gbl.spaces")2810
);2811
);2812
let group = calling::IncomingRing {2813
is_group: true,2814
..ring2815
};2816
assert_eq!(state.conversation_of_ring(&group), None);2811
})2817
})2812
});2818
});2813
}2819
}