Merge branch 'kvt/issue-6-contactkaart-kopieren' into 'master'
@@ -502,6 +502,16 @@ de app de Teams-link (`customTapAction`) in de browser. `teams_core::teams_link_
502
502
of `threadId` in `context`). Kent de app dat gesprek, dan opent het daar; anders nog steeds de browser.
503
503
Upstream aangeraakt: `crates/app/src/views/shell.rs` (`ActivityPanelEvent::Open`), `crates/core/src/lib.rs`.
504
504
505
### Contactkaart: gegevens kopiëren — issue #6
506
507
Mail, telefoonnummers en kantoor op de contactkaart zijn selecteerbare tekst (`SelectableText`, doet
508
mee met de vensterselectie en Ctrl+C). Achter elk gegeven staat een kopieer-icoontje: dat zet de waarde
509
op het klembord en meldt «Gekopieerd: …» (Tim: «beide»). De kaart blokkeert tekstselectie nog steeds
510
voor een klik elders, zodat je niet de chat erachter selecteert (`guard_card_press`: alleen een druk die
511
op een contactgegeven begint, mag selecteren). Upstream aangeraakt: `crates/app/src/views/profile_card.rs`
512
(`contact_row`, `contact_value`, `guard_card_press`), `crates/app-state/src/profile_state.rs`
513
(`copy_profile_detail`). Teksten in `kvt.yml` (`kvt.profile.*`).
514
505
515
## Eigen modules in het kort
506
516
507
517
@@ -502,6 +502,16 @@ de app de Teams-link (`customTapAction`) in de browser. `teams_core::teams_link_502
of `threadId` in `context`). Kent de app dat gesprek, dan opent het daar; anders nog steeds de browser.502
of `threadId` in `context`). Kent de app dat gesprek, dan opent het daar; anders nog steeds de browser.503
Upstream aangeraakt: `crates/app/src/views/shell.rs` (`ActivityPanelEvent::Open`), `crates/core/src/lib.rs`.503
Upstream aangeraakt: `crates/app/src/views/shell.rs` (`ActivityPanelEvent::Open`), `crates/core/src/lib.rs`.504
504
505
### Contactkaart: gegevens kopiëren — issue #6506
507
Mail, telefoonnummers en kantoor op de contactkaart zijn selecteerbare tekst (`SelectableText`, doet508
mee met de vensterselectie en Ctrl+C). Achter elk gegeven staat een kopieer-icoontje: dat zet de waarde509
op het klembord en meldt «Gekopieerd: …» (Tim: «beide»). De kaart blokkeert tekstselectie nog steeds510
voor een klik elders, zodat je niet de chat erachter selecteert (`guard_card_press`: alleen een druk die511
op een contactgegeven begint, mag selecteren). Upstream aangeraakt: `crates/app/src/views/profile_card.rs`512
(`contact_row`, `contact_value`, `guard_card_press`), `crates/app-state/src/profile_state.rs`513
(`copy_profile_detail`). Teksten in `kvt.yml` (`kvt.profile.*`).514
505
## Eigen modules in het kort515
## Eigen modules in het kort506
516
507
517
@@ -516,3 +516,12 @@ kvt:
516
516
en: Closed
517
517
de: Erledigt
518
518
nl: Afgehandeld
519
profile:
520
copy:
521
en: Copy
522
de: Kopieren
523
nl: Kopiëren
524
copied:
525
en: "Copied: %{value}"
526
de: "Kopiert: %{value}"
527
nl: "Gekopieerd: %{value}"
@@ -516,3 +516,12 @@ kvt:516
en: Closed516
en: Closed517
de: Erledigt517
de: Erledigt518
nl: Afgehandeld518
nl: Afgehandeld519
profile:520
copy:521
en: Copy522
de: Kopieren523
nl: Kopiëren524
copied:525
en: "Copied: %{value}"526
de: "Kopiert: %{value}"527
nl: "Gekopieerd: %{value}"@@ -119,6 +119,13 @@ impl AppState {
119
119
self.raise_notice("Email copied".to_owned(), None, cx);
120
120
}
121
121
122
/// KVT issue #6: een regel van de contactkaart (mail, telefoon, kantoor) naar het klembord.
123
pub fn copy_profile_detail(&mut self, value: &str, cx: &mut Context<Self>) {
124
cx.write_to_clipboard(ClipboardItem::new_string(value.to_owned()));
125
let notice = app_base::ui_locale::tr("kvt.profile.copied").replace("%{value}", value);
126
self.raise_notice(notice, None, cx);
127
}
128
122
129
pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {
123
130
self.with_one_on_one(user_id, cx, |state, chat_id, cx| {
124
131
state.select(Selection::Chat(chat_id.to_owned()), cx)
@@ -182,3 +189,35 @@ impl AppState {
182
189
.detach();
183
190
}
184
191
}
192
193
#[cfg(test)]
194
mod tests {
195
use std::sync::Arc;
196
197
use gpui_kit::{AppContext as _, TestAppContext};
198
use store::Store;
199
200
use crate::app_state::{AppState, Mode};
201
202
#[gpui_kit::test]
203
fn a_contact_detail_lands_on_the_clipboard(cx: &mut TestAppContext) {
204
cx.update(gpui_kit::init);
205
let store = Arc::new(Store::open_in_memory().unwrap());
206
let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
207
cx.update(|cx| {
208
app.update(cx, |state, cx| {
209
state.copy_profile_detail("ada@example.com", cx);
210
assert!(
211
state
212
.notice
213
.as_ref()
214
.unwrap()
215
.text
216
.contains("ada@example.com")
217
);
218
})
219
});
220
let copied = cx.read_from_clipboard().and_then(|item| item.text());
221
assert_eq!(copied.as_deref(), Some("ada@example.com"));
222
}
223
}
@@ -119,6 +119,13 @@ impl AppState {119
self.raise_notice("Email copied".to_owned(), None, cx);119
self.raise_notice("Email copied".to_owned(), None, cx);120
}120
}121
121
122
/// KVT issue #6: een regel van de contactkaart (mail, telefoon, kantoor) naar het klembord.123
pub fn copy_profile_detail(&mut self, value: &str, cx: &mut Context<Self>) {124
cx.write_to_clipboard(ClipboardItem::new_string(value.to_owned()));125
let notice = app_base::ui_locale::tr("kvt.profile.copied").replace("%{value}", value);126
self.raise_notice(notice, None, cx);127
}128
122
pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {129
pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {123
self.with_one_on_one(user_id, cx, |state, chat_id, cx| {130
self.with_one_on_one(user_id, cx, |state, chat_id, cx| {124
state.select(Selection::Chat(chat_id.to_owned()), cx)131
state.select(Selection::Chat(chat_id.to_owned()), cx)@@ -182,3 +189,35 @@ impl AppState {182
.detach();189
.detach();183
}190
}184
}191
}192
193
#[cfg(test)]194
mod tests {195
use std::sync::Arc;196
197
use gpui_kit::{AppContext as _, TestAppContext};198
use store::Store;199
200
use crate::app_state::{AppState, Mode};201
202
#[gpui_kit::test]203
fn a_contact_detail_lands_on_the_clipboard(cx: &mut TestAppContext) {204
cx.update(gpui_kit::init);205
let store = Arc::new(Store::open_in_memory().unwrap());206
let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));207
cx.update(|cx| {208
app.update(cx, |state, cx| {209
state.copy_profile_detail("ada@example.com", cx);210
assert!(211
state212
.notice213
.as_ref()214
.unwrap()215
.text216
.contains("ada@example.com")217
);218
})219
});220
let copied = cx.read_from_clipboard().and_then(|item| item.text());221
assert_eq!(copied.as_deref(), Some("ada@example.com"));222
}223
}@@ -1,8 +1,10 @@
1
use std::cell::Cell;
2
use std::rc::Rc;
1
3
use std::sync::Arc;
2
4
3
5
use chrono::Utc;
4
6
use gpui_kit::assets::IconName;
5
use gpui_kit::base::GlobalState;
7
use gpui_kit::base::{GlobalState, SelectableText};
6
8
use gpui_kit::component::scroll::ScrollableElement as _;
7
9
use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
8
10
use gpui_kit::prelude::FluentBuilder as _;
@@ -52,6 +54,8 @@ pub struct ProfileCard {
52
54
organization_open: bool,
53
55
reports_open: bool,
54
56
focus_handle: FocusHandle,
57
/// KVT #6: de muisklik begon op een contactgegeven; dat mag tekst selecteren.
58
text_press: Rc<Cell<bool>>,
55
59
_observation: Subscription,
56
60
}
57
61
@@ -111,6 +115,7 @@ impl ProfileCard {
111
115
organization_open: true,
112
116
reports_open: false,
113
117
focus_handle,
118
text_press: Rc::default(),
114
119
_observation: observation,
115
120
}
116
121
}
@@ -416,7 +421,9 @@ impl ProfileCard {
416
421
.gap(px(6.))
417
422
.child(self.section_header("profile-contact-header", "Contact", open, cx))
418
423
.when(open, |section| {
419
section.children(rows.into_iter().map(contact_row))
424
section.children(rows.into_iter().enumerate().map(|(index, row)| {
425
contact_row(index, row, self.text_press.clone(), self.app.clone())
426
}))
420
427
})
421
428
}
422
429
@@ -617,27 +624,74 @@ fn skeleton(width_ratio: f32) -> Div {
617
624
.bg(theme::popup_hover())
618
625
}
619
626
620
fn contact_row(row: ContactRow) -> Div {
627
/// KVT issue #6: het gegeven is selecteerbare tekst, het icoontje erachter kopieert het.
628
fn contact_row(
629
index: usize,
630
row: ContactRow,
631
text_press: Rc<Cell<bool>>,
632
app: Entity<AppState>,
633
) -> Div {
621
634
let glyph = match row.kind {
622
635
ContactKind::Email => IconName::Mail,
623
636
ContactKind::WorkPhone => IconName::Phone,
624
637
ContactKind::MobilePhone => IconName::Smartphone,
625
638
ContactKind::Office => IconName::MapPin,
626
639
};
640
let value = row.value.clone();
627
641
h_flex()
628
642
.gap(px(8.))
629
643
.px(px(4.))
630
644
.items_center()
631
645
.child(icon(glyph, 14., theme::text_muted()))
632
646
.child(
633
div()
647
contact_value(index, row.value, text_press)
634
648
.flex_1()
635
649
.min_w_0()
636
650
.truncate()
637
651
.text_size(px(12.5))
638
.text_color(theme::text())
639
.child(row.value),
652
.text_color(theme::text()),
640
653
)
654
.child(
655
div()
656
.id(ElementId::Name(
657
format!("profile-copy-contact-{index}").into(),
658
))
659
.flex_none()
660
.p(px(3.))
661
.rounded(px(4.))
662
.cursor_pointer()
663
.hover(|button| button.bg(theme::row_hover()))
664
.child(icon(IconName::Copy, 12., theme::text_muted()))
665
.tooltip(|window, cx| {
666
Tooltip::new(crate::i18n::tr("kvt.profile.copy")).build(window, cx)
667
})
668
.on_click(move |_, _, cx| {
669
app.update(cx, |state, cx| state.copy_profile_detail(&value, cx));
670
}),
671
)
672
}
673
674
/// Tekst die meedoet met de vensterselectie. Een druk erop meldt zich via `text_press`, zodat
675
/// `guard_card_press` de selectie dan niet tegenhoudt.
676
fn contact_value(index: usize, value: String, text_press: Rc<Cell<bool>>) -> Div {
677
div()
678
.on_mouse_down(MouseButton::Left, move |_, _, _| text_press.set(true))
679
.child(SelectableText::new(
680
ElementId::Name(format!("profile-contact-{index}").into()),
681
value,
682
))
683
}
684
685
/// Een klik in de kaart selecteert niet de chat erachter, behalve als hij op een
686
/// contactgegeven begon: dan mag de vensterselectie beginnen (KVT issue #6).
687
fn guard_card_press(card: Stateful<Div>, text_press: Rc<Cell<bool>>) -> Stateful<Div> {
688
card.on_mouse_down(MouseButton::Left, move |_, _, cx| {
689
if text_press.replace(false) {
690
return;
691
}
692
GlobalState::suppress_text_selection(cx);
693
cx.stop_propagation();
694
})
641
695
}
642
696
643
697
pub fn video_call_tooltip(name: &str) -> String {
@@ -735,14 +789,11 @@ impl Render for ProfileCard {
735
789
.text_color(theme::text())
736
790
.occlude()
737
791
.on_key_down(cx.listener(Self::on_key_down))
738
.on_mouse_down(MouseButton::Left, |_, _, cx| {
739
GlobalState::suppress_text_selection(cx);
740
cx.stop_propagation();
741
})
742
792
.on_mouse_down(MouseButton::Right, |_, _, cx| cx.stop_propagation())
743
793
.children(back)
744
794
.child(header)
745
795
.children(body);
796
let card = guard_card_press(card, self.text_press.clone());
746
797
let offset = point(px(CLICK_OFFSET), px(CLICK_OFFSET));
747
798
div()
748
799
.id("profile-layer")
@@ -774,7 +825,85 @@ impl Render for ProfileCard {
774
825
775
826
#[cfg(test)]
776
827
mod tests {
777
use super::{audio_call_tooltip, video_call_tooltip};
828
use std::cell::Cell;
829
use std::rc::Rc;
830
831
use gpui_kit::base::{SelectableText, TextSelection, TextSelectionLayer};
832
use gpui_kit::{
833
Context, InteractiveElement as _, IntoElement, Modifiers, MouseButton, ParentElement as _,
834
Pixels, Point, Render, Styled as _, TestAppContext,
835
VisualTestContext, Window, anchored, deferred, div, point, px,
836
};
837
838
use super::{audio_call_tooltip, contact_value, guard_card_press, video_call_tooltip};
839
840
/// Chattekst achter een kaart met één contactgegeven, zoals de echte kaart (deferred, occlude).
841
struct CardOverChat {
842
text_press: Rc<Cell<bool>>,
843
}
844
845
impl Render for CardOverChat {
846
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
847
let card = div()
848
.id("card")
849
.occlude()
850
.w(px(240.))
851
.h(px(80.))
852
.child(contact_value(
853
0,
854
"ada@example.com".into(),
855
self.text_press.clone(),
856
))
857
.child(div().h(px(40.)));
858
div()
859
.size_full()
860
.child(TextSelectionLayer)
861
.child(div().w(px(400.)).h(px(200.)).child(SelectableText::new(
862
"chat",
863
"chat text behind the card ".repeat(20),
864
)))
865
.child(deferred(
866
anchored()
867
.position(point(px(0.), px(0.)))
868
.child(guard_card_press(card, self.text_press.clone())),
869
))
870
}
871
}
872
873
fn drag(cx: &mut VisualTestContext, from: Point<Pixels>, to: Point<Pixels>) -> String {
874
cx.update(|window, cx| {
875
let _ = window.draw(cx);
876
});
877
cx.simulate_mouse_down(from, MouseButton::Left, Modifiers::default());
878
cx.simulate_mouse_move(to, Some(MouseButton::Left), Modifiers::default());
879
cx.simulate_mouse_up(to, MouseButton::Left, Modifiers::default());
880
cx.update(|window, cx| {
881
let _ = window.draw(cx);
882
TextSelection::selected_text(window, cx).to_string()
883
})
884
}
885
886
#[gpui_kit::test]
887
fn contact_details_on_the_card_are_selectable(cx: &mut TestAppContext) {
888
let (_, cx) = cx.add_window_view(|_, _| CardOverChat {
889
text_press: Rc::default(),
890
});
891
assert_eq!(
892
drag(cx, point(px(1.), px(6.)), point(px(230.), px(6.))),
893
"ada@example.com"
894
);
895
}
896
897
#[gpui_kit::test]
898
fn a_press_elsewhere_on_the_card_selects_nothing_behind_it(cx: &mut TestAppContext) {
899
let (_, cx) = cx.add_window_view(|_, _| CardOverChat {
900
text_press: Rc::default(),
901
});
902
assert_eq!(
903
drag(cx, point(px(5.), px(60.)), point(px(230.), px(70.))),
904
""
905
);
906
}
778
907
779
908
#[test]
780
909
fn call_tooltips_use_the_teams_wording() {
@@ -1,8 +1,10 @@1
use std::cell::Cell;2
use std::rc::Rc;1
use std::sync::Arc;3
use std::sync::Arc;2
4
3
use chrono::Utc;5
use chrono::Utc;4
use gpui_kit::assets::IconName;6
use gpui_kit::assets::IconName;5
use gpui_kit::base::GlobalState;7
use gpui_kit::base::{GlobalState, SelectableText};6
use gpui_kit::component::scroll::ScrollableElement as _;8
use gpui_kit::component::scroll::ScrollableElement as _;7
use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};9
use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};8
use gpui_kit::prelude::FluentBuilder as _;10
use gpui_kit::prelude::FluentBuilder as _;@@ -52,6 +54,8 @@ pub struct ProfileCard {52
organization_open: bool,54
organization_open: bool,53
reports_open: bool,55
reports_open: bool,54
focus_handle: FocusHandle,56
focus_handle: FocusHandle,57
/// KVT #6: de muisklik begon op een contactgegeven; dat mag tekst selecteren.58
text_press: Rc<Cell<bool>>,55
_observation: Subscription,59
_observation: Subscription,56
}60
}57
61
@@ -111,6 +115,7 @@ impl ProfileCard {111
organization_open: true,115
organization_open: true,112
reports_open: false,116
reports_open: false,113
focus_handle,117
focus_handle,118
text_press: Rc::default(),114
_observation: observation,119
_observation: observation,115
}120
}116
}121
}@@ -416,7 +421,9 @@ impl ProfileCard {416
.gap(px(6.))421
.gap(px(6.))417
.child(self.section_header("profile-contact-header", "Contact", open, cx))422
.child(self.section_header("profile-contact-header", "Contact", open, cx))418
.when(open, |section| {423
.when(open, |section| {419
section.children(rows.into_iter().map(contact_row))424
section.children(rows.into_iter().enumerate().map(|(index, row)| {425
contact_row(index, row, self.text_press.clone(), self.app.clone())426
}))420
})427
})421
}428
}422
429
@@ -617,27 +624,74 @@ fn skeleton(width_ratio: f32) -> Div {617
.bg(theme::popup_hover())624
.bg(theme::popup_hover())618
}625
}619
626
620
fn contact_row(row: ContactRow) -> Div {627
/// KVT issue #6: het gegeven is selecteerbare tekst, het icoontje erachter kopieert het.628
fn contact_row(629
index: usize,630
row: ContactRow,631
text_press: Rc<Cell<bool>>,632
app: Entity<AppState>,633
) -> Div {621
let glyph = match row.kind {634
let glyph = match row.kind {622
ContactKind::Email => IconName::Mail,635
ContactKind::Email => IconName::Mail,623
ContactKind::WorkPhone => IconName::Phone,636
ContactKind::WorkPhone => IconName::Phone,624
ContactKind::MobilePhone => IconName::Smartphone,637
ContactKind::MobilePhone => IconName::Smartphone,625
ContactKind::Office => IconName::MapPin,638
ContactKind::Office => IconName::MapPin,626
};639
};640
let value = row.value.clone();627
h_flex()641
h_flex()628
.gap(px(8.))642
.gap(px(8.))629
.px(px(4.))643
.px(px(4.))630
.items_center()644
.items_center()631
.child(icon(glyph, 14., theme::text_muted()))645
.child(icon(glyph, 14., theme::text_muted()))632
.child(646
.child(633
div()647
contact_value(index, row.value, text_press)634
.flex_1()648
.flex_1()635
.min_w_0()649
.min_w_0()636
.truncate()650
.truncate()637
.text_size(px(12.5))651
.text_size(px(12.5))638
.text_color(theme::text())652
.text_color(theme::text()),639
.child(row.value),640
)653
)654
.child(655
div()656
.id(ElementId::Name(657
format!("profile-copy-contact-{index}").into(),658
))659
.flex_none()660
.p(px(3.))661
.rounded(px(4.))662
.cursor_pointer()663
.hover(|button| button.bg(theme::row_hover()))664
.child(icon(IconName::Copy, 12., theme::text_muted()))665
.tooltip(|window, cx| {666
Tooltip::new(crate::i18n::tr("kvt.profile.copy")).build(window, cx)667
})668
.on_click(move |_, _, cx| {669
app.update(cx, |state, cx| state.copy_profile_detail(&value, cx));670
}),671
)672
}673
674
/// Tekst die meedoet met de vensterselectie. Een druk erop meldt zich via `text_press`, zodat675
/// `guard_card_press` de selectie dan niet tegenhoudt.676
fn contact_value(index: usize, value: String, text_press: Rc<Cell<bool>>) -> Div {677
div()678
.on_mouse_down(MouseButton::Left, move |_, _, _| text_press.set(true))679
.child(SelectableText::new(680
ElementId::Name(format!("profile-contact-{index}").into()),681
value,682
))683
}684
685
/// Een klik in de kaart selecteert niet de chat erachter, behalve als hij op een686
/// contactgegeven begon: dan mag de vensterselectie beginnen (KVT issue #6).687
fn guard_card_press(card: Stateful<Div>, text_press: Rc<Cell<bool>>) -> Stateful<Div> {688
card.on_mouse_down(MouseButton::Left, move |_, _, cx| {689
if text_press.replace(false) {690
return;691
}692
GlobalState::suppress_text_selection(cx);693
cx.stop_propagation();694
})641
}695
}642
696
643
pub fn video_call_tooltip(name: &str) -> String {697
pub fn video_call_tooltip(name: &str) -> String {@@ -735,14 +789,11 @@ impl Render for ProfileCard {735
.text_color(theme::text())789
.text_color(theme::text())736
.occlude()790
.occlude()737
.on_key_down(cx.listener(Self::on_key_down))791
.on_key_down(cx.listener(Self::on_key_down))738
.on_mouse_down(MouseButton::Left, |_, _, cx| {739
GlobalState::suppress_text_selection(cx);740
cx.stop_propagation();741
})742
.on_mouse_down(MouseButton::Right, |_, _, cx| cx.stop_propagation())792
.on_mouse_down(MouseButton::Right, |_, _, cx| cx.stop_propagation())743
.children(back)793
.children(back)744
.child(header)794
.child(header)745
.children(body);795
.children(body);796
let card = guard_card_press(card, self.text_press.clone());746
let offset = point(px(CLICK_OFFSET), px(CLICK_OFFSET));797
let offset = point(px(CLICK_OFFSET), px(CLICK_OFFSET));747
div()798
div()748
.id("profile-layer")799
.id("profile-layer")@@ -774,7 +825,85 @@ impl Render for ProfileCard {774
825
775
#[cfg(test)]826
#[cfg(test)]776
mod tests {827
mod tests {777
use super::{audio_call_tooltip, video_call_tooltip};828
use std::cell::Cell;829
use std::rc::Rc;830
831
use gpui_kit::base::{SelectableText, TextSelection, TextSelectionLayer};832
use gpui_kit::{833
Context, InteractiveElement as _, IntoElement, Modifiers, MouseButton, ParentElement as _,834
Pixels, Point, Render, Styled as _, TestAppContext,835
VisualTestContext, Window, anchored, deferred, div, point, px,836
};837
838
use super::{audio_call_tooltip, contact_value, guard_card_press, video_call_tooltip};839
840
/// Chattekst achter een kaart met één contactgegeven, zoals de echte kaart (deferred, occlude).841
struct CardOverChat {842
text_press: Rc<Cell<bool>>,843
}844
845
impl Render for CardOverChat {846
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {847
let card = div()848
.id("card")849
.occlude()850
.w(px(240.))851
.h(px(80.))852
.child(contact_value(853
0,854
"ada@example.com".into(),855
self.text_press.clone(),856
))857
.child(div().h(px(40.)));858
div()859
.size_full()860
.child(TextSelectionLayer)861
.child(div().w(px(400.)).h(px(200.)).child(SelectableText::new(862
"chat",863
"chat text behind the card ".repeat(20),864
)))865
.child(deferred(866
anchored()867
.position(point(px(0.), px(0.)))868
.child(guard_card_press(card, self.text_press.clone())),869
))870
}871
}872
873
fn drag(cx: &mut VisualTestContext, from: Point<Pixels>, to: Point<Pixels>) -> String {874
cx.update(|window, cx| {875
let _ = window.draw(cx);876
});877
cx.simulate_mouse_down(from, MouseButton::Left, Modifiers::default());878
cx.simulate_mouse_move(to, Some(MouseButton::Left), Modifiers::default());879
cx.simulate_mouse_up(to, MouseButton::Left, Modifiers::default());880
cx.update(|window, cx| {881
let _ = window.draw(cx);882
TextSelection::selected_text(window, cx).to_string()883
})884
}885
886
#[gpui_kit::test]887
fn contact_details_on_the_card_are_selectable(cx: &mut TestAppContext) {888
let (_, cx) = cx.add_window_view(|_, _| CardOverChat {889
text_press: Rc::default(),890
});891
assert_eq!(892
drag(cx, point(px(1.), px(6.)), point(px(230.), px(6.))),893
"ada@example.com"894
);895
}896
897
#[gpui_kit::test]898
fn a_press_elsewhere_on_the_card_selects_nothing_behind_it(cx: &mut TestAppContext) {899
let (_, cx) = cx.add_window_view(|_, _| CardOverChat {900
text_press: Rc::default(),901
});902
assert_eq!(903
drag(cx, point(px(5.), px(60.)), point(px(230.), px(70.))),904
""905
);906
}778
907
779
#[test]908
#[test]780
fn call_tooltips_use_the_teams_wording() {909
fn call_tooltips_use_the_teams_wording() {