mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
* feat(meetings): launch polish for the capsules, Calls sheet, and Meetings pane - Recording capsule: red dot before the time, a quiet ✕ on the icon spine that asks, then discards the recording (capture stops, no final pass, folder to the Trash). - Finished capsule: a title band that opens the meeting in Hex, Copy transcript over Copy agent prompt, and a ring round ✕ that drains over its stay and holds under the pointer. - Calls sheet: one card for when a call starts and stopping when it ends. - Meetings pane: larger detail title, labelled copies, Rename in the ⋯ menu, an empty state, a System Audio notice, and the pane listed while Meetings is off on macOS. - Retention: unchosen meetings are kept 7 days, and expiry never trashes the exported Markdown or notes. * meetings: pane tests follow Rename in the menu and the Calls dropdown; Stop keeps its grace line * meetings: goldens for the new capsules, Calls sheet and pane; labs test keeps Meetings in a Mac's sidebar * rune_ui: the edit icon is only used on macOS now
4177 lines
148 KiB
Rust
4177 lines
148 KiB
Rust
//! The macOS and Windows surfaces, driven headlessly on Linux from preview
|
||
//! data: Meetings, the OS-only General rows, and the full tour.
|
||
|
||
use super::*;
|
||
use crate::desktop::login_item::LoginItemStatus;
|
||
use crate::desktop::onboarding::{
|
||
Input, Observation, PermissionAction, PermissionKind, Practice, Step,
|
||
};
|
||
use platform::{CalendarRequest, MeetingRequest, PlatformHost, PlatformRequest};
|
||
|
||
fn asked(rt: &Runtime<Ui>) -> &[PlatformRequest] {
|
||
match &rt.state.host {
|
||
PlatformHost::Fixture(sent) => sent,
|
||
_ => panic!("scenes record platform requests"),
|
||
}
|
||
}
|
||
|
||
/// Redraws after a test changes state directly, as the host would.
|
||
fn refresh(rt: &mut Runtime<Ui>) {
|
||
rt.invalidate();
|
||
settle(rt);
|
||
}
|
||
|
||
#[test]
|
||
fn each_os_lists_only_the_panes_it_can_run() {
|
||
// Meetings (beta) is a Labs switch on every OS; this Mac fixture has it on.
|
||
for scene in ["portal", "windows-settings"] {
|
||
let mut rt = runtime(scene, true, PANE_SIZE);
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-meetings").is_some(), "{scene} offers Meetings");
|
||
}
|
||
let mut mac = runtime("mac-settings", true, PANE_SIZE);
|
||
tap(&mut mac, "nav-labs");
|
||
for (key, pane) in [
|
||
("nav-meetings", Pane::Meetings),
|
||
("nav-general", Pane::General),
|
||
] {
|
||
tap(&mut mac, key);
|
||
assert_eq!(mac.state.pane, pane);
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn settings_rows_follow_each_os() {
|
||
let present = |rt: &Runtime<Ui>, key: &str| rt.find(key).is_some();
|
||
let mut linux = runtime("portal", true, TALL_SIZE);
|
||
open_advanced(&mut linux, Pane::General);
|
||
assert!(present(&linux, "terminal-paste"));
|
||
assert!(present(&linux, "toggle-listening"));
|
||
assert!(present(&linux, "enable-on-launch"));
|
||
assert!(present(&linux, "launch-at-login"));
|
||
assert!(present(&linux, "speech-engine"));
|
||
assert!(!present(&linux, "dock-icon"));
|
||
assert!(!present(&linux, "meetings-enabled"));
|
||
|
||
let mut mac = runtime("mac-settings", true, TALL_SIZE);
|
||
open_advanced(&mut mac, Pane::General);
|
||
for key in ["launch-at-login", "dock-icon", "update-status"] {
|
||
assert!(present(&mac, key), "macOS shows {key}");
|
||
}
|
||
// Features own their settings: none of these are in General.
|
||
for key in [
|
||
"terminal-paste",
|
||
"toggle-listening",
|
||
"enable-on-launch",
|
||
"meetings-enabled",
|
||
"calls",
|
||
"hex-mic-driver",
|
||
"command-model-notice",
|
||
] {
|
||
assert!(!present(&mac, key), "macOS General has no {key}");
|
||
}
|
||
// macOS runs its models on Metal or Apple's speech engine: no Speech
|
||
// engine row, and no GPU fallback to explain.
|
||
assert!(
|
||
!present(&mac, "speech-engine"),
|
||
"macOS has no Speech engine row"
|
||
);
|
||
|
||
let mut windows = runtime("windows-settings", true, TALL_SIZE);
|
||
open_advanced(&mut windows, Pane::General);
|
||
assert!(present(&windows, "launch-at-login"));
|
||
assert!(present(&windows, "toggle-listening"));
|
||
assert!(present(&windows, "speech-engine"));
|
||
assert!(!present(&windows, "dock-icon"));
|
||
assert!(
|
||
!present(&windows, "terminal-paste"),
|
||
"Windows has it in Labs"
|
||
);
|
||
assert!(!present(&windows, "meetings-enabled"));
|
||
}
|
||
|
||
#[test]
|
||
fn a_listener_notice_reads_apart_from_a_dictation_failure() {
|
||
let mut rt = runtime("portal", true, TALL_SIZE);
|
||
open_advanced(&mut rt, Pane::General);
|
||
if let Some(view) = &mut rt.state.view {
|
||
view.listener.warning = Some("Microphone unavailable".into());
|
||
}
|
||
refresh(&mut rt);
|
||
let shown = texts(&rt);
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "Last dictation failed: Microphone unavailable"),
|
||
"{shown:?}"
|
||
);
|
||
|
||
let notice = "wl-copy is not installed. Install the wl-clipboard package, then try again.";
|
||
if let Some(view) = &mut rt.state.view {
|
||
view.listener.warning = None;
|
||
view.listener.notice = Some(notice.into());
|
||
}
|
||
refresh(&mut rt);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == notice), "{shown:?}");
|
||
assert!(
|
||
!shown
|
||
.iter()
|
||
.any(|text| text.starts_with("Last dictation failed:")),
|
||
"{shown:?}"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn launch_at_login_asks_the_login_item_and_needs_approval_first() {
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2400.0));
|
||
tap(&mut rt, "launch-at-login");
|
||
assert_eq!(asked(&rt), [PlatformRequest::SetLaunchAtLogin(true)]);
|
||
assert_eq!(rt.state.platform.login_item, Some(LoginItemStatus::Enabled));
|
||
|
||
let mut rt = runtime("mac-settings-permissions", true, (980.0, 2400.0));
|
||
tap(&mut rt, "launch-at-login-approval");
|
||
assert_eq!(asked(&rt), [PlatformRequest::OpenLoginItemSettings]);
|
||
}
|
||
|
||
/// The macOS login item switch's state before macOS has answered a click.
|
||
fn login_item(status: LoginItemStatus) -> platform::PlatformState {
|
||
let mut state = platform::PlatformState::new(platform::Capabilities::MACOS);
|
||
state.login_item = Some(status);
|
||
state
|
||
}
|
||
|
||
fn login_failed(status: Option<LoginItemStatus>) -> crate::desktop::login_item::LoginItemResult {
|
||
Err(crate::desktop::login_item::LoginItemFailure {
|
||
status,
|
||
message: "Operation not permitted".into(),
|
||
})
|
||
}
|
||
|
||
#[test]
|
||
fn login_item_switch_moves_on_click_and_stays_when_macos_agrees() {
|
||
let mut state = login_item(LoginItemStatus::Disabled);
|
||
state.request_login_item(true);
|
||
assert!(
|
||
state.login_item_on(),
|
||
"the thumb moves before macOS answers"
|
||
);
|
||
assert_eq!(state.login_item, Some(LoginItemStatus::Disabled));
|
||
state.login_item_answered(Ok(LoginItemStatus::Enabled), true);
|
||
assert!(state.login_item_on());
|
||
assert_eq!(state.login_item_requested, None);
|
||
assert_eq!(state.login_item, Some(LoginItemStatus::Enabled));
|
||
assert_eq!(state.login_item_error, None);
|
||
}
|
||
|
||
#[test]
|
||
fn login_item_switch_springs_back_beside_the_error_when_macos_refuses() {
|
||
let mut state = login_item(LoginItemStatus::Disabled);
|
||
state.request_login_item(true);
|
||
state.login_item_answered(login_failed(Some(LoginItemStatus::Disabled)), true);
|
||
assert!(!state.login_item_on());
|
||
assert_eq!(
|
||
state.login_item_error.as_deref(),
|
||
Some("Operation not permitted")
|
||
);
|
||
// A failure that could not read the status keeps the last known one.
|
||
state.request_login_item(true);
|
||
assert_eq!(state.login_item_error, None, "a new click clears the error");
|
||
state.login_item_answered(login_failed(None), true);
|
||
assert!(!state.login_item_on());
|
||
assert!(state.login_item_error.is_some());
|
||
// macOS answering with the other state, without an error, also springs back.
|
||
state.request_login_item(true);
|
||
state.login_item_answered(Ok(LoginItemStatus::Disabled), true);
|
||
assert!(!state.login_item_on());
|
||
}
|
||
|
||
#[test]
|
||
fn login_item_status_answer_never_flips_a_pending_click() {
|
||
let mut state = login_item(LoginItemStatus::Disabled);
|
||
// The status check from opening Settings was still running at the click.
|
||
state.request_login_item(true);
|
||
state.login_item_answered(Ok(LoginItemStatus::Disabled), false);
|
||
assert!(state.login_item_on());
|
||
// Even a failed check behind the click leaves it, with no stale error.
|
||
state.login_item_answered(login_failed(Some(LoginItemStatus::Disabled)), false);
|
||
assert!(state.login_item_on());
|
||
assert_eq!(state.login_item_error, None);
|
||
state.login_item_answered(Ok(LoginItemStatus::Enabled), true);
|
||
assert!(state.login_item_on());
|
||
// Without a click, a status answer is simply adopted.
|
||
state.login_item_answered(Ok(LoginItemStatus::Disabled), false);
|
||
assert!(!state.login_item_on());
|
||
}
|
||
|
||
#[test]
|
||
fn login_item_double_click_keeps_the_last_click() {
|
||
let mut state = login_item(LoginItemStatus::Disabled);
|
||
state.request_login_item(true);
|
||
state.request_login_item(false);
|
||
assert!(!state.login_item_on());
|
||
// The first request's answer arrives while the second still runs.
|
||
state.login_item_answered(Ok(LoginItemStatus::Enabled), false);
|
||
assert!(!state.login_item_on(), "the last click wins");
|
||
assert_eq!(state.login_item, Some(LoginItemStatus::Enabled));
|
||
state.login_item_answered(Ok(LoginItemStatus::Disabled), true);
|
||
assert!(!state.login_item_on());
|
||
assert_eq!(state.login_item_requested, None);
|
||
}
|
||
|
||
/// A native host whose login item answers only when the test says so.
|
||
struct SlowLoginItem(std::rc::Rc<std::cell::RefCell<Vec<PlatformRequest>>>);
|
||
|
||
impl platform::NativeHost for SlowLoginItem {
|
||
fn send(&mut self, request: PlatformRequest) -> Result<(), String> {
|
||
self.0.borrow_mut().push(request);
|
||
Ok(())
|
||
}
|
||
fn poll(&mut self, _: &mut platform::PlatformState) -> bool {
|
||
false
|
||
}
|
||
fn meetings(&mut self) -> Option<Result<Vec<meetings::Meeting>, String>> {
|
||
None
|
||
}
|
||
fn tour_inputs(&mut self, _: bool) -> Vec<Input> {
|
||
Vec::new()
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn login_item_row_moves_its_switch_before_macos_answers() {
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2400.0));
|
||
let sent = std::rc::Rc::default();
|
||
rt.state.host = PlatformHost::Native(Box::new(SlowLoginItem(std::rc::Rc::clone(&sent))));
|
||
tap(&mut rt, "launch-at-login");
|
||
tap(&mut rt, "launch-at-login");
|
||
tap(&mut rt, "launch-at-login");
|
||
assert_eq!(
|
||
*sent.borrow(),
|
||
[true, false, true].map(PlatformRequest::SetLaunchAtLogin)
|
||
);
|
||
assert!(rt.state.platform.login_item_on());
|
||
assert_eq!(
|
||
rt.state.platform.login_item,
|
||
Some(LoginItemStatus::Disabled)
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn missing_permissions_lead_settings_and_open_the_guide() {
|
||
let mut rt = runtime("mac-settings-permissions", true, (980.0, 2400.0));
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Permissions needed"));
|
||
assert!(
|
||
rt.find("permission-microphone-allow-control/mark/dot")
|
||
.is_none()
|
||
);
|
||
tap(&mut rt, "permission-microphone-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(PermissionAction::ShowGuide(
|
||
PermissionKind::Microphone
|
||
))]
|
||
);
|
||
assert!(rt.state.platform.asked(PermissionKind::Microphone));
|
||
assert!(
|
||
rt.find("permission-microphone-allow-control/mark/dot")
|
||
.is_some(),
|
||
"asked permissions wait with a dot"
|
||
);
|
||
}
|
||
|
||
/// The drawn rect and effective opacity of the element whose path ends
|
||
/// with `path`.
|
||
fn drawn(rt: &Runtime<Ui>, path: &str) -> Option<([f32; 4], f32)> {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| e.path.ends_with(path) && !e.exiting)
|
||
.map(|e| (e.rect, e.opacity))
|
||
}
|
||
|
||
#[test]
|
||
fn a_grant_gathers_then_releases_into_allowed() {
|
||
let mut rt = runtime("meetings-allow", true, PANE_SIZE);
|
||
let pill = "meeting-system-audio-allow";
|
||
let control = format!("{pill}-control");
|
||
tap(&mut rt, pill);
|
||
assert_eq!(asked(&rt), [PlatformRequest::SystemAudio]);
|
||
assert!(
|
||
rt.find(&format!("{control}/mark/dot")).is_some(),
|
||
"waits with a dot"
|
||
);
|
||
let at_rest = drawn(&rt, &control).unwrap().0;
|
||
|
||
// The fixture grants on the second ask.
|
||
let (x, y) = rt.find(pill).unwrap();
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_up(x, y);
|
||
let mut smallest = f32::MAX;
|
||
for _ in 0..120 {
|
||
rt.frame(1.0 / 120.0);
|
||
smallest = smallest.min(drawn(&rt, &control).unwrap().0[2]);
|
||
let label = drawn(&rt, &format!("{pill}/label")).unwrap().0;
|
||
let (suffix, _) = drawn(&rt, &format!("{pill}/suffix")).unwrap();
|
||
assert!(
|
||
suffix[0] >= label[0] + label[2] - 0.5,
|
||
"\"ed\" follows \"Allow\" without overlapping it: {label:?} {suffix:?}"
|
||
);
|
||
let (dot, _) = drawn(&rt, &format!("{control}/mark/dot")).unwrap();
|
||
let (_, ink) = drawn(&rt, &format!("{control}/mark/ink")).unwrap();
|
||
assert!(
|
||
ink < 0.05 || dot[2] < 1.0,
|
||
"the check appears once the dot has gone: dot {dot:?}, check opacity {ink}"
|
||
);
|
||
}
|
||
assert!(rt.state.platform.system_audio);
|
||
assert!(
|
||
smallest < at_rest[2] * 0.97,
|
||
"the control gathers: {smallest} of {}",
|
||
at_rest[2]
|
||
);
|
||
let allowed = drawn(&rt, &control).unwrap().0;
|
||
assert!(
|
||
(allowed[2] - at_rest[2]).abs() < 2.0,
|
||
"and releases to its size: {at_rest:?} → {allowed:?}"
|
||
);
|
||
assert!(rt.find(&format!("{control}/mark/ink/check")).is_some());
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Allow"));
|
||
assert!(shown.iter().any(|text| text == "ed"));
|
||
|
||
tap(&mut rt, pill);
|
||
assert_eq!(asked(&rt).len(), 2, "Allowed is not a button");
|
||
|
||
// Coming back to the pane shows Allowed at rest, without replaying.
|
||
tap(&mut rt, "nav-general");
|
||
let (x, y) = rt.find("nav-meetings").unwrap();
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_up(x, y);
|
||
rt.frame(1.0 / 60.0);
|
||
let moving: Vec<_> = rt
|
||
.elements()
|
||
.into_iter()
|
||
.filter(|e| e.path.contains(&control) && e.moving)
|
||
.map(|e| e.path)
|
||
.collect();
|
||
assert!(moving.is_empty(), "replayed: {moving:?}");
|
||
}
|
||
|
||
#[test]
|
||
fn reduce_motion_swaps_allow_for_allowed_at_once() {
|
||
let mut rt = runtime("meetings-allow", true, PANE_SIZE);
|
||
let pill = "meeting-system-audio-allow";
|
||
tap(&mut rt, pill);
|
||
let mut settled = runtime("meetings-allow", true, PANE_SIZE);
|
||
tap(&mut settled, pill);
|
||
settled.state.platform.system_audio = true;
|
||
refresh(&mut settled);
|
||
let allowed = settled.presented(pill).unwrap().0;
|
||
|
||
rt.set_system_reduced_motion(true);
|
||
let (x, y) = rt.find(pill).unwrap();
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_up(x, y);
|
||
rt.frame(1.0 / 60.0);
|
||
assert_eq!(rt.presented(pill).unwrap().0, allowed, "no travel");
|
||
}
|
||
|
||
#[test]
|
||
fn the_browser_permission_shows_with_pause_media_and_its_labs_toggle() {
|
||
let mut rt = runtime("mac-settings-pause-browser", true, TALL_SIZE);
|
||
rt.state.settings.pause_browser_media = false;
|
||
refresh(&mut rt);
|
||
open_advanced(&mut rt, Pane::General);
|
||
assert!(rt.find("pause-browser").is_none(), "the toggle is in Labs");
|
||
assert!(rt.find("pause-browser-audio").is_none());
|
||
rt.state.settings.pause_browser_media = true;
|
||
refresh(&mut rt);
|
||
assert!(rt.find("pause-browser-audio").is_some());
|
||
}
|
||
|
||
#[test]
|
||
fn the_browser_labs_toggle_turns_on_and_asks_for_system_audio() {
|
||
let mut rt = runtime("mac-settings", true, TALL_SIZE);
|
||
rt.state.platform.system_audio = false;
|
||
open_labs(&mut rt);
|
||
tap(&mut rt, "lab-pause-browser");
|
||
assert!(rt.state.settings.pause_browser_media);
|
||
assert_eq!(asked(&rt), [PlatformRequest::SystemAudio]);
|
||
|
||
let mut rt = runtime("mac-settings", true, TALL_SIZE);
|
||
rt.state.platform.system_audio = true;
|
||
open_labs(&mut rt);
|
||
tap(&mut rt, "lab-pause-browser");
|
||
assert!(rt.state.settings.pause_browser_media);
|
||
assert!(asked(&rt).is_empty());
|
||
}
|
||
|
||
#[test]
|
||
fn contributed_options_are_labs_toggles_off_by_default() {
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2800.0));
|
||
open_labs(&mut rt);
|
||
for row in [
|
||
"lab-mouse-shortcuts",
|
||
"lab-pause-browser",
|
||
"lab-keep-on-clipboard",
|
||
"lab-signature",
|
||
"lab-copy-only",
|
||
"lab-return-to-app",
|
||
"lab-spoken-formatting",
|
||
"lab-filler-words",
|
||
"lab-clean-up",
|
||
"lab-neutral-voice",
|
||
"lab-spoken-symbols",
|
||
"lab-caps-lock-dictation",
|
||
"lab-copy-dictation-audio",
|
||
] {
|
||
assert!(rt.find(row).is_some(), "Labs lacks {row}");
|
||
}
|
||
assert!(!rt.state.settings.labs.spoken_formatting);
|
||
tap(&mut rt, "lab-spoken-formatting");
|
||
assert!(rt.state.settings.labs.spoken_formatting);
|
||
assert!(!rt.state.settings.labs.spoken_symbols);
|
||
tap(&mut rt, "lab-spoken-symbols");
|
||
assert!(rt.state.settings.labs.spoken_symbols);
|
||
assert!(!rt.state.settings.labs.filler_words);
|
||
tap(&mut rt, "lab-filler-words");
|
||
assert!(rt.state.settings.labs.filler_words);
|
||
assert!(!rt.state.settings.labs.clean_up_with_apple_intelligence);
|
||
tap(&mut rt, "lab-clean-up");
|
||
assert!(rt.state.settings.labs.clean_up_with_apple_intelligence);
|
||
assert!(!rt.state.settings.labs.neutral_voice);
|
||
tap(&mut rt, "lab-neutral-voice");
|
||
assert!(rt.state.settings.labs.neutral_voice);
|
||
assert!(rt.find("lab-share-shortcut").is_none(), "Windows only");
|
||
assert!(!rt.state.settings.labs.mouse_shortcuts);
|
||
tap(&mut rt, "lab-mouse-shortcuts");
|
||
assert!(rt.state.settings.labs.mouse_shortcuts);
|
||
assert!(!rt.state.settings.labs.keep_on_clipboard);
|
||
tap(&mut rt, "lab-keep-on-clipboard");
|
||
assert!(rt.state.settings.labs.keep_on_clipboard);
|
||
assert!(!rt.state.settings.labs.signature);
|
||
tap(&mut rt, "lab-signature");
|
||
assert!(rt.state.settings.labs.signature);
|
||
assert!(!rt.state.settings.labs.copy_only);
|
||
tap(&mut rt, "lab-copy-only");
|
||
assert!(rt.state.settings.labs.copy_only);
|
||
assert!(!rt.state.settings.labs.return_to_app);
|
||
tap(&mut rt, "lab-return-to-app");
|
||
assert!(rt.state.settings.labs.return_to_app);
|
||
assert!(!rt.state.settings.labs.copy_dictation_audio);
|
||
tap(&mut rt, "lab-copy-dictation-audio");
|
||
assert!(rt.state.settings.labs.copy_dictation_audio);
|
||
assert!(!rt.state.settings.labs.caps_lock_dictation);
|
||
tap(&mut rt, "lab-caps-lock-dictation");
|
||
assert!(rt.state.settings.labs.caps_lock_dictation);
|
||
|
||
// Tall enough that the last Labs rows (Share shortcut, Terminal paste)
|
||
// sit inside the window, where a tap reaches them.
|
||
let mut rt = runtime("windows-settings", true, (980.0, 2600.0));
|
||
open_advanced(&mut rt, Pane::General);
|
||
assert!(rt.find("share-dictation-shortcut").is_none());
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-mouse-shortcuts").is_none(), "macOS only");
|
||
assert!(rt.find("lab-keep-on-clipboard").is_some(), "every OS");
|
||
assert!(rt.find("lab-signature").is_some(), "every OS");
|
||
assert!(rt.find("lab-copy-only").is_some(), "macOS and Windows");
|
||
assert!(rt.find("lab-spoken-formatting").is_some(), "every OS");
|
||
assert!(rt.find("lab-filler-words").is_some(), "every OS");
|
||
assert!(rt.find("lab-clean-up").is_none(), "macOS only");
|
||
assert!(rt.find("lab-neutral-voice").is_none(), "macOS only");
|
||
assert!(rt.find("lab-spoken-symbols").is_some(), "every OS");
|
||
assert!(!rt.state.settings.labs.keep_on_clipboard);
|
||
tap(&mut rt, "lab-keep-on-clipboard");
|
||
assert!(rt.state.settings.labs.keep_on_clipboard);
|
||
assert!(!rt.state.settings.labs.copy_only);
|
||
tap(&mut rt, "lab-copy-only");
|
||
assert!(rt.state.settings.labs.copy_only);
|
||
assert!(!rt.state.settings.share_dictation_shortcut);
|
||
tap(&mut rt, "lab-share-shortcut");
|
||
assert!(rt.state.settings.share_dictation_shortcut);
|
||
|
||
// Linux's paster keeps the dictation on the clipboard too; only macOS
|
||
// and Windows can skip the paste.
|
||
let mut rt = runtime("linux-labs", true, (980.0, 4000.0));
|
||
unfold_labs(&mut rt);
|
||
assert!(rt.find("lab-keep-on-clipboard").is_some(), "every OS");
|
||
assert!(rt.find("lab-copy-only").is_none(), "macOS and Windows only");
|
||
assert!(!rt.state.settings.labs.keep_on_clipboard);
|
||
tap(&mut rt, "lab-keep-on-clipboard");
|
||
assert!(rt.state.settings.labs.keep_on_clipboard);
|
||
}
|
||
|
||
/// Summaries is one choice in Meetings › Settings › After a meeting: Off,
|
||
/// On this Mac, or OpenCode on a Mac, with OpenCode's model nested under it
|
||
/// only while OpenCode writes them.
|
||
#[test]
|
||
fn summaries_are_one_choice_with_opencode_s_model_under_it() {
|
||
use crate::app_settings::MeetingSummaries;
|
||
let size = (980.0, 2400.0);
|
||
let mut rt = runtime("meetings-settings", true, size);
|
||
assert!(rt.find("after-meeting").is_some());
|
||
assert!(rt.find("meeting-summaries").is_some());
|
||
assert!(
|
||
rt.find("meeting-summary-model").is_none(),
|
||
"On this Mac has no model"
|
||
);
|
||
tap(&mut rt, "meeting-summaries-control-trigger");
|
||
tap(&mut rt, "meeting-summaries-menu-item3");
|
||
assert_eq!(
|
||
rt.state.settings.meetings.summaries,
|
||
MeetingSummaries::OpenCode
|
||
);
|
||
settle(&mut rt);
|
||
assert!(rt.find("meeting-summary-model").is_some());
|
||
assert!(
|
||
rt.find("refresh-models").is_none(),
|
||
"opening the picker reads the list"
|
||
);
|
||
tap(&mut rt, "meeting-summaries-control-trigger");
|
||
tap(&mut rt, "meeting-summaries-menu-item0");
|
||
assert_eq!(rt.state.settings.meetings.summaries, MeetingSummaries::Off);
|
||
settle(&mut rt);
|
||
assert!(rt.find("meeting-summary-model").is_none());
|
||
}
|
||
|
||
/// Without Apple Intelligence, On this Mac stays chosen and disabled, and
|
||
/// the row says how to turn it on; nothing switches to OpenCode.
|
||
#[test]
|
||
fn on_this_mac_without_apple_intelligence_stays_chosen_with_the_fix() {
|
||
use crate::app_settings::MeetingSummaries;
|
||
let mut rt = runtime("meetings-summaries-unavailable", true, (980.0, 2400.0));
|
||
assert!(texts(&rt).iter().any(|text| {
|
||
text == "Turn on Apple Intelligence in System Settings to write them on this Mac"
|
||
}));
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text == "Turn on Apple Intelligence in System Settings")
|
||
);
|
||
tap(&mut rt, "meeting-summaries-menu-item2");
|
||
assert_eq!(rt.state.settings.meetings.summaries, MeetingSummaries::Mac);
|
||
assert!(rt.find("meeting-summary-model").is_none());
|
||
}
|
||
|
||
/// Keep audio sits beside Keep meetings once Meetings is on and saves its
|
||
/// window.
|
||
#[test]
|
||
fn keep_audio_shows_with_meetings_and_saves_its_window() {
|
||
use crate::app_settings::MeetingRetention;
|
||
let mut rt = runtime("portal", true, TALL_SIZE);
|
||
rt.state.pane = Pane::Meetings;
|
||
rt.state.meetings.view = super::super::meetings::View::Settings;
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("meeting-audio-retention").is_none(),
|
||
"hidden while Meetings is off"
|
||
);
|
||
|
||
rt.state.settings.meetings.enabled = true;
|
||
refresh(&mut rt);
|
||
assert!(rt.find("meeting-audio-retention").is_some());
|
||
assert_eq!(
|
||
a11y_value(&rt, "meeting-audio-retention-control-trigger").as_deref(),
|
||
Some("Same as meetings")
|
||
);
|
||
pick(&mut rt, "meeting-audio-retention", 2);
|
||
assert_eq!(
|
||
rt.state.settings.meetings.audio_retention,
|
||
Some(MeetingRetention::Week)
|
||
);
|
||
}
|
||
|
||
/// Export's two switches and the Calls sheet's Stop when the call ends save
|
||
/// their meeting settings; the Stop row names the grace it waits.
|
||
#[test]
|
||
fn meeting_export_and_stop_when_call_ends_save_their_settings() {
|
||
let mut rt = runtime("mac-settings", true, (980.0, 3200.0));
|
||
rt.state.settings.meetings.enabled = true;
|
||
rt.state.pane = Pane::Meetings;
|
||
rt.state.meetings.view = super::super::meetings::View::Settings;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "meeting-descriptive-filenames");
|
||
assert!(rt.state.settings.meetings.export.descriptive_filenames);
|
||
tap(&mut rt, "meeting-notes-file");
|
||
assert!(rt.state.settings.meetings.export.notes_file);
|
||
// Slack huddles record automatically, so the sheet offers Stop.
|
||
tap(&mut rt, "calls");
|
||
tap(&mut rt, "meeting-stop-when-call-ends");
|
||
assert!(rt.state.settings.meetings.stop_when_call_ends);
|
||
let grace = format!(
|
||
"{} seconds after",
|
||
crate::meeting::detection::AUTO_STOP_GRACE.as_secs()
|
||
);
|
||
assert!(
|
||
texts(&rt).iter().any(|text| text.starts_with(&grace)),
|
||
"the Stop row names its {grace}"
|
||
);
|
||
}
|
||
|
||
/// Stop when the call ends shows next to Record automatically on Windows
|
||
/// and Linux too: the call app's audio output keeps a muted call's recording
|
||
/// alive there as Core Audio does on a Mac (#835).
|
||
#[test]
|
||
fn stop_when_the_call_ends_shows_on_every_os() {
|
||
use crate::app_settings::MeetingPolicy;
|
||
for scene in ["portal", "windows-settings"] {
|
||
let mut rt = runtime(scene, true, (980.0, 2400.0));
|
||
rt.state.settings.meetings.enabled = true;
|
||
rt.state.settings.meetings.default_policy = MeetingPolicy::AlwaysRecord;
|
||
rt.state.pane = Pane::Meetings;
|
||
rt.state.meetings.view = super::super::meetings::View::Settings;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "calls");
|
||
assert!(
|
||
rt.find("meeting-stop-when-call-ends").is_some(),
|
||
"no Stop row on {scene}"
|
||
);
|
||
tap(&mut rt, "meeting-stop-when-call-ends");
|
||
assert!(rt.state.settings.meetings.stop_when_call_ends, "{scene}");
|
||
}
|
||
}
|
||
|
||
/// Labs' Stop every call recording lab shows wherever Meetings is on, and
|
||
/// its switch saves: Windows and Linux record offered and by-hand calls too,
|
||
/// even though a calendar reminder is macOS only.
|
||
#[test]
|
||
fn the_stop_every_call_recording_lab_shows_on_every_os() {
|
||
for scene in ["portal", "windows-settings"] {
|
||
let mut rt = runtime(scene, true, (980.0, 2600.0));
|
||
rt.state.settings.meetings.enabled = true;
|
||
refresh(&mut rt);
|
||
open_labs(&mut rt);
|
||
assert!(
|
||
rt.find("lab-stop-any-call-recording").is_some(),
|
||
"no Stop every call recording lab on {scene}"
|
||
);
|
||
scroll_into_view(&mut rt, "lab-stop-any-call-recording", "scroll");
|
||
assert!(!rt.state.settings.labs.stop_any_call_recording, "{scene}");
|
||
tap(&mut rt, "lab-stop-any-call-recording");
|
||
assert!(rt.state.settings.labs.stop_any_call_recording, "{scene}");
|
||
}
|
||
}
|
||
|
||
/// Off a Mac, Summaries is a switch that turns OpenCode on.
|
||
#[test]
|
||
fn summaries_are_a_switch_off_a_mac() {
|
||
use crate::app_settings::MeetingSummaries;
|
||
for scene in ["portal", "windows-settings"] {
|
||
let mut rt = runtime(scene, true, (980.0, 2400.0));
|
||
rt.state.settings.meetings.enabled = true;
|
||
rt.state.pane = Pane::Meetings;
|
||
rt.state.meetings.view = super::super::meetings::View::Settings;
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
rt.state.settings.meetings.summaries,
|
||
MeetingSummaries::Off,
|
||
"{scene}"
|
||
);
|
||
tap(&mut rt, "meeting-summaries");
|
||
assert_eq!(
|
||
rt.state.settings.meetings.summaries,
|
||
MeetingSummaries::OpenCode,
|
||
"{scene}"
|
||
);
|
||
}
|
||
}
|
||
|
||
/// The meeting summary model picks from OpenCode's models, with OpenCode's
|
||
/// own default model first; without OpenCode it offers a retry and keeps the
|
||
/// saved model (#1301).
|
||
#[test]
|
||
fn the_meeting_summary_model_is_picked_from_opencode_s_models() {
|
||
let size = (980.0, 2400.0);
|
||
let mut rt = runtime("meetings-summary-model", true, size);
|
||
assert!(rt.find("meeting-summary-model").is_some());
|
||
assert!(rt.find("opencode-unavailable").is_none());
|
||
assert!(super::super::platform_settings::summary_model_shown(
|
||
&rt.state
|
||
));
|
||
rt.state.models.open_picker();
|
||
rt.invalidate();
|
||
settle(&mut rt);
|
||
// Hex's automatic choice, then the catalog in order.
|
||
tap(&mut rt, "model-picker-option-3");
|
||
assert_eq!(
|
||
rt.state.settings.meetings.opencode_model.as_deref(),
|
||
Some("openai/gpt-5")
|
||
);
|
||
assert!(rt.find("thinking").is_none(), "summaries have no thinking");
|
||
tap(&mut rt, "model-value");
|
||
assert!(rt.state.models.picker.is_open());
|
||
tap(&mut rt, "model-picker-option-0");
|
||
assert_eq!(rt.state.settings.meetings.opencode_model, None);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text == "OpenCode's default model")
|
||
);
|
||
|
||
let rt = runtime("meetings-summary-model-not-running", true, size);
|
||
assert!(rt.find("opencode-unavailable").is_some());
|
||
assert!(rt.find("retry-opencode").is_some());
|
||
assert_eq!(
|
||
rt.state.settings.meetings.opencode_model.as_deref(),
|
||
Some("anthropic/claude-sonnet-4-5")
|
||
);
|
||
assert!(texts(&rt).iter().any(|text| text == "claude-sonnet-4-5"));
|
||
}
|
||
|
||
/// The cancel shortcut's row shows only in Toggle; its default, Escape,
|
||
/// can't be recorded (Escape ends the recorder), so restoring puts it back.
|
||
#[test]
|
||
fn the_cancel_shortcut_shows_in_toggle_and_restores_escape() {
|
||
use crate::app_settings::HotkeyBinding;
|
||
let hold = runtime("mac-settings", true, PANE_SIZE);
|
||
assert!(hold.find("cancel-shortcut").is_none(), "Hold has no cancel");
|
||
|
||
let mut rt = runtime("toggle-cancel", true, PANE_SIZE);
|
||
assert!(rt.find("cancel-hotkey").is_some());
|
||
assert!(
|
||
rt.find("restore-cancel-shortcut").is_none(),
|
||
"already Escape"
|
||
);
|
||
rt.state.settings.cancel_hotkey = HotkeyBinding::paste_last_default();
|
||
rt.state.settings.paste_last_hotkey = None;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "restore-cancel-shortcut");
|
||
assert_eq!(
|
||
rt.state.settings.cancel_hotkey,
|
||
HotkeyBinding::cancel_default()
|
||
);
|
||
|
||
// On Wayland the portal would hold the key for good: the row points
|
||
// to `hex dictation cancel` instead of recording one.
|
||
let portal = runtime("portal-toggle-cancel", true, PANE_SIZE);
|
||
assert!(portal.find("cancel-shortcut").is_some());
|
||
assert!(portal.find("cancel-hotkey").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn general_hides_advanced_options_until_asked() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
assert!(rt.find("shortcut-mode").is_some(), "under the shortcut");
|
||
assert!(rt.find("avoid-bluetooth-microphone").is_none());
|
||
tap(&mut rt, "advanced-toggle");
|
||
assert!(rt.find("avoid-bluetooth-microphone").is_some());
|
||
tap(&mut rt, "advanced-toggle");
|
||
assert!(rt.find("avoid-bluetooth-microphone").is_none());
|
||
assert!(
|
||
rt.find("microphone-mode").is_some(),
|
||
"the mic switch is in General"
|
||
);
|
||
}
|
||
|
||
/// General's level bars follow what the microphone hears, settle once it
|
||
/// is quiet, and lie flat and dimmed while no audio arrives.
|
||
#[test]
|
||
fn the_microphone_level_follows_the_voice() {
|
||
let bar = |rt: &Runtime<Ui>| element(rt, "microphone-control/level/bar1").rect[3];
|
||
let mut rt = runtime("mac-settings-mic-level", true, PANE_SIZE);
|
||
let rest = bar(&rt);
|
||
let mut tallest = rest;
|
||
for _ in 0..90 {
|
||
rt.frame(1.0 / 30.0);
|
||
tallest = tallest.max(bar(&rt));
|
||
}
|
||
assert!(
|
||
tallest > rest + 4.0,
|
||
"the voice raised the bars ({tallest} vs {rest})"
|
||
);
|
||
for _ in 0..30 {
|
||
rt.frame(1.0 / 30.0);
|
||
}
|
||
assert_eq!(bar(&rt), rest, "the bars settle after the voice");
|
||
assert!(rt.state.mic_level.receiving);
|
||
|
||
let released = runtime("mac-settings-mic-released", true, PANE_SIZE);
|
||
assert_eq!(bar(&released), rest);
|
||
assert!(!released.state.mic_level.receiving);
|
||
|
||
let mut level = general::MicLevel::default();
|
||
assert!(level.hear(Some(0.5)), "a voice shows at once");
|
||
assert!(level.hear(None), "no audio flattens the bars");
|
||
assert!(!level.hear(None));
|
||
|
||
// A quiet room's noise shows nothing, so it asks for no frames.
|
||
let mut quiet = general::MicLevel::default();
|
||
assert!(!quiet.hear(Some(0.01)));
|
||
assert!(!quiet.moving());
|
||
assert!(quiet.hear(Some(0.5)) && quiet.moving());
|
||
}
|
||
|
||
/// The row under the shortcut names the choice and opens Shortcut mode.
|
||
#[test]
|
||
fn the_shortcut_mode_row_names_the_choice() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
let name = |rt: &Runtime<Ui>| a11y_value(rt, "shortcut-mode-control");
|
||
assert_eq!(name(&rt).as_deref(), Some("Hold or double-tap"));
|
||
rt.state.settings.shortcut_mode = crate::dictation::ShortcutMode::Toggle;
|
||
refresh(&mut rt);
|
||
assert_eq!(name(&rt).as_deref(), Some("Tap"));
|
||
tap(&mut rt, "shortcut-mode-control");
|
||
assert!(rt.state.is_modal(Modal::Explainer));
|
||
}
|
||
|
||
#[test]
|
||
fn shortcut_mode_opens_from_its_row_and_keeps_focus_inside() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
rt.state.settings.dictation_hotkey.key = None;
|
||
refresh(&mut rt);
|
||
tab_to(&mut rt, "shortcut-mode-control");
|
||
key(&mut rt, Key::Text(" ".into()), Mods::default());
|
||
settle(&mut rt);
|
||
assert!(rt.state.is_modal(Modal::Explainer));
|
||
tab_to(&mut rt, "trigger-hold-or-double-tap");
|
||
// A lone modifier can't double-tap, so that option takes no focus.
|
||
let stops = [
|
||
"trigger-hold",
|
||
"trigger-tap",
|
||
"shortcut-mode-done",
|
||
"trigger-hold-or-double-tap",
|
||
];
|
||
for stop in stops {
|
||
key(&mut rt, Key::Tab, Mods::default());
|
||
assert!(
|
||
focused(&rt).ends_with(stop),
|
||
"Tab reached {} instead of {stop}",
|
||
focused(&rt)
|
||
);
|
||
}
|
||
key(&mut rt, Key::Escape, Mods::default());
|
||
settle(&mut rt);
|
||
assert!(!rt.state.is_modal(Modal::Explainer));
|
||
assert!(
|
||
focused(&rt).ends_with("shortcut-mode-control"),
|
||
"focus went to {}",
|
||
focused(&rt)
|
||
);
|
||
|
||
// Return presses Done, the default button, even from a focused option.
|
||
key(&mut rt, Key::Text(" ".into()), Mods::default());
|
||
settle(&mut rt);
|
||
tab_to(&mut rt, "trigger-tap");
|
||
key(&mut rt, Key::Enter, Mods::default());
|
||
settle(&mut rt);
|
||
assert!(!rt.state.is_modal(Modal::Explainer));
|
||
assert_eq!(
|
||
rt.state.settings.shortcut_mode,
|
||
crate::dictation::ShortcutMode::Hold
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn each_option_picks_its_trigger() {
|
||
use shortcut_mode::Trigger;
|
||
let mut rt = runtime("shortcut-mode-key", true, PANE_SIZE);
|
||
let trigger = |rt: &Runtime<Ui>| Trigger::of(&rt.state.settings);
|
||
assert_eq!(trigger(&rt), Trigger::DoubleTap);
|
||
tab_to(&mut rt, "trigger-tap");
|
||
key(&mut rt, Key::Text(" ".into()), Mods::default());
|
||
settle(&mut rt);
|
||
assert_eq!(trigger(&rt), Trigger::Tap);
|
||
assert_eq!(saved(&rt), 1);
|
||
for (option, picked) in [
|
||
("trigger-hold", Trigger::Hold),
|
||
("trigger-hold-or-double-tap", Trigger::HoldOrDoubleTap),
|
||
("trigger-double-tap", Trigger::DoubleTap),
|
||
] {
|
||
tap(&mut rt, option);
|
||
assert_eq!(trigger(&rt), picked);
|
||
}
|
||
tap(&mut rt, "trigger-double-tap");
|
||
assert_eq!(saved(&rt), 4, "picking the choice again saves nothing");
|
||
tap(&mut rt, "shortcut-mode-done");
|
||
assert!(!rt.state.is_modal(Modal::Explainer));
|
||
|
||
// With a lone modifier, Double-tap says why and does nothing.
|
||
let mut rt = runtime("shortcut-mode", true, PANE_SIZE);
|
||
let mut example = rt.state.settings.dictation_hotkey.clone();
|
||
example.key = Some(crate::app_settings::HotkeyKey::named("space"));
|
||
let why = format!(
|
||
"Needs a shortcut with a key, like {}",
|
||
example.keycaps().join("+")
|
||
);
|
||
assert!(texts(&rt).contains(&why));
|
||
tap(&mut rt, "trigger-double-tap");
|
||
assert_eq!(trigger(&rt), Trigger::HoldOrDoubleTap);
|
||
assert_eq!(saved(&rt), 0);
|
||
}
|
||
|
||
#[test]
|
||
fn the_explainer_loops_on_the_poll_clock() {
|
||
let mut rt = runtime("shortcut-mode-motion", true, PANE_SIZE);
|
||
let pressed = |rt: &Runtime<Ui>| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| e.path.ends_with("trigger-hold/visual/keys/keycap0/cap"))
|
||
.map(|e| e.target[1])
|
||
.unwrap()
|
||
};
|
||
let up = pressed(&rt);
|
||
// Hold presses from 0.4 s to 2.4 s into the loop.
|
||
rt.frame(1.0);
|
||
assert!(pressed(&rt) > up, "the keycap goes down while held");
|
||
rt.frame(2.0);
|
||
assert_eq!(pressed(&rt), up, "and comes back up");
|
||
let held = runtime("shortcut-mode", true, PANE_SIZE);
|
||
assert_eq!(held.state.explainer.time(), explainer::SNAPSHOT_MS);
|
||
}
|
||
|
||
#[test]
|
||
fn reduce_motion_shows_the_finished_explainer_without_waking() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
rt.set_system_reduced_motion(true);
|
||
settle(&mut rt);
|
||
assert_eq!(rt.wake_deadline(), None);
|
||
// Opened from outside a handler, so the next poll runs before any view.
|
||
explainer::open(&mut rt.state);
|
||
let mut tx = rune::Tx::default();
|
||
assert!(
|
||
!explainer::poll(&mut rt.state, 1.0, true, &mut tx),
|
||
"the first poll already knows"
|
||
);
|
||
settle(&mut rt);
|
||
assert!(rt.state.is_modal(Modal::Explainer));
|
||
assert_eq!(rt.state.explainer.time(), explainer::DONE);
|
||
assert_eq!(rt.wake_deadline(), None, "the loop never ticks");
|
||
}
|
||
|
||
/// The side picker and the recorder's right edge never move, whatever the
|
||
/// recorder shows, and with Reduce Motion its faces change in place.
|
||
#[test]
|
||
fn the_shortcut_row_holds_still_through_every_face_and_side() {
|
||
use crate::app_settings::HotkeyModifiers;
|
||
use settings::Capture;
|
||
fn rect(rt: &Runtime<Ui>, key: &str) -> [f32; 4] {
|
||
let found = rt
|
||
.elements()
|
||
.into_iter()
|
||
.find(|e| e.key.as_deref() == Some(key));
|
||
found.unwrap_or_else(|| panic!("no {key}")).rect
|
||
}
|
||
/// The side select's right edge and top, and the recorder's right edge.
|
||
fn place(rt: &Runtime<Ui>) -> ((f32, f32), f32) {
|
||
let recorder = rect(rt, "dictation-hotkey");
|
||
let side = rect(rt, "dictation-side-control-trigger");
|
||
((side[0] + side[2], side[1]), recorder[0] + recorder[2])
|
||
}
|
||
fn watch(rt: &mut Runtime<Ui>, at_rest: ((f32, f32), f32), reduced: bool) {
|
||
for _ in 0..45 {
|
||
rt.frame(1.0 / 60.0);
|
||
let ((side, top), edge) = place(rt);
|
||
assert_eq!((side, top), at_rest.0, "the side select moved");
|
||
assert!(
|
||
(edge - at_rest.1).abs() < 0.05,
|
||
"the recorder moved: {edge}"
|
||
);
|
||
if !reduced {
|
||
continue;
|
||
}
|
||
let elements = rt.elements();
|
||
let faces = elements
|
||
.iter()
|
||
.find(|e| e.path.ends_with("dictation-hotkey/content"))
|
||
.unwrap()
|
||
.rect;
|
||
for face in elements {
|
||
let shown = face.path.ends_with("dictation-hotkey/content/face");
|
||
if shown {
|
||
assert_eq!(face.rect[1], faces[1], "{} travelled", face.path);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for reduced in [false, true] {
|
||
let mut rt = runtime("shortcut-row", true, TALL_SIZE);
|
||
rt.set_system_reduced_motion(reduced);
|
||
open_advanced(&mut rt, Pane::General);
|
||
let at_rest = place(&rt);
|
||
for side in [1, 2, 0] {
|
||
pick(&mut rt, "dictation-side", side);
|
||
settle(&mut rt);
|
||
watch(&mut rt, at_rest, reduced);
|
||
}
|
||
let (x, y) = rt.find("dictation-hotkey").unwrap();
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_up(x, y);
|
||
watch(&mut rt, at_rest, reduced);
|
||
assert!(matches!(rt.state.capture, Capture::Listening { .. }));
|
||
settings::hold(&mut rt.state, HotkeyModifiers::option_command());
|
||
rt.invalidate();
|
||
watch(&mut rt, at_rest, reduced);
|
||
settings::hold(&mut rt.state, HotkeyModifiers::default());
|
||
key(&mut rt, Key::Text("d".into()), Mods::default());
|
||
watch(&mut rt, at_rest, reduced);
|
||
rt.state.capture = Capture::Saved {
|
||
target: ShortcutTarget::Dictation,
|
||
until: None,
|
||
};
|
||
rt.invalidate();
|
||
watch(&mut rt, at_rest, reduced);
|
||
rt.state.capture = Capture::Idle;
|
||
rt.invalidate();
|
||
watch(&mut rt, at_rest, reduced);
|
||
// A chord keeps the recorder's right edge too.
|
||
let (x, y) = rt.find("dictation-hotkey").unwrap();
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_up(x, y);
|
||
settle(&mut rt);
|
||
let ctrl_alt = Mods {
|
||
ctrl: true,
|
||
alt: true,
|
||
..Mods::default()
|
||
};
|
||
key(&mut rt, Key::Text("d".into()), ctrl_alt);
|
||
for _ in 0..45 {
|
||
let recorder = rect(&rt, "dictation-hotkey");
|
||
let edge = recorder[0] + recorder[2];
|
||
assert!(
|
||
(edge - at_rest.1).abs() < 0.05,
|
||
"the recorder moved: {edge}"
|
||
);
|
||
rt.frame(1.0 / 60.0);
|
||
}
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn esc_stays_on_the_recorder_however_many_keys_are_held() {
|
||
use crate::app_settings::{HotkeyModifiers, ModifierSide};
|
||
let mut rt = runtime("shortcut-row", true, PANE_SIZE);
|
||
tap(&mut rt, "dictation-hotkey");
|
||
let any = Some(ModifierSide::Either);
|
||
settings::hold(
|
||
&mut rt.state,
|
||
HotkeyModifiers {
|
||
control: any,
|
||
option: any,
|
||
shift: any,
|
||
command: any,
|
||
function: false,
|
||
},
|
||
);
|
||
refresh(&mut rt);
|
||
let recorder = rt
|
||
.elements()
|
||
.into_iter()
|
||
.find(|e| e.key.as_deref() == Some("dictation-hotkey"))
|
||
.unwrap()
|
||
.rect;
|
||
let (escape, opacity) = drawn(&rt, "dictation-hotkey/content/face/escape").unwrap();
|
||
assert_eq!(opacity, 1.0);
|
||
assert!(
|
||
escape[0] + escape[2] <= recorder[0] + recorder[2],
|
||
"esc is pushed out of the recorder"
|
||
);
|
||
let held = drawn(&rt, "dictation-hotkey/content/face/held").unwrap().0;
|
||
assert!(
|
||
held[0] + held[2] <= escape[0],
|
||
"the held keys run under esc"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn the_practice_game_follows_hex_s_own_dictation_on_every_os() {
|
||
for scene in ["mac-onboarding-try", "onboarding-try"] {
|
||
let mut rt = runtime(scene, true, PANE_SIZE);
|
||
let holding = |rt: &Runtime<Ui>| {
|
||
rt.state
|
||
.first_run
|
||
.as_ref()
|
||
.is_some_and(|s| s.live_hold_from().is_some())
|
||
};
|
||
assert!(rt.find("done").is_some(), "{scene}: the game shows Done");
|
||
assert!(!holding(&rt));
|
||
onboarding::input(&mut rt.state, Input::Dictation(Observation::Started));
|
||
refresh(&mut rt);
|
||
assert!(holding(&rt), "{scene}: the shortcut held, as Hex records");
|
||
onboarding::input(&mut rt.state, Input::Dictation(Observation::Transcribing));
|
||
refresh(&mut rt);
|
||
assert!(!holding(&rt), "{scene}: released");
|
||
}
|
||
}
|
||
|
||
/// The practice waits for the listener: while it warms up, the page says Hex
|
||
/// is getting ready instead of inviting a hold that does nothing.
|
||
#[test]
|
||
fn the_practice_page_waits_for_the_listener() {
|
||
let warming = "Getting Hex ready to listen…";
|
||
let warming_state = |rt: &mut Runtime<Ui>, warming: bool| {
|
||
if let Some(view) = &mut rt.state.view {
|
||
view.listener.warming = warming;
|
||
}
|
||
refresh(rt);
|
||
};
|
||
for scene in ["mac-onboarding-try", "onboarding-try"] {
|
||
let mut rt = runtime(scene, true, PANE_SIZE);
|
||
warming_state(&mut rt, true);
|
||
let shown = texts(&rt);
|
||
assert!(
|
||
shown.iter().any(|text| text == warming),
|
||
"{scene}: {shown:?}"
|
||
);
|
||
assert!(
|
||
!shown
|
||
.iter()
|
||
.any(|text| text == "and answer the one that's lit."),
|
||
"{scene}: no hold prompt while warming: {shown:?}"
|
||
);
|
||
warming_state(&mut rt, false);
|
||
let shown = texts(&rt);
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "and answer the one that's lit."),
|
||
"{scene}: the hold prompt returns: {shown:?}"
|
||
);
|
||
assert!(
|
||
!shown.iter().any(|text| text == warming),
|
||
"{scene}: {shown:?}"
|
||
);
|
||
}
|
||
|
||
// The plain practice field, without the game, says the same.
|
||
let mut rt = runtime("onboarding-try", true, PANE_SIZE);
|
||
if let Some(s) = rt.state.first_run.as_mut() {
|
||
s.practice_field = true;
|
||
}
|
||
warming_state(&mut rt, true);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == warming), "{shown:?}");
|
||
assert!(
|
||
!shown.iter().any(|text| text == "and say anything."),
|
||
"{shown:?}"
|
||
);
|
||
}
|
||
|
||
/// Shortcut mode's options, by key.
|
||
const TRIGGERS: [&str; 4] = [
|
||
"trigger-hold-or-double-tap",
|
||
"trigger-hold",
|
||
"trigger-tap",
|
||
"trigger-double-tap",
|
||
];
|
||
|
||
#[test]
|
||
fn shortcut_mode_draws_a_keycap_per_key_and_lines_up_the_lanes() {
|
||
use crate::app_settings::{HotkeyBinding, HotkeyModifiers};
|
||
let mut rt = runtime("shortcut-mode-chord", true, PANE_SIZE);
|
||
let default = rt.state.settings.dictation_hotkey.clone();
|
||
let one = HotkeyBinding {
|
||
modifiers: HotkeyModifiers {
|
||
option: default.modifiers.option,
|
||
..HotkeyModifiers::default()
|
||
},
|
||
key: None,
|
||
};
|
||
let three = rt.state.settings.dictation_hotkey.clone();
|
||
for binding in [one, default, three] {
|
||
rt.state.settings.dictation_hotkey = binding.clone();
|
||
refresh(&mut rt);
|
||
let elements = rt.elements();
|
||
let rect = |suffix: &str| {
|
||
elements
|
||
.iter()
|
||
.find(|e| e.path.ends_with(suffix))
|
||
.map(|e| e.target)
|
||
.unwrap_or_else(|| panic!("no {suffix}"))
|
||
};
|
||
let labels = binding.keycaps();
|
||
for owner in TRIGGERS {
|
||
let caps: Vec<_> = (0..labels.len())
|
||
.map(|index| rect(&format!("{owner}/visual/keys/keycap{index}")))
|
||
.collect();
|
||
assert!(
|
||
elements.iter().all(|e| !e
|
||
.path
|
||
.ends_with(&format!("{owner}/visual/keys/keycap{}", labels.len()))),
|
||
"{owner} draws one keycap per key of {labels:?}"
|
||
);
|
||
for pair in caps.windows(2) {
|
||
assert!(
|
||
pair[1][0] > pair[0][0] + pair[0][2],
|
||
"{owner}'s keycaps sit side by side"
|
||
);
|
||
assert_eq!(pair[0][1], pair[1][1], "{owner}'s keycaps share a baseline");
|
||
}
|
||
}
|
||
let hold = rect("trigger-hold/visual/lanes");
|
||
for owner in TRIGGERS {
|
||
let lanes = rect(&format!("{owner}/visual/lanes"));
|
||
assert!(
|
||
(hold[0] - lanes[0]).abs() < 0.5 && (hold[2] - lanes[2]).abs() < 0.5,
|
||
"{labels:?}: {owner}'s lanes line up with Hold's"
|
||
);
|
||
}
|
||
assert!(hold[2] > 30.0, "{labels:?}: lanes keep room to draw");
|
||
}
|
||
}
|
||
|
||
/// A five-key chord widens the panel so every option's lanes keep room, and
|
||
/// the keycaps stay inside their options.
|
||
#[test]
|
||
fn a_long_chord_widens_shortcut_mode() {
|
||
use crate::app_settings::{HotkeyBinding, HotkeyKey, HotkeyModifiers, ModifierSide};
|
||
let mut rt = runtime("shortcut-mode-chord", true, PANE_SIZE);
|
||
let side = Some(ModifierSide::Either);
|
||
rt.state.settings.dictation_hotkey = HotkeyBinding {
|
||
modifiers: HotkeyModifiers {
|
||
control: side,
|
||
option: side,
|
||
shift: side,
|
||
command: side,
|
||
..HotkeyModifiers::default()
|
||
},
|
||
key: Some(HotkeyKey::named("space")),
|
||
};
|
||
refresh(&mut rt);
|
||
let elements = rt.elements();
|
||
let rect = |suffix: &str| {
|
||
elements
|
||
.iter()
|
||
.find(|e| e.path.ends_with(suffix))
|
||
.map(|e| e.target)
|
||
.unwrap_or_else(|| panic!("no {suffix}"))
|
||
};
|
||
let panel = rect("shortcut-mode-modal");
|
||
assert!(panel[0] >= 0.0 && panel[0] + panel[2] <= PANE_SIZE.0);
|
||
for owner in TRIGGERS {
|
||
let (card, keys, lanes) = (
|
||
rect(&format!("options/{owner}")),
|
||
rect(&format!("{owner}/visual/keys")),
|
||
rect(&format!("{owner}/visual/lanes")),
|
||
);
|
||
assert!(lanes[2] >= 63.5, "{owner}'s lanes keep room: {lanes:?}");
|
||
assert!(
|
||
keys[0] >= card[0] && lanes[0] >= keys[0] + keys[2],
|
||
"{owner}: {card:?} {keys:?} {lanes:?} {panel:?}"
|
||
);
|
||
assert!(
|
||
lanes[0] + lanes[2] <= card[0] + card[2],
|
||
"{owner}'s lanes stay in the option"
|
||
);
|
||
}
|
||
}
|
||
|
||
/// Reduce Motion is read again when the window gains focus, after that
|
||
/// frame's poll; the tape starts again on the next.
|
||
#[test]
|
||
fn the_explainer_restarts_when_reduce_motion_turns_off() {
|
||
let mut rt = runtime("shortcut-mode-motion", true, PANE_SIZE);
|
||
rt.set_system_reduced_motion(true);
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.explainer.time(), explainer::DONE);
|
||
assert_eq!(rt.wake_deadline(), None);
|
||
rt.window_focus(false);
|
||
settle(&mut rt);
|
||
rt.set_system_reduced_motion(false);
|
||
rt.window_focus(true);
|
||
// A host draws no further frame unless one is asked for.
|
||
rt.frame(1.0 / 60.0);
|
||
assert!(
|
||
rt.wake_deadline().is_some(),
|
||
"the focus frame asks for another"
|
||
);
|
||
settle(&mut rt);
|
||
let before = rt.state.explainer.time();
|
||
rt.frame(0.25);
|
||
assert_ne!(rt.state.explainer.time(), before, "and moves");
|
||
}
|
||
|
||
#[test]
|
||
fn the_explainer_picker_and_shortcut_recording_never_share_the_window() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
tap(&mut rt, "dictation-hotkey");
|
||
assert!(matches!(
|
||
rt.state.capture,
|
||
settings::Capture::Listening { .. }
|
||
));
|
||
explainer::open(&mut rt.state);
|
||
assert!(matches!(rt.state.capture, settings::Capture::Idle));
|
||
assert!(sent(&rt).contains(&Request::CancelShortcut));
|
||
|
||
picker::open(&mut rt.state);
|
||
assert!(
|
||
rt.state.is_modal(Modal::Picker),
|
||
"the picker replaces the explainer"
|
||
);
|
||
picker::close(&mut rt.state);
|
||
tap(&mut rt, "dictation-hotkey");
|
||
assert!(matches!(
|
||
rt.state.capture,
|
||
settings::Capture::Listening { .. }
|
||
));
|
||
picker::open(&mut rt.state);
|
||
assert!(matches!(rt.state.capture, settings::Capture::Idle));
|
||
explainer::open(&mut rt.state);
|
||
assert!(
|
||
rt.state.is_modal(Modal::Explainer),
|
||
"and the explainer replaces the picker"
|
||
);
|
||
|
||
rt.state
|
||
.select_pane(Pane::History, &mut rune::Tx::default());
|
||
assert_eq!(rt.state.modal, None);
|
||
picker::open(&mut rt.state);
|
||
rt.state
|
||
.select_pane(Pane::General, &mut rune::Tx::default());
|
||
assert_eq!(rt.state.modal, None);
|
||
}
|
||
|
||
#[test]
|
||
fn meetings_switch_between_recordings_and_settings() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
assert!(rt.find("meeting-preview-design").is_some());
|
||
assert!(rt.find("meetings-enabled").is_none());
|
||
tap(&mut rt, "meetings-view/segment1");
|
||
assert_eq!(rt.state.meetings.view, meetings::View::Settings);
|
||
assert!(rt.find("meetings-enabled").is_some());
|
||
assert!(rt.find("meeting-preview-design").is_none());
|
||
tap(&mut rt, "meetings-view/segment0");
|
||
assert!(rt.find("meeting-preview-design").is_some());
|
||
}
|
||
|
||
#[test]
|
||
fn a_meeting_recording_error_can_be_dismissed() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
rt.state.meetings.runtime_error = Some("Browser call: Access is denied.".into());
|
||
refresh(&mut rt);
|
||
assert!(rt.find("meeting-runtime-error").is_some());
|
||
tap(&mut rt, "meeting-runtime-error/dismiss");
|
||
assert_eq!(rt.state.meetings.runtime_error, None);
|
||
assert!(rt.find("meeting-runtime-error").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn the_meetings_switch_stays_put_and_a_swap_drops_pending_edits() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
let switch = |rt: &Runtime<Ui>| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| e.key.as_deref() == Some("meetings-view"))
|
||
.map(|e| e.rect)
|
||
.unwrap()
|
||
};
|
||
let recordings = switch(&rt);
|
||
rename(&mut rt);
|
||
assert!(rt.state.meetings.renaming.is_some());
|
||
rt.state.meetings.delete_armed = Some("preview-notes".into());
|
||
tap(&mut rt, "meetings-view/segment1");
|
||
assert_eq!(switch(&rt), recordings, "the search field never moves it");
|
||
assert!(rt.state.meetings.renaming.is_none());
|
||
assert!(rt.state.meetings.delete_armed.is_none());
|
||
|
||
tap(&mut rt, "meetings-enabled");
|
||
assert!(!rt.state.settings.meetings.enabled);
|
||
assert_eq!(rt.state.meetings.view, meetings::View::Recordings);
|
||
}
|
||
|
||
#[test]
|
||
fn an_update_is_a_secondary_button_with_a_dot_and_its_own_label() {
|
||
let mut rt = runtime("mac-update-ready", true, PANE_SIZE);
|
||
assert!(rt.find("sidebar-update-control/dot").is_some());
|
||
assert!(texts(&rt).iter().any(|text| text == "Restart to update"));
|
||
tap(&mut rt, "sidebar-update");
|
||
assert!(matches!(
|
||
sent(&rt),
|
||
[Request::Desktop(DesktopAction::RestartIntoUpdate)]
|
||
));
|
||
if let Some(view) = &mut rt.state.view {
|
||
view.update_status = DesktopUpdateStatus::Available;
|
||
}
|
||
refresh(&mut rt);
|
||
assert!(texts(&rt).iter().any(|text| text == "Download update"));
|
||
}
|
||
|
||
#[test]
|
||
fn release_notes_link_shows_only_for_a_published_build() {
|
||
let mut rt = runtime("portal", true, PANE_SIZE);
|
||
rt.state.build_preview = Some(BuildKind::Release);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("release-notes").is_some());
|
||
assert!(rt.find("nav-whats-new").is_some());
|
||
|
||
for (kind, name) in [
|
||
(
|
||
BuildKind::Local {
|
||
version: "3.4.0",
|
||
commit: None,
|
||
},
|
||
"local",
|
||
),
|
||
(BuildKind::Test, "test"),
|
||
] {
|
||
rt.state.build_preview = Some(kind);
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("release-notes").is_none(),
|
||
"a {name} build has no published notes"
|
||
);
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn a_staged_dev_build_lists_its_first_changes_under_the_update() {
|
||
let mut rt = runtime("mac-update-ready", true, PANE_SIZE);
|
||
assert!(
|
||
rt.find("sidebar-update-notes").is_none(),
|
||
"no notes, no list"
|
||
);
|
||
if let Some(view) = &mut rt.state.view {
|
||
view.update_notes = Some(crate::desktop::host::UpdateNotes {
|
||
items: ["One", "Two", "Three", "Four"].map(String::from).to_vec(),
|
||
url: "https://anoma.ly/hex/dev#0.0.0-dev-2".into(),
|
||
});
|
||
}
|
||
refresh(&mut rt);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Release notes"));
|
||
assert!(shown.iter().any(|text| text == "· Three"));
|
||
assert!(!shown.iter().any(|text| text == "· Four"), "three at most");
|
||
assert!(rt.find("sidebar-update-control/dot").is_some());
|
||
}
|
||
|
||
#[test]
|
||
fn meetings_off_offers_the_opt_in_and_keeps_the_pane() {
|
||
let mut rt = runtime("meetings-off", true, PANE_SIZE);
|
||
assert!(rt.find("meetings-view").is_none());
|
||
assert!(rt.find("start-meeting").is_none());
|
||
tap(&mut rt, "meetings-turn-on");
|
||
assert!(rt.state.settings.meetings.enabled);
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("nav-meetings").is_some(),
|
||
"on, it joins the sidebar"
|
||
);
|
||
assert!(rt.find("meetings-view").is_some());
|
||
}
|
||
|
||
/// Labs › Choose meeting audio puts Computer audio in Meetings › Settings:
|
||
/// all computer audio first, and a saved device the list doesn't have stays
|
||
/// visible with why, so the choice is never silently lost.
|
||
#[test]
|
||
fn meeting_audio_source_lists_all_audio_and_keeps_a_missing_choice_visible() {
|
||
use crate::meeting::audio_source::SourceChoice;
|
||
let mut rt = runtime("meetings-settings", true, (980.0, 2400.0));
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("meeting-audio-source").is_none(),
|
||
"hidden while the lab is off"
|
||
);
|
||
assert_eq!(
|
||
rt.state.settings.labs.meeting_audio_source_choice,
|
||
SourceChoice::All
|
||
);
|
||
rt.update(|ui, _| ui.settings.labs.meeting_audio_source = true);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("meeting-audio-source").is_some());
|
||
assert_eq!(
|
||
a11y_value(&rt, "meeting-audio-source-control-trigger").as_deref(),
|
||
Some("All computer audio")
|
||
);
|
||
rt.update(|ui, _| {
|
||
ui.settings.labs.meeting_audio_source_choice = SourceChoice::Output {
|
||
id: "alsa_output.dock".into(),
|
||
name: "Dock speakers".into(),
|
||
};
|
||
});
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
a11y_value(&rt, "meeting-audio-source-control-trigger").as_deref(),
|
||
Some("Dock speakers"),
|
||
"the saved device stays the shown choice"
|
||
);
|
||
assert!(
|
||
texts(&rt).iter().any(|text| text == "not connected"),
|
||
"a missing device says why it isn't listed"
|
||
);
|
||
tap(&mut rt, "meeting-audio-source-control-trigger");
|
||
tap(&mut rt, "meeting-audio-source-menu-item0");
|
||
assert_eq!(
|
||
rt.state.settings.labs.meeting_audio_source_choice,
|
||
SourceChoice::All
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn meetings_settings_save_and_ask_for_system_audio() {
|
||
let mut rt = runtime("meetings-settings", true, (980.0, 2400.0));
|
||
rt.state.platform.system_audio = false;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "meeting-system-audio-allow");
|
||
assert_eq!(asked(&rt), [PlatformRequest::SystemAudio]);
|
||
tap(&mut rt, "meetings-enabled");
|
||
assert!(!rt.state.settings.meetings.enabled);
|
||
assert!(rt.find("meeting-folder").is_none());
|
||
assert!(rt.find("calls").is_none());
|
||
assert!(rt.find("meetings-turn-on").is_some(), "the opt-in remains");
|
||
}
|
||
|
||
/// The Calls row opens the sheet; its radios set the answer every call
|
||
/// gets, and each row's menu gives one app or website its own.
|
||
#[test]
|
||
fn the_calls_sheet_saves_the_default_and_each_answer() {
|
||
use crate::app_settings::MeetingPolicy;
|
||
let mut rt = runtime("meetings-settings", true, (980.0, 2400.0));
|
||
let policy = |rt: &Runtime<Ui>, key: &str| rt.state.settings.meetings.policy_for(key);
|
||
assert_eq!(
|
||
a11y_value(&rt, "calls-control").as_deref(),
|
||
Some("Ask each time")
|
||
);
|
||
tap(&mut rt, "calls");
|
||
assert!(rt.state.is_modal(Modal::Calls));
|
||
// Seen calls newest first (Slack, Zoom, Google Meet, a website), then
|
||
// the saved answer Hex hasn't seen a call in.
|
||
pick(&mut rt, "call1-policy", 1);
|
||
assert_eq!(policy(&rt, "us.zoom.xos"), MeetingPolicy::AlwaysRecord);
|
||
pick(&mut rt, "call4-policy", 0);
|
||
assert_eq!(policy(&rt, "example.com"), MeetingPolicy::Ask);
|
||
assert!(rt.find("call4").is_some(), "a saved answer stays listed");
|
||
// A new default carries the calls that followed the old one.
|
||
pick(&mut rt, "calls-default", 2);
|
||
let meetings = &rt.state.settings.meetings;
|
||
assert_eq!(meetings.default_policy, MeetingPolicy::NeverOffer);
|
||
assert_eq!(policy(&rt, "meet.google.com"), MeetingPolicy::NeverOffer);
|
||
assert_eq!(policy(&rt, "example.com"), MeetingPolicy::NeverOffer);
|
||
assert_eq!(policy(&rt, "us.zoom.xos"), MeetingPolicy::AlwaysRecord);
|
||
tap(&mut rt, "close-calls");
|
||
assert!(!rt.state.is_modal(Modal::Calls));
|
||
}
|
||
|
||
/// Before Hex has seen a call, the sheet says where they'll come from.
|
||
#[test]
|
||
fn an_empty_calls_sheet_says_what_fills_it() {
|
||
let rt = runtime("meetings-calls-empty", true, (980.0, 2400.0));
|
||
assert!(rt.find("calls-empty").is_some());
|
||
assert!(rt.find("call0").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn the_calendar_asks_for_access_only_when_connect_is_pressed() {
|
||
let mut rt = runtime("meetings-settings", true, (980.0, 2400.0));
|
||
assert!(rt.find("calendar-connect").is_some());
|
||
assert!(rt.find("calendar-remind").is_none());
|
||
assert!(asked(&rt).is_empty());
|
||
tap(&mut rt, "calendar-connect-button");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Calendar(CalendarRequest::Connect)]
|
||
);
|
||
|
||
// Meetings off: no calendar card, so nothing can ask for access.
|
||
tap(&mut rt, "meetings-enabled");
|
||
assert!(rt.find("calendar").is_none());
|
||
for scene in ["portal", "windows-settings"] {
|
||
let rt = runtime(scene, true, GOLDEN_SIZE);
|
||
assert!(rt.find("calendar").is_none(), "{scene} has no calendar");
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn a_connected_calendar_saves_reminders_and_lists_meetings() {
|
||
let mut rt = runtime("meetings-calendar", true, (980.0, 2600.0));
|
||
let shown = texts(&rt);
|
||
for text in [
|
||
"Design sync",
|
||
"Today · 2:30 PM",
|
||
"Google Meet",
|
||
"2 of 3 calendars",
|
||
] {
|
||
assert!(shown.iter().any(|shown| shown == text), "shows {text}");
|
||
}
|
||
assert!(rt.find("upcoming2").is_some());
|
||
assert!(
|
||
rt.find("upcoming2/provider/icon").is_none(),
|
||
"no link, no icon"
|
||
);
|
||
pick(&mut rt, "calendar-lead", 3);
|
||
assert_eq!(rt.state.settings.meetings.calendar.lead_minutes, 5);
|
||
tap(&mut rt, "calendar-remind");
|
||
assert!(!rt.state.settings.meetings.calendar.remind);
|
||
assert!(rt.find("calendar-lead").is_none());
|
||
tap(&mut rt, "calendar-calendars-control-trigger");
|
||
assert_eq!(rt.state.open, Some(Menu::Calendars));
|
||
}
|
||
|
||
/// Labs › Select all calendars puts one bulk button beside the Calendars
|
||
/// select; off by default, it adds nothing.
|
||
#[test]
|
||
fn the_select_all_calendars_lab_saves_every_calendar_at_once() {
|
||
let mut rt = runtime("meetings-calendar", true, (980.0, 2600.0));
|
||
assert!(
|
||
rt.find("calendar-select-all").is_none(),
|
||
"the lab is off by default"
|
||
);
|
||
assert!(
|
||
rt.find("calendar-calendars-controls").is_none(),
|
||
"off, the row is the select alone"
|
||
);
|
||
rt.update(|ui, _| ui.settings.labs.calendar_bulk_select = true);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("calendar-select-all").is_some());
|
||
assert!(texts(&rt).iter().any(|text| text == "2 of 3 calendars"));
|
||
assert!(texts(&rt).iter().any(|text| text == "Select all"));
|
||
|
||
tap(&mut rt, "calendar-select-all");
|
||
assert_eq!(
|
||
rt.state.settings.meetings.calendar.excluded_calendars,
|
||
Vec::<String>::new()
|
||
);
|
||
assert!(texts(&rt).iter().any(|text| text == "All calendars"));
|
||
assert!(texts(&rt).iter().any(|text| text == "Deselect all"));
|
||
|
||
// A stale exclusion that names no current calendar leaves every current
|
||
// calendar included, so the button still offers Deselect all.
|
||
rt.update(|ui, _| {
|
||
ui.settings.meetings.calendar.excluded_calendars = vec!["gone".to_string()];
|
||
});
|
||
refresh(&mut rt);
|
||
assert!(texts(&rt).iter().any(|text| text == "All calendars"));
|
||
assert!(texts(&rt).iter().any(|text| text == "Deselect all"));
|
||
|
||
tap(&mut rt, "calendar-select-all");
|
||
assert_eq!(
|
||
rt.state.settings.meetings.calendar.excluded_calendars,
|
||
vec![
|
||
"work".to_string(),
|
||
"home".to_string(),
|
||
"birthdays".to_string()
|
||
],
|
||
"the stale id is replaced by the calendars shown now"
|
||
);
|
||
assert!(texts(&rt).iter().any(|text| text == "0 of 3 calendars"));
|
||
assert!(texts(&rt).iter().any(|text| text == "Select all"));
|
||
|
||
{
|
||
// An organization's Labs lock closes the Meetings pane itself
|
||
// (`meetings::available`), so the button goes with it; the saved
|
||
// setting stays as it was.
|
||
use crate::policy::{Lock, Policy};
|
||
let _locked = Policy::forced_for_test(Policy::default().with(Lock::Labs));
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("meetings-enabled").is_some(),
|
||
"the lock takes effect"
|
||
);
|
||
assert!(
|
||
rt.find("calendar-select-all").is_none(),
|
||
"a locked lab hides the button"
|
||
);
|
||
assert!(rt.state.settings.labs.calendar_bulk_select);
|
||
}
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("calendar-select-all").is_some(),
|
||
"unlocked, the button is back"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn denied_calendar_access_links_to_privacy_settings() {
|
||
let mut rt = runtime("meetings-calendar-denied", true, (980.0, 2400.0));
|
||
assert!(rt.find("calendar-connect").is_none());
|
||
tap(&mut rt, "calendar-privacy");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Calendar(
|
||
CalendarRequest::OpenPrivacySettings
|
||
)]
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn meetings_select_search_and_copy_a_transcript() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "meeting-preview-design");
|
||
assert_eq!(
|
||
rt.state.meetings.selected.as_deref(),
|
||
Some("preview-design")
|
||
);
|
||
tap(&mut rt, "meeting-copy-transcript");
|
||
let copied = rt.copy_request.as_deref().unwrap().to_owned();
|
||
assert!(copied.starts_with("**You** · 00:09\nOh nice."), "{copied}");
|
||
rt.state.meetings.search = TextEdit::new("roblox");
|
||
refresh(&mut rt);
|
||
assert!(rt.find("meeting-preview-failed").is_none());
|
||
assert!(
|
||
rt.find("meeting-preview-notes").is_some(),
|
||
"searches transcripts"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn recording_starts_and_stops_from_the_header() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "stop-meeting");
|
||
assert_eq!(asked(&rt), [PlatformRequest::Meeting(MeetingRequest::Stop)]);
|
||
assert!(rt.find("stop-meeting").is_none(), "finalizing");
|
||
|
||
let mut rt = runtime("meetings-empty", true, PANE_SIZE);
|
||
assert!(texts(&rt).iter().any(|text| text == "No meetings yet"));
|
||
tap(&mut rt, "start-meeting");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Start)]
|
||
);
|
||
}
|
||
|
||
/// Rename is in the detail's ⋯ menu.
|
||
fn rename(rt: &mut Runtime<Ui>) {
|
||
tap(rt, "meeting-more");
|
||
let rename = menu_item(rt, "meeting-actions", "Rename…");
|
||
tap(rt, &rename);
|
||
}
|
||
|
||
#[test]
|
||
fn meetings_rename_from_the_title_field() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
rename(&mut rt);
|
||
assert_eq!(rt.state.meetings.renaming.as_deref(), Some("preview-notes"));
|
||
rt.state.meetings.rename = TextEdit::new("Arcade launch");
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "meeting-save-title");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Rename {
|
||
id: "preview-notes".into(),
|
||
title: "Arcade launch".into(),
|
||
})]
|
||
);
|
||
assert_eq!(rt.state.meetings.meetings[1].title, "Arcade launch");
|
||
assert!(rt.state.meetings.renaming.is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn deleting_a_meeting_takes_the_menu_then_a_confirmation() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "meeting-more");
|
||
assert_eq!(rt.state.open, Some(Menu::MeetingActions));
|
||
// Copy summary, Reveal Markdown, Reveal files, Regenerate summary, a
|
||
// separator, Delete.
|
||
let delete = menu_item(&rt, "meeting-actions", "Delete…");
|
||
tap(&mut rt, &delete);
|
||
assert_eq!(
|
||
rt.state.meetings.delete_armed.as_deref(),
|
||
Some("preview-notes")
|
||
);
|
||
assert!(asked(&rt).is_empty(), "the first step only arms");
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text == "Trash recording & Markdown")
|
||
);
|
||
tap(&mut rt, "meeting-confirm-delete");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Trash(
|
||
"preview-notes".into()
|
||
))]
|
||
);
|
||
assert!(
|
||
rt.state
|
||
.meetings
|
||
.meetings
|
||
.iter()
|
||
.all(|m| m.id != "preview-notes")
|
||
);
|
||
|
||
let mut rt = runtime("meetings-delete", true, PANE_SIZE);
|
||
key(&mut rt, Key::Escape, Mods::default());
|
||
assert!(rt.state.meetings.delete_armed.is_none(), "Escape cancels");
|
||
|
||
let mut rt = runtime("meetings-delete", true, PANE_SIZE);
|
||
key(&mut rt, Key::Enter, Mods::default());
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Trash(
|
||
"preview-notes".into()
|
||
))],
|
||
"Return confirms"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn deleting_transcript_lines_needs_the_lab_a_selection_and_a_confirmation() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
assert!(
|
||
rt.find("meeting-select-lines").is_none(),
|
||
"the lab is off: no selection UI"
|
||
);
|
||
|
||
rt.state.settings.labs.transcript_edits = true;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "meeting-select-lines");
|
||
assert!(rt.state.meetings.selection.active());
|
||
assert!(texts(&rt).iter().any(|text| text == "0 lines selected"));
|
||
|
||
// One turn reads in the singular, however many lines it covers.
|
||
tap(&mut rt, "select-turn0");
|
||
assert_eq!(rt.state.meetings.selection.len(), 1);
|
||
assert!(texts(&rt).iter().any(|text| text == "1 line selected"));
|
||
tap(&mut rt, "meeting-delete-lines");
|
||
assert!(texts(&rt).iter().any(|text| text == "Delete 1 line"));
|
||
tap(&mut rt, "meeting-cancel-delete-lines");
|
||
|
||
// A mixed pair: one Them turn and one You turn, each one published line.
|
||
tap(&mut rt, "select-turn2");
|
||
assert_eq!(rt.state.meetings.selection.len(), 2);
|
||
assert!(texts(&rt).iter().any(|text| text == "2 lines selected"));
|
||
|
||
tap(&mut rt, "meeting-delete-lines");
|
||
assert!(asked(&rt).is_empty(), "the first press only arms");
|
||
tap(&mut rt, "meeting-confirm-delete-lines");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::DeleteTranscript {
|
||
id: "preview-notes".into(),
|
||
entries: vec![
|
||
crate::meeting::TranscriptEntryKey {
|
||
source: crate::meeting::MeetingSource::System,
|
||
start_ms: 1_000,
|
||
end_ms: 2_000,
|
||
},
|
||
crate::meeting::TranscriptEntryKey {
|
||
source: crate::meeting::MeetingSource::Microphone,
|
||
start_ms: 9_000,
|
||
end_ms: 10_000,
|
||
},
|
||
],
|
||
})],
|
||
"exactly one request, for the lines under the two turns"
|
||
);
|
||
assert!(!rt.state.meetings.selection.active());
|
||
}
|
||
|
||
/// The bar only promises to remove notes that exist, and a selection the pane
|
||
/// no longer offers goes away with it.
|
||
#[test]
|
||
fn the_selection_bar_only_warns_about_notes_that_exist() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
rt.state.settings.labs.transcript_edits = true;
|
||
refresh(&mut rt);
|
||
let warns = |rt: &Runtime<Ui>| {
|
||
texts(rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("Its summary and chapters will be removed"))
|
||
};
|
||
|
||
// The notes meeting has a summary.
|
||
tap(&mut rt, "meeting-select-lines");
|
||
assert!(warns(&rt));
|
||
tap(&mut rt, "meeting-cancel-selection");
|
||
|
||
// The design review is Complete with a transcript but no summary or chapters.
|
||
tap(&mut rt, "meeting-preview-design");
|
||
tap(&mut rt, "meeting-select-lines");
|
||
assert!(!warns(&rt));
|
||
|
||
// Turning the lab off takes the selection away with it.
|
||
rt.state.settings.labs.transcript_edits = false;
|
||
refresh(&mut rt);
|
||
assert!(!rt.state.meetings.selection.active());
|
||
}
|
||
|
||
#[test]
|
||
fn the_overflow_menu_copies_the_summary_and_asks_for_new_notes() {
|
||
let mut rt = runtime("meetings-actions", true, PANE_SIZE);
|
||
let copy = menu_item(&rt, "meeting-actions", "Copy summary");
|
||
tap(&mut rt, ©);
|
||
assert!(
|
||
rt.copy_request
|
||
.as_deref()
|
||
.is_some_and(|summary| summary.starts_with("One login"))
|
||
);
|
||
assert_eq!(rt.state.open, Some(Menu::MeetingActions), "stays open");
|
||
let regenerate = menu_item(&rt, "meeting-actions", "Regenerate summary");
|
||
tap(&mut rt, ®enerate);
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Summarize(
|
||
"preview-notes".into()
|
||
))]
|
||
);
|
||
}
|
||
|
||
/// Regenerating a summary keeps the old one visible under a spinner and the
|
||
/// writer's line, while the row and the menu say "Summarizing…" (#2556).
|
||
#[test]
|
||
fn regenerating_a_summary_shows_progress_above_the_old_summary() {
|
||
let mut rt = runtime("meetings-actions", true, PANE_SIZE);
|
||
let meeting = rt
|
||
.state
|
||
.meetings
|
||
.meetings
|
||
.iter_mut()
|
||
.find(|meeting| meeting.id == "preview-notes")
|
||
.unwrap();
|
||
meeting.notes_running = true;
|
||
refresh(&mut rt);
|
||
assert!(rt.find("notes-running").is_some(), "the spinner row");
|
||
let shown = texts(&rt);
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text.starts_with("Writing a title and summary with")),
|
||
"{shown:?}"
|
||
);
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text.starts_with("One login for every Anomaly Arcade game")),
|
||
"the old summary stays visible: {shown:?}"
|
||
);
|
||
assert!(
|
||
texts_under(&rt, "meeting-preview-notes")
|
||
.iter()
|
||
.any(|text| text.starts_with("Summarizing…")),
|
||
"the list row says so"
|
||
);
|
||
assert!(
|
||
shown.iter().any(|text| text == "Summarizing…"),
|
||
"the menu's disabled item: {shown:?}"
|
||
);
|
||
assert!(
|
||
!shown.iter().any(|text| text == "Regenerate summary"),
|
||
"nothing to ask for twice: {shown:?}"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn reveal_markdown_asks_for_the_exported_file_and_reveal_files_for_the_recording() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "meeting-more");
|
||
assert!(
|
||
texts(&rt).iter().any(|text| text == "Reveal Markdown"),
|
||
"the meeting with a Markdown copy"
|
||
);
|
||
assert!(
|
||
texts(&rt).iter().any(|text| text == "Reveal files"),
|
||
"its recording folder stays reachable"
|
||
);
|
||
let markdown = menu_item(&rt, "meeting-actions", "Reveal Markdown");
|
||
tap(&mut rt, &markdown);
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Reveal(
|
||
crate::meeting::RevealTarget::Markdown(
|
||
"~/Documents/Hex Meetings/Arcade launch plan.md".into()
|
||
)
|
||
))]
|
||
);
|
||
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "meeting-more");
|
||
let files = menu_item(&rt, "meeting-actions", "Reveal files");
|
||
tap(&mut rt, &files);
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Reveal(
|
||
crate::meeting::RevealTarget::Folder(
|
||
"~/Library/Application Support/hex/meetings/preview-notes".into()
|
||
)
|
||
))]
|
||
);
|
||
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "meeting-preview-design");
|
||
tap(&mut rt, "meeting-more");
|
||
assert!(
|
||
!texts(&rt).iter().any(|text| text == "Reveal Markdown"),
|
||
"no Markdown copy to reveal"
|
||
);
|
||
assert!(
|
||
texts(&rt).iter().any(|text| text == "Reveal files"),
|
||
"the recording folder is always offered"
|
||
);
|
||
let files = menu_item(&rt, "meeting-actions", "Reveal files");
|
||
tap(&mut rt, &files);
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Meeting(MeetingRequest::Reveal(
|
||
crate::meeting::RevealTarget::Folder(
|
||
"~/Library/Application Support/hex/meetings/preview-design".into()
|
||
)
|
||
))]
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn copy_section_copies_one_chapter() {
|
||
let rt = runtime("meetings", true, PANE_SIZE);
|
||
assert!(rt.find("chapters").is_none(), "no chapters, no section");
|
||
|
||
let mut rt = runtime("meetings-chapters", true, PANE_SIZE);
|
||
assert!(texts(&rt).iter().any(|text| text == "Chapters"));
|
||
tap(&mut rt, "chapter1/copy-section");
|
||
let copied = rt.copy_request.as_deref().unwrap().to_owned();
|
||
assert!(
|
||
copied.starts_with("## Gravity well\n\nA pulse and gravity well"),
|
||
"{copied}"
|
||
);
|
||
assert!(copied.contains("Prototype it in WebGPU"), "{copied}");
|
||
assert!(!copied.contains("Roblox") && !copied.contains("build screen"));
|
||
}
|
||
|
||
#[test]
|
||
fn active_and_failed_meetings_show_their_state() {
|
||
let rt = runtime("meetings-recording", true, PANE_SIZE);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Live transcript"));
|
||
assert!(shown.iter().any(|text| text == "Listening…"));
|
||
assert!(
|
||
rt.find("meeting-rename").is_none(),
|
||
"no rename while recording"
|
||
);
|
||
let rt = runtime("meetings-failed", true, PANE_SIZE);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Recording failed."));
|
||
assert!(shown.iter().any(|text| text == "Recovered draft"));
|
||
}
|
||
|
||
#[test]
|
||
fn the_mac_first_run_asks_each_permission_then_practices() {
|
||
let mut rt = runtime("mac-onboarding-permissions", true, PANE_SIZE);
|
||
assert_eq!(rt.state.tour.as_ref().unwrap().flow.step(), Step::Setup);
|
||
assert!(
|
||
matches!(sent(&rt), [Request::ChooseModel { .. }]),
|
||
"the model downloads behind the permissions"
|
||
);
|
||
tap(&mut rt, "mic-pill-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(
|
||
PermissionAction::RequestMicrophone
|
||
)]
|
||
);
|
||
// macOS grants everything and the model lands: the practice follows.
|
||
use crate::desktop::onboarding::PermissionState::Ready;
|
||
rt.state.platform.permissions.microphone = Ready;
|
||
rt.state.platform.permissions.accessibility = Ready;
|
||
rt.state.picker.installed = Some(vec![rt.state.settings.transcription.model]);
|
||
refresh(&mut rt);
|
||
rt.update(|ui, _| onboarding_kit::live::fixture_resume(ui, Page::Try));
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.tour.as_ref().unwrap().flow.step(), Step::TryIt);
|
||
onboarding::input(&mut rt.state, Input::Dictation(Observation::Started));
|
||
onboarding::input(&mut rt.state, Input::Dictation(Observation::Pasted));
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
rt.state.tour.as_ref().unwrap().flow.view().practice,
|
||
Practice::Landed
|
||
);
|
||
// Done leaves the game at any point; Start using Hex closes onboarding.
|
||
tap(&mut rt, "done");
|
||
tap(&mut rt, "start-using-hex");
|
||
assert!(rt.state.tour.is_none());
|
||
assert!(rt.state.first_run.is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn a_listener_that_will_not_start_relaunches_once_then_asks_to_reopen() {
|
||
let mut rt = runtime("mac-onboarding-try", true, PANE_SIZE);
|
||
onboarding::input(
|
||
&mut rt.state,
|
||
Input::ListenerFailed {
|
||
relaunch_allowed: true,
|
||
},
|
||
);
|
||
assert_eq!(asked(&rt), [PlatformRequest::Relaunch]);
|
||
let mut rt = runtime("mac-onboarding-reopen", true, PANE_SIZE);
|
||
tap(&mut rt, "reopen-hex");
|
||
assert_eq!(asked(&rt), [PlatformRequest::Relaunch]);
|
||
}
|
||
|
||
#[test]
|
||
fn a_grant_waiting_for_a_restart_makes_setup_restart_hex() {
|
||
let mut rt = runtime("mac-onboarding-restart", true, PANE_SIZE);
|
||
assert_eq!(rt.state.tour.as_ref().unwrap().flow.step(), Step::Setup);
|
||
tap(&mut rt, "restart");
|
||
assert_eq!(asked(&rt), [PlatformRequest::Relaunch]);
|
||
}
|
||
|
||
#[test]
|
||
fn a_refused_microphone_points_to_system_settings() {
|
||
let mut rt = runtime("mac-onboarding-denied", true, PANE_SIZE);
|
||
let shown = texts(&rt);
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "Switch on Hex in System Settings")
|
||
);
|
||
tap(&mut rt, "mic-pill-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(PermissionAction::ShowGuide(
|
||
PermissionKind::Microphone
|
||
))]
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn windows_onboarding_asks_only_for_the_microphone_switch() {
|
||
let mut rt = runtime("windows-onboarding-microphone", true, PANE_SIZE);
|
||
let shown = texts(&rt);
|
||
assert!(
|
||
shown.iter().any(|text| text == "Let Hex hear you"),
|
||
"{shown:?}"
|
||
);
|
||
assert!(rt.find("ax-row").is_none(), "no Accessibility on Windows");
|
||
tap(&mut rt, "mic-pill-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(PermissionAction::ShowGuide(
|
||
PermissionKind::Microphone
|
||
))]
|
||
);
|
||
// Switched on in Settings: the practice follows.
|
||
rt.state.platform.permissions.microphone = crate::desktop::onboarding::PermissionState::Ready;
|
||
rt.state.picker.installed = Some(vec![rt.state.settings.transcription.model]);
|
||
refresh(&mut rt);
|
||
rt.update(|ui, _| onboarding_kit::live::fixture_resume(ui, Page::Try));
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.tour.as_ref().unwrap().flow.step(), Step::TryIt);
|
||
}
|
||
|
||
#[test]
|
||
fn stale_permissions_offer_fix_it_and_reset_entries_across_panes() {
|
||
// 1. Onboarding setup step.
|
||
let mut rt = runtime("mac-onboarding-stale", true, PANE_SIZE);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Still grey? Fix it"));
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "An older Hex entry can keep this off")
|
||
);
|
||
tap(&mut rt, "ax-pill-allow");
|
||
assert_eq!(
|
||
asked(&rt).last(),
|
||
Some(&PlatformRequest::Permission(
|
||
PermissionAction::ResetAndPrompt(PermissionKind::Accessibility)
|
||
))
|
||
);
|
||
assert!(!rt.state.platform.stale(PermissionKind::Accessibility));
|
||
|
||
// 2. General › Permissions needed.
|
||
let mut rt = runtime("mac-settings-permissions-stale", true, PANE_SIZE);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Still grey? Fix it"));
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "An older Hex entry can keep this off")
|
||
);
|
||
tap(&mut rt, "permission-accessibility-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(
|
||
PermissionAction::ResetAndPrompt(PermissionKind::Accessibility)
|
||
)]
|
||
);
|
||
assert!(!rt.state.platform.stale(PermissionKind::Accessibility));
|
||
|
||
// 3. Meetings › Settings › Screen & System Audio Recording.
|
||
let mut rt = runtime("meetings-settings", true, (980.0, 2400.0));
|
||
rt.state.platform.system_audio = false;
|
||
rt.state.platform.note_stale(PermissionKind::SystemAudio);
|
||
refresh(&mut rt);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Still grey? Fix it"));
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "An older Hex entry can keep this off")
|
||
);
|
||
tap(&mut rt, "meeting-system-audio-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(
|
||
PermissionAction::ResetAndPrompt(PermissionKind::SystemAudio)
|
||
)]
|
||
);
|
||
assert!(!rt.state.platform.stale(PermissionKind::SystemAudio));
|
||
}
|
||
|
||
#[test]
|
||
fn macos_27_3_stale_accessibility_restarts_once_then_resets() {
|
||
// The post-event preflight keeps its launch-time answer there, so the
|
||
// first stale row can only be settled by a restart: a reset would drop
|
||
// the grant.
|
||
let mut rt = runtime("mac-settings-permissions-stale", true, PANE_SIZE);
|
||
rt.state.platform.accessibility_split = true;
|
||
refresh(&mut rt);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Restart Hex"));
|
||
assert!(
|
||
shown
|
||
.iter()
|
||
.any(|text| text == "Turns on when Hex restarts")
|
||
);
|
||
assert!(!shown.iter().any(|text| text == "Still grey? Fix it"));
|
||
tap(&mut rt, "permission-accessibility-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(PermissionAction::Restart)]
|
||
);
|
||
|
||
// That restart was spent and the row still reads untrusted: the existing
|
||
// reset-and-prompt flow comes back instead of a second restart.
|
||
let mut rt = runtime("mac-settings-permissions-stale", true, PANE_SIZE);
|
||
rt.state.platform.accessibility_split = true;
|
||
rt.state.platform.accessibility_restart_done = true;
|
||
refresh(&mut rt);
|
||
let shown = texts(&rt);
|
||
assert!(shown.iter().any(|text| text == "Still grey? Fix it"));
|
||
assert!(!shown.iter().any(|text| text == "Restart Hex"));
|
||
tap(&mut rt, "permission-accessibility-allow");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::Permission(
|
||
PermissionAction::ResetAndPrompt(PermissionKind::Accessibility)
|
||
)]
|
||
);
|
||
|
||
// The reset clears the one-restart marker (host) and the person tries
|
||
// again, still untrusted: Restart Hex is offered once more.
|
||
rt.state.platform.accessibility_restart_done = false;
|
||
rt.state.platform.note_stale(PermissionKind::Accessibility);
|
||
refresh(&mut rt);
|
||
assert!(texts(&rt).iter().any(|text| text == "Restart Hex"));
|
||
assert!(!texts(&rt).iter().any(|text| text == "Still grey? Fix it"));
|
||
}
|
||
|
||
#[test]
|
||
fn visible_untrusted_permission_rows_are_reported_for_legacy_cleanup() {
|
||
let mut rt = runtime("mac-onboarding-permissions", true, PANE_SIZE);
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
rt.state.platform.permissions_shown,
|
||
[PermissionKind::Accessibility]
|
||
);
|
||
|
||
let mut rt = runtime("mac-settings-permissions", true, PANE_SIZE);
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
rt.state.platform.permissions_shown,
|
||
[PermissionKind::Accessibility]
|
||
);
|
||
|
||
let mut rt = runtime("meetings-settings", true, (980.0, 2400.0));
|
||
rt.state.platform.system_audio = false;
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
rt.state.platform.permissions_shown,
|
||
[PermissionKind::SystemAudio]
|
||
);
|
||
|
||
#[cfg(hex_capture)]
|
||
{
|
||
let mut rt = runtime("mac-scrawl-permission", true, PANE_SIZE);
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
rt.state.platform.permissions_shown,
|
||
[PermissionKind::ScreenRecording]
|
||
);
|
||
}
|
||
}
|
||
|
||
/// The macOS and Windows surfaces in both appearances.
|
||
#[test]
|
||
fn platform_goldens() {
|
||
let _goldens = Goldens::collect();
|
||
for dark in [true, false] {
|
||
check_golden("meetings-calendar", dark, (980.0, 1800.0));
|
||
check_golden("meetings-summary-model", dark, (980.0, 1800.0));
|
||
check_golden("meetings-summary-model-not-running", dark, (980.0, 1800.0));
|
||
for scene in [
|
||
"mac-settings",
|
||
"mac-input-source-models",
|
||
"meetings",
|
||
"meetings-settings",
|
||
"meetings-off",
|
||
"meetings-recording",
|
||
"mac-settings-permissions-stale",
|
||
"shortcut-mode",
|
||
"shortcut-mode-key",
|
||
"toggle-cancel",
|
||
"sound-sets",
|
||
"sound-sets-playing",
|
||
] {
|
||
check_golden(scene, dark, PANE_SIZE);
|
||
}
|
||
}
|
||
check_golden("shortcut-mode-chord", false, PANE_SIZE);
|
||
check_golden("portal-toggle-cancel", false, PANE_SIZE);
|
||
check_golden("mac-settings-permissions", true, PANE_SIZE);
|
||
check_golden("mac-settings-advanced", false, PANE_SIZE);
|
||
check_golden("mac-microphone-bluetooth", true, PANE_SIZE);
|
||
check_golden("meetings-calendar-denied", true, PANE_SIZE);
|
||
check_golden("windows-settings", false, GOLDEN_SIZE);
|
||
check_golden("meetings-actions", true, PANE_SIZE);
|
||
check_golden("meetings-delete", false, PANE_SIZE);
|
||
check_golden("meetings-rename", true, PANE_SIZE);
|
||
check_golden("meetings-empty", false, PANE_SIZE);
|
||
check_golden("meetings-calls", true, PANE_SIZE);
|
||
check_golden("meetings-calls", false, PANE_SIZE);
|
||
check_golden("meetings-calls-empty", true, PANE_SIZE);
|
||
}
|
||
|
||
#[test]
|
||
fn voice_filter_saves_the_mode_and_applies_the_tuning_live() {
|
||
use crate::audio::voice_filter::VoiceFilterMode;
|
||
let mut rt = runtime("mac-voice-filter", true, (980.0, 1300.0));
|
||
assert!(rt.find("fun-slider-strength").is_none());
|
||
open_advanced(&mut rt, Pane::VoiceFilter);
|
||
tap(&mut rt, "muted/apply");
|
||
assert_eq!(
|
||
rt.state.settings.experimental.hex_microphone_mode,
|
||
VoiceFilterMode::Muted
|
||
);
|
||
assert!(matches!(
|
||
asked(&rt),
|
||
[PlatformRequest::SetTuning(cfg)] if cfg.mode == VoiceFilterMode::Muted
|
||
));
|
||
assert!(
|
||
rt.find("fun-comfort-noise").is_some(),
|
||
"Muted offers comfort noise"
|
||
);
|
||
tap(&mut rt, "normal/apply");
|
||
assert!(
|
||
rt.find("fun-slider-strength").is_none(),
|
||
"Normal has no sliders"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn preview_each_effect_before_install_without_applying_it() {
|
||
use crate::audio::{hex_microphone::DemoPlaybackTrack, voice_filter::VoiceFilterMode};
|
||
let mut rt = runtime("mac-voice-filter-driver-missing", false, PANE_SIZE);
|
||
let tuning = rt.state.platform.tuning.clone();
|
||
let saves = saved(&rt);
|
||
assert!(asked(&rt).is_empty());
|
||
for mode in VoiceFilterMode::ALL {
|
||
tap(&mut rt, &format!("{}/play", mode.id()));
|
||
}
|
||
let expected: Vec<_> = VoiceFilterMode::ALL
|
||
.into_iter()
|
||
.map(|mode| {
|
||
PlatformRequest::HexMicrophoneDemo(platform::DemoRequest::Play(
|
||
DemoPlaybackTrack::Effect(mode),
|
||
))
|
||
})
|
||
.collect();
|
||
assert_eq!(asked(&rt), expected);
|
||
assert_eq!(rt.state.platform.tuning, tuning);
|
||
assert_eq!(saved(&rt), saves);
|
||
}
|
||
|
||
#[test]
|
||
fn voice_filter_setup_distinguishes_an_available_input_from_a_call() {
|
||
let mut rt = runtime("mac-voice-filter", true, PANE_SIZE);
|
||
rt.state
|
||
.platform
|
||
.hex_microphone
|
||
.as_mut()
|
||
.unwrap()
|
||
.mic_in_use = false;
|
||
refresh(&mut rt);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|s| s.contains("Select Hex Microphone"))
|
||
);
|
||
assert!(!texts(&rt).iter().any(|s| s.contains("Slack")));
|
||
let linux = runtime("voice-filter-unavailable", true, PANE_SIZE);
|
||
assert!(texts(&linux).iter().any(|s| s.contains("pw-cat")));
|
||
assert!(linux.find("install").is_none());
|
||
assert!(linux.find("robot/play").is_some());
|
||
}
|
||
|
||
#[test]
|
||
fn voice_filter_sliders_set_the_filter_from_the_pointer() {
|
||
let mut rt = runtime("mac-voice-filter", true, (980.0, 1300.0));
|
||
open_advanced(&mut rt, Pane::VoiceFilter);
|
||
let before = rt.state.platform.tuning.muffled_wall_hz;
|
||
let (x, y) = rt.find("fun-slider-wall/track").unwrap();
|
||
rt.pointer_down(x + 140.0, y);
|
||
rt.pointer_up(x + 140.0, y);
|
||
settle(&mut rt);
|
||
let after = rt.state.platform.tuning.muffled_wall_hz;
|
||
assert!(after > before && after >= 2900.0, "{before} -> {after}");
|
||
assert!(matches!(
|
||
asked(&rt).last(),
|
||
Some(PlatformRequest::SetTuning(_))
|
||
));
|
||
tap(&mut rt, "fun-reset-tuning");
|
||
assert_eq!(rt.state.platform.tuning.muffled_wall_hz, before);
|
||
}
|
||
|
||
#[test]
|
||
fn sound_volume_slider_sets_the_level_and_zero_turns_tones_off() {
|
||
let mut rt = runtime("sound-sets", true, (980.0, 1500.0));
|
||
let (x, y) = rt.find("sound-volume-slider/track").unwrap();
|
||
// A press between steps lands on one: the volume moves in 5% steps.
|
||
rt.pointer_down(x + 12.0, y);
|
||
rt.pointer_up(x + 12.0, y);
|
||
settle(&mut rt);
|
||
let volume = rt.state.settings.sound_effect_volume;
|
||
assert!(volume > 0.5 && volume < 0.7, "{volume}");
|
||
assert!(
|
||
((volume * 20.0).round() - volume * 20.0).abs() < 1e-4,
|
||
"{volume}"
|
||
);
|
||
|
||
rt.pointer_down(x + 99.0, y);
|
||
rt.pointer_up(x + 99.0, y);
|
||
settle(&mut rt);
|
||
assert!(rt.state.settings.sound_effects);
|
||
assert_eq!(rt.state.settings.sound_effect_volume, 1.0);
|
||
|
||
rt.pointer_down(x - 99.0, y);
|
||
rt.pointer_up(x - 99.0, y);
|
||
settle(&mut rt);
|
||
assert!(!rt.state.settings.sound_effects);
|
||
assert_eq!(
|
||
rt.state.settings.sound_effect_volume, 1.0,
|
||
"keeps the level"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn try_it_records_and_plays_through_the_host() {
|
||
use platform::DemoRequest;
|
||
let mut rt = runtime("mac-voice-filter", true, PANE_SIZE);
|
||
tap(&mut rt, "fun-demo-record");
|
||
tap(&mut rt, "robot/play");
|
||
tap(&mut rt, "fun-demo-source/segment1");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[
|
||
PlatformRequest::HexMicrophoneDemo(DemoRequest::Record),
|
||
PlatformRequest::HexMicrophoneDemo(DemoRequest::Play(
|
||
crate::audio::hex_microphone::DemoPlaybackTrack::Effect(
|
||
crate::audio::voice_filter::VoiceFilterMode::Robot
|
||
)
|
||
)),
|
||
PlatformRequest::HexMicrophoneDemo(DemoRequest::SelectSource(
|
||
crate::audio::hex_microphone::DemoSourceKind::Recording
|
||
)),
|
||
]
|
||
);
|
||
let mut rt = runtime("mac-voice-filter-muted", true, PANE_SIZE);
|
||
tap(&mut rt, "robot/play");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[PlatformRequest::HexMicrophoneDemo(
|
||
DemoRequest::StopPlayback
|
||
)]
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn hud_lab_and_activity_stay_out_of_the_window_sidebar() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
rt.state.platform.developer = true;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "nav-labs");
|
||
assert!(rt.find("nav-hud-lab").is_none());
|
||
assert!(rt.find("nav-activity").is_none());
|
||
assert!(
|
||
rt.find("nav-voice-filter").is_some(),
|
||
"Hex Microphone is on"
|
||
);
|
||
let rt = runtime("mac-hud-lab", true, PANE_SIZE);
|
||
assert!(rt.find("nav-hud-lab").is_none());
|
||
assert!(rt.find("nav-activity").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn voice_filter_shows_only_while_its_labs_toggle_is_on() {
|
||
let mut rt = runtime("mac-settings", true, PANE_SIZE);
|
||
rt.state.settings.experimental.hex_microphone = false;
|
||
rt.state.platform.hex_microphone = None;
|
||
refresh(&mut rt);
|
||
assert!(rt.find("nav-voice-filter").is_none());
|
||
open_labs(&mut rt);
|
||
tap(&mut rt, "lab-voice-filter");
|
||
assert!(rt.state.settings.experimental.hex_microphone);
|
||
assert!(
|
||
rt.find("nav-voice-filter").is_some(),
|
||
"a top-level sidebar item"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn hud_lab_tunes_dot_scope() {
|
||
let mut rt = runtime("mac-hud-lab", true, PANE_SIZE);
|
||
assert!(rt.find("dot-glow").is_some());
|
||
rt.state.platform.hud.tuning = crate::rune_hud::dot_scope::Tuning {
|
||
glow: 2.0,
|
||
..Default::default()
|
||
};
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "hud-demo/segment2");
|
||
let Some(PlatformRequest::ConfigureHud(lab)) = asked(&rt).last().cloned() else {
|
||
panic!("{:?}", asked(&rt));
|
||
};
|
||
assert_eq!(lab.tuning.glow, 2.0);
|
||
assert_eq!(lab.demo, platform::HudDemo::Processing);
|
||
tap(&mut rt, "dot-scope-copy");
|
||
assert!(
|
||
rt.copy_request
|
||
.as_deref()
|
||
.is_some_and(|json| json.contains("\"glow\": 2.0"))
|
||
);
|
||
assert!(rt.state.hud_copied);
|
||
tap(&mut rt, "dot-scope-save");
|
||
assert!(matches!(
|
||
asked(&rt).last(),
|
||
Some(PlatformRequest::SaveDotScope(tuning)) if tuning.glow == 2.0
|
||
));
|
||
assert!(rt.state.hud_saved);
|
||
tap(&mut rt, "dot-scope-reset");
|
||
assert_eq!(
|
||
rt.state.platform.hud.tuning,
|
||
crate::rune_hud::dot_scope::Tuning::default()
|
||
);
|
||
assert!(!rt.state.hud_saved);
|
||
}
|
||
|
||
#[test]
|
||
fn hud_lab_picks_dot_scope_processing_placement_and_level() {
|
||
use crate::rune_hud::dot_scope::{Placement, Processing};
|
||
let mut rt = runtime("mac-hud-lab", true, PANE_SIZE);
|
||
tap(&mut rt, "dot-processing/segments/segment2");
|
||
tap(&mut rt, "dot-placement/segments/segment2");
|
||
tap(&mut rt, "dot-auto-level");
|
||
tap(&mut rt, "dot-pretend-notch");
|
||
let Some(PlatformRequest::TuneHud(lab)) = asked(&rt).last().cloned() else {
|
||
panic!("{:?}", asked(&rt));
|
||
};
|
||
let tuning = lab.tuning;
|
||
assert_eq!(tuning.processing, Processing::Pulse);
|
||
assert_eq!(tuning.placement, Placement::Notch);
|
||
assert!(!tuning.auto_level && tuning.pretend_notch);
|
||
assert!(rt.find("dot-noise-floor").is_some());
|
||
}
|
||
|
||
#[test]
|
||
fn labs_lists_every_toggle_off_by_default() {
|
||
let mut rt = runtime("mac-production", true, (980.0, 2200.0));
|
||
rt.state.settings.experimental.hex_microphone = false;
|
||
rt.state.platform.hex_microphone = None;
|
||
refresh(&mut rt);
|
||
// On a Mac, Meetings stays in the sidebar while off, to offer itself.
|
||
assert!(
|
||
rt.find("nav-meetings").is_some(),
|
||
"Meetings left the sidebar"
|
||
);
|
||
for hidden in [
|
||
"nav-annotate",
|
||
"nav-voice-filter",
|
||
"nav-playground",
|
||
"nav-hud-lab",
|
||
"nav-activity",
|
||
] {
|
||
assert!(rt.find(hidden).is_none(), "the sidebar showed {hidden}");
|
||
}
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("send-feedback").is_some());
|
||
assert!(rt.find("restart-onboarding").is_some());
|
||
let settings = &rt.state.settings;
|
||
for (row, on) in [
|
||
("lab-meetings", settings.meetings.enabled),
|
||
("lab-voice-filter", settings.experimental.hex_microphone),
|
||
("lab-playground", settings.labs.playground),
|
||
("lab-live-text", settings.labs.live_text),
|
||
("lab-live-chapters", settings.labs.live_chapters),
|
||
("lab-vocabulary-files", settings.labs.vocabulary_files),
|
||
("lab-screen-vocabulary", settings.labs.screen_vocabulary),
|
||
(
|
||
"lab-learn-from-corrections",
|
||
settings.labs.learn_from_corrections,
|
||
),
|
||
("lab-cursor-context", settings.labs.cursor_context),
|
||
("lab-return-to-app", settings.labs.return_to_app),
|
||
("lab-speakers-only", settings.labs.speakers_only),
|
||
(
|
||
"lab-second-dictation-shortcut",
|
||
settings.labs.second_dictation_shortcut,
|
||
),
|
||
] {
|
||
assert!(rt.find(row).is_some(), "Labs lacks {row}");
|
||
assert!(!on, "{row} is on");
|
||
}
|
||
assert!(rt.find("lab-terminal-paste").is_none(), "Windows only");
|
||
|
||
tap(&mut rt, "lab-meetings");
|
||
assert!(rt.state.settings.meetings.enabled);
|
||
assert!(
|
||
rt.find("nav-meetings").is_some(),
|
||
"Meetings joins the main sidebar"
|
||
);
|
||
tap(&mut rt, "lab-live-text");
|
||
assert!(rt.state.settings.labs.live_text);
|
||
tap(&mut rt, "lab-vocabulary-files");
|
||
assert!(rt.state.settings.labs.vocabulary_files);
|
||
tap(&mut rt, "lab-cursor-context");
|
||
assert!(rt.state.settings.labs.cursor_context);
|
||
tap(&mut rt, "lab-meetings");
|
||
assert!(
|
||
rt.find("nav-meetings").is_some(),
|
||
"a Mac keeps it while off, to offer itself"
|
||
);
|
||
|
||
// Windows lists Terminal paste in Labs, not General. Labs is tall enough
|
||
// that its last row needs the macOS half's height to be on screen.
|
||
let mut rt = runtime("windows-settings", true, (980.0, 2200.0));
|
||
assert!(rt.find("terminal-paste").is_none());
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-return-to-app").is_none(), "macOS only");
|
||
assert!(rt.find("lab-screen-vocabulary").is_none(), "macOS only");
|
||
assert!(
|
||
rt.find("lab-learn-from-corrections").is_none(),
|
||
"macOS only"
|
||
);
|
||
assert!(rt.find("lab-cursor-context").is_none(), "macOS only");
|
||
assert!(
|
||
rt.find("lab-second-dictation-shortcut").is_some(),
|
||
"the second dictation shortcut runs on Windows too"
|
||
);
|
||
tap(&mut rt, "lab-terminal-paste");
|
||
assert!(rt.state.settings.paste_with_shift);
|
||
assert!(
|
||
rt.find("lab-meetings").is_some(),
|
||
"Meetings runs on Windows too"
|
||
);
|
||
|
||
// Linux lists the second dictation shortcut as well.
|
||
let mut rt = runtime("linux-labs", true, (980.0, 2000.0));
|
||
unfold_labs(&mut rt);
|
||
assert!(
|
||
rt.find("lab-second-dictation-shortcut").is_some(),
|
||
"the second dictation shortcut runs on Linux too"
|
||
);
|
||
assert!(
|
||
rt.find("lab-screen-vocabulary").is_none(),
|
||
"screen vocabulary is macOS only"
|
||
);
|
||
assert!(
|
||
rt.find("lab-cursor-context").is_none(),
|
||
"cursor context is macOS only"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn a_labs_link_shows_its_labs_group_and_leaves_it_off() {
|
||
use super::super::labs::LabsLink;
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2000.0));
|
||
let feature = Feature::VocabularyFiles;
|
||
assert!(!feature.on(&rt.state.settings));
|
||
let link = LabsLink {
|
||
lab: Some(feature.name().into()),
|
||
..LabsLink::default()
|
||
};
|
||
rt.update(|ui, tx| super::super::labs::reveal(ui, &link, tx));
|
||
settle(&mut rt);
|
||
assert!(rt.state.labs_open);
|
||
assert_eq!(rt.state.lab_store.group, Some(feature.group()));
|
||
assert!(rt.find("lab-card-vocabulary-files").is_some());
|
||
assert!(!feature.on(&rt.state.settings), "a link never flips it");
|
||
}
|
||
|
||
#[test]
|
||
fn a_labs_link_keeps_the_category_it_names() {
|
||
use super::super::labs::LabsLink;
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2000.0));
|
||
let link = LabsLink {
|
||
lab: Some(crate::labs::Feature::VocabularyFiles.name().into()),
|
||
category: Some("shortcuts".into()),
|
||
..LabsLink::default()
|
||
};
|
||
rt.update(|ui, tx| super::super::labs::reveal(ui, &link, tx));
|
||
settle(&mut rt);
|
||
assert_eq!(
|
||
rt.state.lab_store.group,
|
||
Some(crate::labs::Group::Shortcuts)
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn a_labs_link_to_an_unknown_name_opens_labs_on_every_group() {
|
||
use super::super::labs::LabsLink;
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2000.0));
|
||
let link = LabsLink {
|
||
lab: Some("no-such-lab".into()),
|
||
category: Some("no-such-category".into()),
|
||
..LabsLink::default()
|
||
};
|
||
rt.update(|ui, tx| super::super::labs::reveal(ui, &link, tx));
|
||
settle(&mut rt);
|
||
assert!(rt.state.labs_open);
|
||
assert!(rt.state.lab_store.group.is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn a_labs_link_sets_the_stores_tab_chip_and_search() {
|
||
use super::super::labs::LabsLink;
|
||
use super::super::labs::Tab;
|
||
let mut rt = runtime("mac-settings", true, (980.0, 2000.0));
|
||
let link = LabsLink {
|
||
turned_on: true,
|
||
category: Some("shortcuts".into()),
|
||
search: Some("tap".into()),
|
||
..LabsLink::default()
|
||
};
|
||
rt.update(|ui, tx| super::super::labs::reveal(ui, &link, tx));
|
||
settle(&mut rt);
|
||
let store = &rt.state.lab_store;
|
||
assert_eq!(store.tab, Tab::On);
|
||
assert_eq!(store.group, Some(crate::labs::Group::Shortcuts));
|
||
assert_eq!(store.search.text, "tap");
|
||
}
|
||
|
||
#[test]
|
||
fn voice_prompt_shows_its_phrase_on_its_card_while_on() {
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(Feature::VoicePrompt.group()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("voice-prompt-phrase").is_none(), "hidden while off");
|
||
tap(&mut rt, "lab-voice-prompt");
|
||
assert!(rt.state.settings.labs.voice_prompt);
|
||
assert!(rt.find("voice-prompt-phrase").is_some());
|
||
assert_eq!(
|
||
rt.state.lab_store.phrase.text,
|
||
crate::dictation::voice_prompt::DEFAULT_PHRASE,
|
||
"the field starts at the saved phrase"
|
||
);
|
||
let (field, _) = rt
|
||
.presented("voice-prompt-phrase")
|
||
.expect("the phrase field");
|
||
let (card, _) = rt.presented("lab-card-voice-prompt").expect("its card");
|
||
assert!(
|
||
field[0] + field[2] <= card[0] + card[2],
|
||
"the phrase field stays inside its card"
|
||
);
|
||
|
||
// A draft that fails validation stays in the field, says why, and leaves
|
||
// the saved phrase working.
|
||
let saved = rt.state.settings.labs.voice_prompt_phrase.clone();
|
||
rt.update(|ui, _| ui.lab_store.phrase = rune::TextEdit::new("rewrite".to_string()));
|
||
rt.state.flush_drafts();
|
||
assert_eq!(rt.state.settings.labs.voice_prompt_phrase, saved);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("voice-prompt-phrase-error").is_some());
|
||
|
||
// A valid draft saves.
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.phrase = rune::TextEdit::new("say it better".to_string());
|
||
});
|
||
rt.state.flush_drafts();
|
||
assert_eq!(rt.state.settings.labs.voice_prompt_phrase, "say it better");
|
||
refresh(&mut rt);
|
||
assert!(rt.find("voice-prompt-phrase-error").is_none());
|
||
|
||
// A phrase saved elsewhere updates the field.
|
||
let mut external = rt.state.settings.clone();
|
||
external.labs.voice_prompt_phrase = "say it clearer".to_string();
|
||
assert!(rt.state.adopt(external));
|
||
refresh(&mut rt);
|
||
assert_eq!(rt.state.lab_store.phrase.text, "say it clearer");
|
||
|
||
// An invalid draft is dropped when another writer turns the lab off and
|
||
// back on, so it can't survive the toggle.
|
||
rt.update(|ui, _| ui.lab_store.phrase = rune::TextEdit::new("rewrite".to_string()));
|
||
let mut off = rt.state.settings.clone();
|
||
off.labs.voice_prompt = false;
|
||
assert!(rt.state.adopt(off.clone()));
|
||
let mut on = off;
|
||
on.labs.voice_prompt = true;
|
||
assert!(rt.state.adopt(on));
|
||
refresh(&mut rt);
|
||
assert_eq!(rt.state.lab_store.phrase.text, "say it clearer");
|
||
assert!(rt.find("voice-prompt-phrase-error").is_none());
|
||
|
||
// The field leaves with its lab.
|
||
tap(&mut rt, "lab-voice-prompt");
|
||
assert!(!rt.state.settings.labs.voice_prompt);
|
||
assert!(rt.find("voice-prompt-phrase").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn stop_phrase_shows_its_phrase_on_its_card_while_on() {
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(Feature::StopPhrase.group()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("stop-phrase-text").is_none(), "hidden while off");
|
||
tap(&mut rt, "lab-stop-phrase");
|
||
assert!(rt.state.settings.labs.stop_phrase);
|
||
assert!(rt.find("stop-phrase-text").is_some());
|
||
assert_eq!(
|
||
rt.state.lab_store.stop_phrase.text,
|
||
crate::dictation::stop_phrase::DEFAULT_PHRASE,
|
||
"the field starts at the saved phrase"
|
||
);
|
||
|
||
// A draft that fails validation stays in the field, says why, and leaves
|
||
// both saved phrases alone.
|
||
let voice_prompt = rt.state.settings.labs.voice_prompt_phrase.clone();
|
||
rt.update(|ui, _| ui.lab_store.stop_phrase = rune::TextEdit::new("stop".to_string()));
|
||
rt.state.flush_drafts();
|
||
assert_eq!(
|
||
rt.state.settings.labs.stop_phrase_text,
|
||
crate::dictation::stop_phrase::DEFAULT_PHRASE
|
||
);
|
||
assert_eq!(
|
||
rt.state.settings.labs.voice_prompt_phrase, voice_prompt,
|
||
"Rewrite by voice's phrase is its own"
|
||
);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("stop-phrase-text-error").is_some());
|
||
|
||
// A valid draft saves.
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.stop_phrase = rune::TextEdit::new("that's all".to_string());
|
||
});
|
||
rt.state.flush_drafts();
|
||
assert_eq!(rt.state.settings.labs.stop_phrase_text, "that's all");
|
||
refresh(&mut rt);
|
||
assert!(rt.find("stop-phrase-text-error").is_none());
|
||
|
||
// A phrase saved elsewhere updates the field.
|
||
let mut external = rt.state.settings.clone();
|
||
external.labs.stop_phrase_text = "end dictation".to_string();
|
||
assert!(rt.state.adopt(external));
|
||
refresh(&mut rt);
|
||
assert_eq!(rt.state.lab_store.stop_phrase.text, "end dictation");
|
||
|
||
// The field leaves with its lab.
|
||
tap(&mut rt, "lab-stop-phrase");
|
||
assert!(!rt.state.settings.labs.stop_phrase);
|
||
assert!(rt.find("stop-phrase-text").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn clipboard_phrase_shows_its_phrase_on_its_card_while_on() {
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(Feature::ClipboardPhrase.group()));
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("clipboard-phrase-text").is_none(),
|
||
"hidden while off"
|
||
);
|
||
tap(&mut rt, "lab-clipboard-phrase");
|
||
assert!(rt.state.settings.labs.clipboard_phrase);
|
||
assert!(rt.find("clipboard-phrase-text").is_some());
|
||
assert_eq!(
|
||
rt.state.lab_store.clipboard_phrase.text,
|
||
crate::dictation::clipboard_phrase::DEFAULT_PHRASE,
|
||
"the field starts at the saved phrase"
|
||
);
|
||
|
||
// A draft that fails validation stays in the field, says why, and leaves
|
||
// the saved phrase working.
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.clipboard_phrase = rune::TextEdit::new("clipboard".to_string());
|
||
});
|
||
rt.state.flush_drafts();
|
||
assert_eq!(
|
||
rt.state.settings.labs.clipboard_phrase_text,
|
||
crate::dictation::clipboard_phrase::DEFAULT_PHRASE
|
||
);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("clipboard-phrase-text-error").is_some());
|
||
|
||
// A valid draft saves.
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.clipboard_phrase = rune::TextEdit::new("what I copied".to_string());
|
||
});
|
||
rt.state.flush_drafts();
|
||
assert_eq!(
|
||
rt.state.settings.labs.clipboard_phrase_text,
|
||
"what I copied"
|
||
);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("clipboard-phrase-text-error").is_none());
|
||
|
||
// A phrase saved elsewhere updates the field.
|
||
let mut external = rt.state.settings.clone();
|
||
external.labs.clipboard_phrase_text = "the clipboard".to_string();
|
||
assert!(rt.state.adopt(external));
|
||
refresh(&mut rt);
|
||
assert_eq!(rt.state.lab_store.clipboard_phrase.text, "the clipboard");
|
||
|
||
// The field leaves with its lab.
|
||
tap(&mut rt, "lab-clipboard-phrase");
|
||
assert!(!rt.state.settings.labs.clipboard_phrase);
|
||
assert!(rt.find("clipboard-phrase-text").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn signature_shows_its_line_on_its_card_while_on() {
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(Feature::Signature.group()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("signature-text").is_none(), "hidden while off");
|
||
tap(&mut rt, "lab-signature");
|
||
assert!(rt.state.settings.labs.signature);
|
||
assert!(rt.find("signature-text").is_some());
|
||
assert_eq!(
|
||
rt.state.lab_store.signature.text,
|
||
crate::dictation::signature::DEFAULT_TEXT,
|
||
"the field starts at the saved line"
|
||
);
|
||
|
||
// A draft that fails validation stays in the field, says why, and leaves
|
||
// the saved line working.
|
||
let saved = rt.state.settings.labs.signature_text.clone();
|
||
let too_long = "x".repeat(crate::dictation::signature::MAX_CHARS + 1);
|
||
rt.update(|ui, _| ui.lab_store.signature = rune::TextEdit::new(too_long));
|
||
rt.state.flush_drafts();
|
||
assert_eq!(rt.state.settings.labs.signature_text, saved);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("signature-text-error").is_some());
|
||
|
||
// A valid draft saves, and an empty one saves too (it appends nothing).
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.signature = rune::TextEdit::new("Dax, from Hex".to_string());
|
||
});
|
||
rt.state.flush_drafts();
|
||
assert_eq!(rt.state.settings.labs.signature_text, "Dax, from Hex");
|
||
refresh(&mut rt);
|
||
assert!(rt.find("signature-text-error").is_none());
|
||
rt.update(|ui, _| ui.lab_store.signature = rune::TextEdit::new(String::new()));
|
||
rt.state.flush_drafts();
|
||
assert!(rt.state.settings.labs.signature_text.is_empty());
|
||
|
||
// A line saved elsewhere updates the field.
|
||
let mut external = rt.state.settings.clone();
|
||
external.labs.signature_text = "Sent from Dax".to_string();
|
||
assert!(rt.state.adopt(external));
|
||
refresh(&mut rt);
|
||
assert_eq!(rt.state.lab_store.signature.text, "Sent from Dax");
|
||
|
||
// The field leaves with its lab.
|
||
tap(&mut rt, "lab-signature");
|
||
assert!(!rt.state.settings.labs.signature);
|
||
assert!(rt.find("signature-text").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn a_labs_card_shows_its_description_and_its_switch_turns_it_on() {
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-labs", true, (980.0, 2000.0));
|
||
unfold_labs(&mut rt);
|
||
let feature = Feature::ReturnToApp;
|
||
assert!(rt.find("lab-card-return-to-app").is_some());
|
||
tap(&mut rt, "lab-card-return-to-app");
|
||
assert!(
|
||
!feature.on(&rt.state.settings),
|
||
"pressing a card flips nothing"
|
||
);
|
||
tap(&mut rt, "lab-return-to-app");
|
||
assert!(
|
||
feature.on(&rt.state.settings),
|
||
"the card's switch turns it on"
|
||
);
|
||
tap(&mut rt, "lab-return-to-app");
|
||
assert!(!feature.on(&rt.state.settings), "and off");
|
||
}
|
||
|
||
#[test]
|
||
fn unload_when_idle_shows_its_minutes_on_its_card_while_on() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(crate::labs::Feature::UnloadIdle.group()));
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("unload-idle-minutes-trigger").is_none(),
|
||
"hidden while off"
|
||
);
|
||
tap(&mut rt, "lab-unload-idle");
|
||
assert!(rt.state.settings.labs.unload_idle);
|
||
assert!(rt.find("unload-idle-minutes-trigger").is_some());
|
||
}
|
||
|
||
/// At the window's smallest size, in a longer language, the minutes stay
|
||
/// inside their card and the last choice is still reachable.
|
||
#[test]
|
||
fn unload_after_fits_its_card_in_a_small_translated_window() {
|
||
let mut rt = runtime("mac-labs", true, (860.0, 560.0));
|
||
crate::desktop::i18n::apply(Some("de"));
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.group = Some(crate::labs::Feature::UnloadIdle.group());
|
||
ui.settings.labs.unload_idle = true;
|
||
});
|
||
settle(&mut rt);
|
||
let (control, _) = rt
|
||
.presented("unload-idle-minutes-trigger")
|
||
.expect("the minutes' control");
|
||
let (card, _) = rt.presented("lab-card-unload-idle").expect("its card");
|
||
assert!(
|
||
control[0] >= card[0] && control[0] + control[2] <= card[0] + card[2],
|
||
"the minutes' control stays inside its card: {control:?} in {card:?}"
|
||
);
|
||
tap(&mut rt, "unload-idle-minutes-trigger");
|
||
tap(&mut rt, "option3");
|
||
assert_eq!(
|
||
rt.state.settings.labs.unload_idle_minutes,
|
||
crate::app_settings::UNLOAD_IDLE_MINUTES[3]
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn keep_microphone_open_shows_its_window_on_its_card_while_on() {
|
||
use crate::labs::Feature;
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(Feature::KeepMicrophoneOpen.group()));
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("keep-microphone-open-seconds-trigger").is_none(),
|
||
"hidden while off"
|
||
);
|
||
tap(&mut rt, "lab-keep-microphone-open");
|
||
assert!(rt.state.settings.labs.keep_microphone_open);
|
||
let (control, _) = rt
|
||
.presented("keep-microphone-open-seconds-trigger")
|
||
.expect("the window's control");
|
||
let (card, _) = rt
|
||
.presented("lab-card-keep-microphone-open")
|
||
.expect("its card");
|
||
assert!(
|
||
control[0] + control[2] <= card[0] + card[2],
|
||
"the window's control stays inside its card"
|
||
);
|
||
assert_eq!(
|
||
rt.state.settings.labs.keep_microphone_open_seconds,
|
||
crate::app_settings::LabsSettings::DEFAULT_KEEP_MICROPHONE_OPEN_SECONDS
|
||
);
|
||
// The last choice is reachable from the menu.
|
||
tap(&mut rt, "keep-microphone-open-seconds-trigger");
|
||
tap(&mut rt, "option4");
|
||
assert_eq!(
|
||
rt.state.settings.labs.keep_microphone_open_seconds,
|
||
crate::app_settings::KEEP_MICROPHONE_OPEN_SECONDS[4]
|
||
);
|
||
tap(&mut rt, "lab-keep-microphone-open");
|
||
assert!(!rt.state.settings.labs.keep_microphone_open);
|
||
assert!(rt.find("keep-microphone-open-seconds-trigger").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn caps_lock_light_shows_its_choices_on_its_card_while_on() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(crate::labs::Feature::CapsLockDictation.group()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("caps-lock-light").is_none(), "hidden while off");
|
||
assert_eq!(
|
||
rt.state.settings.labs.caps_lock_light,
|
||
crate::app_settings::CapsLockLight::Steady
|
||
);
|
||
tap(&mut rt, "lab-caps-lock-dictation");
|
||
assert!(rt.state.settings.labs.caps_lock_dictation);
|
||
assert!(rt.find("caps-lock-light").is_some());
|
||
}
|
||
|
||
#[test]
|
||
fn dictation_style_shows_its_choices_on_its_card_while_on() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| {
|
||
ui.lab_store.group = Some(crate::labs::Feature::DictationStyle.group());
|
||
ui.lab_store.search = rune::TextEdit::new("Dictation style".to_owned());
|
||
});
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("dictation-style-choice-trigger").is_none(),
|
||
"hidden while off"
|
||
);
|
||
assert_eq!(
|
||
rt.state.settings.labs.dictation_style_choice,
|
||
crate::app_settings::DictationStyle::Polished
|
||
);
|
||
tap(&mut rt, "lab-dictation-style");
|
||
assert!(rt.state.settings.labs.dictation_style);
|
||
assert!(rt.find("dictation-style-choice-trigger").is_some());
|
||
tap(&mut rt, "dictation-style-choice-trigger");
|
||
tap(&mut rt, "option2");
|
||
assert_eq!(
|
||
rt.state.settings.labs.dictation_style_choice,
|
||
crate::app_settings::DictationStyle::Notes
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn output_shows_the_style_row_while_its_lab_is_on() {
|
||
let mut rt = runtime("output", true, (980.0, 4000.0));
|
||
settle(&mut rt);
|
||
assert!(rt.find("dictation-style-row").is_none(), "hidden while off");
|
||
rt.update(|ui, _| ui.settings.labs.dictation_style = true);
|
||
refresh(&mut rt);
|
||
assert!(rt.find("dictation-style-row").is_some());
|
||
assert_eq!(
|
||
rt.state.settings.labs.dictation_style_choice,
|
||
crate::app_settings::DictationStyle::Polished
|
||
);
|
||
tap(&mut rt, "dictation-style-choice-field-trigger");
|
||
tap(&mut rt, "dictation-style-choice-item3");
|
||
assert_eq!(
|
||
rt.state.settings.labs.dictation_style_choice,
|
||
crate::app_settings::DictationStyle::Verbatim
|
||
);
|
||
}
|
||
|
||
/// The style menu shows every name whole. Each hint sits on its own line
|
||
/// under it, so a long hint can truncate but never squeezes the name.
|
||
#[test]
|
||
fn the_style_menu_shows_every_name_whole_beside_its_hint() {
|
||
let mut rt = runtime("output-style", true, (980.0, 760.0));
|
||
settle(&mut rt);
|
||
tap(&mut rt, "dictation-style-choice-field-trigger");
|
||
let names = ["Polished", "Casual", "Notes", "Verbatim"];
|
||
let mut widths = Vec::new();
|
||
for (index, name) in names.iter().enumerate() {
|
||
let label = element(
|
||
&rt,
|
||
&format!("dictation-style-choice-item{index}/content/text/label"),
|
||
);
|
||
assert_eq!(label.text.as_deref(), Some(*name));
|
||
let hint = element(
|
||
&rt,
|
||
&format!("dictation-style-choice-item{index}/content/text/description"),
|
||
);
|
||
assert!(hint.text.is_some());
|
||
assert_eq!(hint.rect[2], label.rect[2], "the hint shares the column");
|
||
widths.push(label.rect[2]);
|
||
}
|
||
assert!(
|
||
widths
|
||
.windows(2)
|
||
.all(|pair| (pair[0] - pair[1]).abs() < 0.5),
|
||
"the names share one column: {widths:?}"
|
||
);
|
||
assert!(
|
||
widths[0] >= 100.0,
|
||
"the name column fits the longest name: {widths:?}"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn appearance_shows_its_theme_on_its_card_while_on() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| ui.lab_store.group = Some(crate::labs::Feature::Appearance.group()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("appearance-theme").is_none(), "hidden while off");
|
||
assert_eq!(
|
||
rt.state.settings.labs.appearance_theme,
|
||
crate::app_settings::AppearanceTheme::System
|
||
);
|
||
tap(&mut rt, "lab-appearance");
|
||
assert!(rt.state.settings.labs.appearance);
|
||
assert!(rt.find("appearance-theme").is_some());
|
||
tap(&mut rt, "segment2");
|
||
assert_eq!(
|
||
rt.state.settings.labs.appearance_theme,
|
||
crate::app_settings::AppearanceTheme::Dark
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn the_main_window_paints_the_forced_appearance_not_the_os() {
|
||
use crate::app_settings::AppearanceTheme;
|
||
let mut rt = runtime("mac-settings", false, (980.0, 4000.0));
|
||
let fill = |rt: &Runtime<Ui>| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|element| element.key.as_deref() == Some("window"))
|
||
.expect("the window paints its background")
|
||
.fill
|
||
};
|
||
assert_eq!(fill(&rt), rune_theme_opencode::kit(false).c.bg_deep);
|
||
rt.update(|ui, _| {
|
||
ui.settings.labs.appearance = true;
|
||
ui.settings.labs.appearance_theme = AppearanceTheme::Dark;
|
||
});
|
||
refresh(&mut rt);
|
||
assert_eq!(
|
||
fill(&rt),
|
||
rune_theme_opencode::kit(true).c.bg_deep,
|
||
"the OS is light, so only the lab's Dark paints the window dark"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn the_labs_store_filters_by_tab_chip_and_search() {
|
||
let mut rt = runtime("mac-labs-on", true, (980.0, 2000.0));
|
||
assert!(rt.find("lab-card-live-text").is_some());
|
||
assert!(
|
||
rt.find("lab-card-vocabulary-biasing").is_none(),
|
||
"Turned on lists only what's on"
|
||
);
|
||
rt.update(|ui, _| ui.lab_store.tab = super::super::labs::Tab::Discover);
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("featured").is_some(),
|
||
"Discover leads with what's new"
|
||
);
|
||
tap(&mut rt, "chip-shortcuts");
|
||
assert!(rt.find("featured").is_none());
|
||
assert!(rt.find("lab-card-mouse-shortcuts").is_some());
|
||
assert!(rt.find("lab-card-live-text").is_none());
|
||
tap(&mut rt, "chip-all");
|
||
rt.update(|ui, _| ui.lab_store.search = rune::TextEdit::new("no such words".to_string()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("empty-copy").is_some());
|
||
assert!(rt.find("lab-card-live-text").is_none());
|
||
}
|
||
|
||
/// Turning a lab on grows the Turned on tab's count. The tabs must keep their
|
||
/// size and place anyway: they sit at the header's end, so a tab that widened
|
||
/// would slide the whole control left, out from under the pointer that just
|
||
/// pressed a switch. Digits differ in width, so a two-digit count needs the
|
||
/// room of the widest one.
|
||
#[test]
|
||
fn the_labs_tabs_keep_their_place_as_the_count_grows() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
let tabs = |rt: &Runtime<Ui>| element(rt, "labs-tab").rect;
|
||
let count = |rt: &Runtime<Ui>| {
|
||
let label = element(rt, "labs-tab/segment1/label").text.clone().unwrap();
|
||
label
|
||
.chars()
|
||
.rev()
|
||
.take_while(char::is_ascii_digit)
|
||
.collect::<String>()
|
||
.chars()
|
||
.rev()
|
||
.collect::<String>()
|
||
.parse::<usize>()
|
||
.unwrap()
|
||
};
|
||
let place = tabs(&rt);
|
||
let mut counts = vec![count(&rt)];
|
||
for feature in crate::labs::Feature::ALL {
|
||
if counts.last().copied().unwrap_or_default() >= 12 {
|
||
break;
|
||
}
|
||
rt.update(|ui, _| feature.set(&mut ui.settings, true));
|
||
refresh(&mut rt);
|
||
let now = count(&rt);
|
||
if counts.last() == Some(&now) {
|
||
continue; // a lab this build does not list
|
||
}
|
||
counts.push(now);
|
||
assert_eq!(tabs(&rt), place, "the count going to {now} moved the tabs");
|
||
}
|
||
assert!(
|
||
counts.iter().any(|count| *count >= 12),
|
||
"the fixture turns twelve labs on: {counts:?}"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn the_labs_search_clear_button_empties_the_field_and_brings_every_card_back() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
unfold_labs(&mut rt);
|
||
rt.update(|ui, _| ui.lab_store.search = rune::TextEdit::new("live text".to_string()));
|
||
settle(&mut rt);
|
||
assert!(rt.find("lab-card-live-text").is_some());
|
||
assert!(
|
||
rt.find("lab-card-mouse-shortcuts").is_none(),
|
||
"the search filters"
|
||
);
|
||
tap(&mut rt, "labs-search/action");
|
||
assert!(
|
||
rt.state.lab_store.search.text.is_empty(),
|
||
"the clear button empties the field"
|
||
);
|
||
assert!(
|
||
rt.find("lab-card-mouse-shortcuts").is_some(),
|
||
"and the filtered-out cards come back"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn a_lone_lab_card_keeps_half_the_row() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
unfold_labs(&mut rt);
|
||
let mut width = None;
|
||
let chips = [
|
||
"chip-all",
|
||
"chip-dictation",
|
||
"chip-output",
|
||
"chip-history",
|
||
"chip-meetings",
|
||
"chip-annotate",
|
||
"chip-shortcuts",
|
||
"chip-models",
|
||
];
|
||
for chip in chips {
|
||
if rt.find(chip).is_none() {
|
||
continue;
|
||
}
|
||
tap(&mut rt, chip);
|
||
let widths: Vec<f32> = rt
|
||
.elements()
|
||
.into_iter()
|
||
.filter(|e| e.key.as_deref().is_some_and(|k| k.starts_with("lab-card-")))
|
||
.map(|e| e.rect[2])
|
||
.collect();
|
||
let width = *width.get_or_insert(widths[0]);
|
||
assert!(
|
||
widths.iter().all(|w| (w - width).abs() < 0.5),
|
||
"{chip}: every card is as wide: {widths:?}"
|
||
);
|
||
}
|
||
// A chip's group can come out even as labs are added and removed, so the
|
||
// lone card is a search that matches exactly one.
|
||
tap(&mut rt, "chip-all");
|
||
rt.update(|ui, _| ui.lab_store.search = rune::TextEdit::new("failure notices".to_string()));
|
||
settle(&mut rt);
|
||
let lone: Vec<f32> = rt
|
||
.elements()
|
||
.into_iter()
|
||
.filter(|e| e.key.as_deref().is_some_and(|k| k.starts_with("lab-card-")))
|
||
.map(|e| e.rect[2])
|
||
.collect();
|
||
assert_eq!(lone.len(), 1, "the search matches one card: {lone:?}");
|
||
assert!(
|
||
(lone[0] - width.expect("a chip shows cards")).abs() < 0.5,
|
||
"a card alone in its row keeps half the width: {lone:?}"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn new_in_labs_isnt_repeated_in_the_grid() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
unfold_labs(&mut rt);
|
||
let featured: Vec<String> = rt
|
||
.elements()
|
||
.into_iter()
|
||
.filter_map(|e| e.key?.strip_prefix("lab-featured-").map(str::to_string))
|
||
.collect();
|
||
// Up to two of the labs added most recently: how many depends on how
|
||
// many share the newest date on this OS, not on the test.
|
||
assert!(
|
||
(1..=2).contains(&featured.len()),
|
||
"one or two labs are featured: {featured:?}"
|
||
);
|
||
for id in featured {
|
||
assert!(
|
||
rt.find(&format!("lab-card-{id}")).is_none(),
|
||
"{id} shows once"
|
||
);
|
||
}
|
||
}
|
||
|
||
/// Groups start folded unless they hold a lab that's on, fold and unfold
|
||
/// from their header, remember it, and stay open while their last lab
|
||
/// turns off. A search shows every match whatever the folds.
|
||
#[test]
|
||
fn labs_groups_fold_and_remember_it() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
assert!(
|
||
rt.find("lab-card-live-text").is_some(),
|
||
"Dictation holds Live text, on"
|
||
);
|
||
assert!(
|
||
rt.find("lab-card-unload-idle").is_none(),
|
||
"Models holds nothing on"
|
||
);
|
||
tap(&mut rt, "group-models");
|
||
assert!(rt.find("lab-card-unload-idle").is_some());
|
||
assert_eq!(rt.state.settings.labs.groups.get("models"), Some(&true));
|
||
tap(&mut rt, "group-dictation");
|
||
assert!(rt.find("lab-card-live-text").is_none());
|
||
assert_eq!(rt.state.settings.labs.groups.get("dictation"), Some(&false));
|
||
tap(&mut rt, "nav-general");
|
||
tap(&mut rt, "nav-labs");
|
||
assert!(rt.find("lab-card-unload-idle").is_some(), "remembered");
|
||
assert!(rt.find("lab-card-live-text").is_none(), "remembered");
|
||
|
||
rt.update(|ui, _| ui.lab_store.search = rune::TextEdit::new("live text".to_string()));
|
||
settle(&mut rt);
|
||
assert!(
|
||
rt.find("lab-card-live-text").is_some(),
|
||
"a search shows folded matches"
|
||
);
|
||
assert!(
|
||
rt.find("group-dictation-slot").is_none(),
|
||
"under a plain heading"
|
||
);
|
||
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.state.settings.labs.unload_idle = true;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "lab-unload-idle");
|
||
assert!(!rt.state.settings.labs.unload_idle);
|
||
assert!(
|
||
rt.find("lab-card-unload-idle").is_some(),
|
||
"turning off a group's last lab leaves it open"
|
||
);
|
||
assert_eq!(rt.state.settings.labs.groups.get("models"), Some(&true));
|
||
}
|
||
|
||
#[cfg(target_os = "macos")]
|
||
#[test]
|
||
fn a_saved_record_shortcut_shows_and_clears_while_annotate_is_off() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 4000.0));
|
||
rt.update(|ui, _| {
|
||
ui.settings.labs.screenshots = true;
|
||
ui.settings.capture.enabled = false;
|
||
ui.settings.screenshots.record_hotkey =
|
||
Some(crate::app_settings::HotkeyBinding::screenshot_default());
|
||
ui.lab_store.group = Some(crate::labs::Feature::Screenshots.group());
|
||
});
|
||
settle(&mut rt);
|
||
assert!(rt.find("needs-annotate").is_some());
|
||
assert!(
|
||
rt.find("clear-screenshot-record-shortcut").is_some(),
|
||
"the key it holds stays visible and can be freed"
|
||
);
|
||
tap(&mut rt, "clear-screenshot-record-shortcut");
|
||
assert_eq!(rt.state.settings.screenshots.record_hotkey, None);
|
||
assert!(rt.find("clear-screenshot-record-shortcut").is_none());
|
||
}
|
||
|
||
/// Labs › Screenshots' saves folder: the row's label is the folder, a picked
|
||
/// one is saved and shown, a cancel changes nothing, a chooser that
|
||
/// couldn't open says why, and the last failed save names the folder it
|
||
/// failed into (not the one chosen since) until another pick clears it. The
|
||
/// dialog itself never opens here: a test would wait on a real panel.
|
||
#[cfg(target_os = "macos")]
|
||
#[test]
|
||
fn a_chosen_screenshots_folder_is_saved_and_says_why_a_chooser_failed() {
|
||
use crate::rune_ui::labs::screenshots::apply_chosen_folder;
|
||
|
||
// The last-save error is one process-wide static: only this test writes
|
||
// it, and it starts and ends clean so a test running beside it never
|
||
// inherits a note.
|
||
crate::screenshots::clear_save_error();
|
||
|
||
let mut rt = runtime("mac-labs-screenshots", true, (980.0, 4000.0));
|
||
let shown = element(&rt, "choose-screenshot-folder")
|
||
.label
|
||
.unwrap_or_default();
|
||
assert!(!shown.is_empty(), "the row shows the saves folder");
|
||
|
||
let home = crate::app_paths::home_dir().expect("a home folder");
|
||
let picked = home.join("Pictures/Hex Shots");
|
||
rt.update(|ui, _| {
|
||
assert!(apply_chosen_folder(ui, Ok(Some(picked.clone()))));
|
||
});
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.settings.screenshots.folder, Some(picked.clone()));
|
||
assert_eq!(
|
||
element(&rt, "choose-screenshot-folder").label.as_deref(),
|
||
Some("~/Pictures/Hex Shots"),
|
||
"the card shows the folder it saves to, home-shortened"
|
||
);
|
||
assert!(rt.find("screenshot-folder-error").is_none());
|
||
|
||
rt.update(|ui, _| {
|
||
assert!(
|
||
!apply_chosen_folder(ui, Ok(None)),
|
||
"a cancel changes nothing"
|
||
);
|
||
});
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.settings.screenshots.folder, Some(picked.clone()));
|
||
|
||
// A save that failed into an older folder names that folder, not the
|
||
// setting that has moved on since. `settle` runs the window's poll, so
|
||
// the note has to come from the poll reporting the change.
|
||
let stale = home.join("Old Shots");
|
||
crate::screenshots::record_save_error(&stale, &anyhow::anyhow!("Permission denied"));
|
||
settle(&mut rt);
|
||
let shown = texts(&rt).join("\n");
|
||
assert!(rt.find("screenshot-save-error").is_some(), "{shown}");
|
||
assert!(shown.contains("~/Old Shots"), "{shown}");
|
||
assert!(
|
||
!shown.contains("~/Pictures/Hex Shots: "),
|
||
"the note names the folder that failed: {shown}"
|
||
);
|
||
|
||
// A pick that saves clears the note, and its own poll reports that.
|
||
let other = home.join("Pictures/Hex Shots 2");
|
||
rt.update(|ui, _| {
|
||
assert!(apply_chosen_folder(ui, Ok(Some(other.clone()))));
|
||
});
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.settings.screenshots.folder, Some(other.clone()));
|
||
assert!(
|
||
rt.find("screenshot-save-error").is_none(),
|
||
"a pick clears it"
|
||
);
|
||
|
||
rt.update(|ui, _| {
|
||
assert!(apply_chosen_folder(
|
||
ui,
|
||
Err("no file chooser portal".into())
|
||
));
|
||
});
|
||
settle(&mut rt);
|
||
assert!(rt.find("screenshot-folder-error").is_some());
|
||
assert_eq!(
|
||
rt.state.settings.screenshots.folder,
|
||
Some(other),
|
||
"a failed chooser leaves the folder alone"
|
||
);
|
||
|
||
crate::screenshots::clear_save_error();
|
||
}
|
||
|
||
/// Each OS shows only its labs, and a group with none of them hides.
|
||
#[test]
|
||
fn labs_groups_follow_each_os() {
|
||
let cards = |rt: &Runtime<Ui>| -> Vec<String> {
|
||
rt.elements()
|
||
.into_iter()
|
||
.filter_map(|e| {
|
||
let key = e.key?;
|
||
key.strip_prefix("lab-card-")
|
||
.or_else(|| key.strip_prefix("lab-featured-"))
|
||
.map(str::to_string)
|
||
})
|
||
.collect()
|
||
};
|
||
let cases: [(&str, &[&str], &[&str]); 3] = [
|
||
(
|
||
"windows-labs",
|
||
&["terminal-paste"],
|
||
&["mouse-shortcuts", "microphone-key"],
|
||
),
|
||
(
|
||
"linux-labs",
|
||
&["section-key"],
|
||
&["terminal-paste", "microphone-key"],
|
||
),
|
||
(
|
||
"mac-labs",
|
||
&["section-key", "mouse-shortcuts", "microphone-key"],
|
||
&["terminal-paste"],
|
||
),
|
||
];
|
||
for (scene, shows, hides) in cases {
|
||
let mut rt = runtime(scene, true, (980.0, 4000.0));
|
||
unfold_labs(&mut rt);
|
||
let shown = cards(&rt);
|
||
for id in shows {
|
||
assert!(shown.contains(&id.to_string()), "{scene} shows {id}");
|
||
}
|
||
for id in hides {
|
||
assert!(!shown.contains(&id.to_string()), "{scene} hides {id}");
|
||
}
|
||
for group in crate::labs::Group::ALL {
|
||
let any = shown.iter().any(|id| {
|
||
crate::labs::Feature::from_name(id)
|
||
.map_or(crate::labs::Group::Annotate, |feature| feature.group())
|
||
== group
|
||
});
|
||
assert_eq!(
|
||
rt.find(&format!("group-{}", group.id())).is_some(),
|
||
any,
|
||
"{scene}: {} shows only with a lab",
|
||
group.id()
|
||
);
|
||
}
|
||
}
|
||
let rt = runtime("windows-labs", true, (980.0, 4000.0));
|
||
assert!(rt.find("group-output").is_some());
|
||
assert!(
|
||
rt.find("lab-card-terminal-paste").is_some(),
|
||
"Output holds Terminal paste, on"
|
||
);
|
||
assert!(rt.find("lab-card-spoken-formatting").is_some());
|
||
assert!(
|
||
rt.find("lab-card-unload-idle").is_none(),
|
||
"Models is folded"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn command_f_searches_labs() {
|
||
let mut rt = runtime("mac-labs", true, PANE_SIZE);
|
||
assert!(!rt.state.lab_store.search.focused);
|
||
key(&mut rt, Key::Command('f'), Mods::default());
|
||
assert!(rt.state.lab_store.search.focused);
|
||
}
|
||
|
||
#[test]
|
||
fn labs_run_setup_again_opens_the_first_run() {
|
||
let mut rt = runtime("mac-labs", true, (980.0, 2000.0));
|
||
assert!(rt.state.first_run.is_none());
|
||
tap(&mut rt, "restart-onboarding");
|
||
assert!(rt.state.error.is_none(), "{:?}", rt.state.error);
|
||
assert!(rt.state.first_run.is_some(), "the first run opens at once");
|
||
}
|
||
|
||
#[test]
|
||
fn run_setup_again_opens_the_first_run_on_linux_and_windows() {
|
||
for scene in ["portal", "windows-settings"] {
|
||
let mut rt = runtime(scene, true, (980.0, 2000.0));
|
||
tap(&mut rt, "nav-labs");
|
||
tap(&mut rt, "restart-onboarding");
|
||
assert!(rt.state.error.is_none(), "{scene}: {:?}", rt.state.error);
|
||
assert!(rt.state.first_run.is_some(), "{scene}: the first run opens");
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn activity_lists_events_and_shows_the_raw_one() {
|
||
let mut rt = runtime("mac-activity", true, PANE_SIZE);
|
||
assert!(texts(&rt).iter().any(|t| t == "Context changed to Slack"));
|
||
tap(&mut rt, "activity-event4");
|
||
assert_eq!(rt.state.activity.selected, Some(4));
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|t| t.contains("\"application\":\"Slack\""))
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn modifier_only_shortcuts_choose_their_side() {
|
||
use crate::app_settings::ModifierSide;
|
||
let mut rt = runtime("mac-settings-sides", true, (980.0, 2400.0));
|
||
pick(&mut rt, "dictation-side", 2);
|
||
assert_eq!(
|
||
rt.state.settings.dictation_hotkey.modifiers.option,
|
||
Some(ModifierSide::Right)
|
||
);
|
||
// Key chords and Linux have no side choice.
|
||
let rt = runtime("mac-settings", true, (980.0, 2400.0));
|
||
assert!(rt.find("dictation-side").is_none());
|
||
let rt = runtime("portal", true, GOLDEN_SIZE);
|
||
assert!(rt.find("dictation-side").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn a_side_that_would_collide_is_refused() {
|
||
use crate::app_settings::{HotkeyBinding, HotkeyModifiers, ModifierSide};
|
||
let mut ui = fixture(DesktopShortcuts::Registered);
|
||
let option = |side| HotkeyBinding {
|
||
modifiers: HotkeyModifiers {
|
||
option: Some(side),
|
||
..HotkeyModifiers::default()
|
||
},
|
||
key: None,
|
||
};
|
||
ui.settings.dictation_hotkey = option(ModifierSide::Left);
|
||
ui.settings.paste_last_hotkey = Some(option(ModifierSide::Right));
|
||
assert!(
|
||
platform_settings::side_binding(
|
||
&ui.settings,
|
||
ShortcutTarget::Dictation,
|
||
ModifierSide::Right
|
||
)
|
||
.is_none()
|
||
);
|
||
assert!(
|
||
platform_settings::side_binding(
|
||
&ui.settings,
|
||
ShortcutTarget::Dictation,
|
||
ModifierSide::Left
|
||
)
|
||
.is_some()
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn macos_27_names_accessibility_as_system_settings_does() {
|
||
let rt = runtime("mac-settings-permissions", true, (980.0, 2400.0));
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|t| t == "Device Control and Data Access")
|
||
);
|
||
}
|
||
|
||
/// macOS 27.3 renamed the Accessibility list and stopped taking a dragged
|
||
/// tile; the name follows the list, and only that version says so.
|
||
#[test]
|
||
fn macos_27_3_names_accessibility_without_a_dragged_tile() {
|
||
assert_eq!(
|
||
platform_settings::accessibility_name(true, false),
|
||
"System & App Protection Override"
|
||
);
|
||
assert_eq!(
|
||
platform_settings::accessibility_name(true, true),
|
||
"Device Control and Data Access"
|
||
);
|
||
assert_eq!(
|
||
platform_settings::accessibility_name(false, true),
|
||
"Accessibility"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn experiment_goldens() {
|
||
let _goldens = Goldens::collect();
|
||
for dark in [true, false] {
|
||
check_golden("mac-voice-filter", dark, PANE_SIZE);
|
||
check_golden("mac-hud-lab", dark, PANE_SIZE);
|
||
}
|
||
check_golden("voice-filter-unavailable", true, PANE_SIZE);
|
||
check_golden("voice-filter", false, PANE_SIZE);
|
||
check_golden("mac-voice-filter-muted", true, PANE_SIZE);
|
||
check_golden("mac-voice-filter-driver-missing", false, PANE_SIZE);
|
||
check_golden("mac-activity", false, PANE_SIZE);
|
||
check_golden("mac-settings-sides", true, PANE_SIZE);
|
||
check_golden("mac-local-build", true, PANE_SIZE);
|
||
}
|
||
|
||
#[test]
|
||
fn ducking_shows_a_persisted_slider_on_every_os_when_selected() {
|
||
use crate::app_settings::RecordingAudioBehavior;
|
||
let mut rt = runtime("mac-settings", true, (1100.0, 2800.0));
|
||
open_advanced(&mut rt, Pane::General);
|
||
assert!(rt.find("recording-duck-slider").is_none());
|
||
pick(&mut rt, "while-dictating", 2);
|
||
assert_eq!(
|
||
rt.state.settings.recording_audio_behavior,
|
||
RecordingAudioBehavior::Duck
|
||
);
|
||
let before = rt.state.saved;
|
||
let (x, y) = rt.find("recording-duck-slider/track").unwrap();
|
||
rt.pointer_down(x + 60.0, y);
|
||
assert_eq!(
|
||
rt.state.saved, before,
|
||
"dragging does not persist each movement"
|
||
);
|
||
rt.pointer_up(x + 60.0, y);
|
||
settle(&mut rt);
|
||
assert_eq!(rt.state.saved, before + 1);
|
||
let volume = rt.state.settings.recording_duck_volume;
|
||
assert!(volume > 0.2 && volume <= 1.0);
|
||
pick(&mut rt, "while-dictating", 3);
|
||
assert!(rt.find("recording-duck-slider").is_none());
|
||
pick(&mut rt, "while-dictating", 2);
|
||
assert_eq!(rt.state.settings.recording_duck_volume, volume);
|
||
for scene in ["portal", "windows-settings"] {
|
||
let mut rt = runtime(scene, true, (1100.0, 2800.0));
|
||
if scene == "portal" {
|
||
rt.state.platform.caps = platform::Capabilities::LINUX;
|
||
}
|
||
open_advanced(&mut rt, Pane::General);
|
||
pick(&mut rt, "while-dictating", 2);
|
||
assert_eq!(
|
||
rt.state.settings.recording_audio_behavior,
|
||
RecordingAudioBehavior::Duck
|
||
);
|
||
assert!(rt.find("recording-duck-slider").is_some());
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn ducking_goldens() {
|
||
let _goldens = Goldens::collect();
|
||
for dark in [true, false] {
|
||
check_golden("mac-settings-ducking", dark, PANE_SIZE);
|
||
check_golden("mac-settings", dark, PANE_SIZE);
|
||
}
|
||
check_golden("mac-settings-permissions", true, PANE_SIZE);
|
||
check_golden("mac-settings-advanced", false, PANE_SIZE);
|
||
check_golden("mac-settings-sides", true, PANE_SIZE);
|
||
}
|
||
|
||
/// Labs › Live typing says when this desktop has no input method to use, and
|
||
/// refuses to turn on; where it is offered it turns on as usual.
|
||
#[test]
|
||
fn live_typing_says_when_the_desktop_cannot_use_it() {
|
||
let mut rt = runtime("linux-labs", false, PANE_SIZE);
|
||
rt.state.platform.live_typing_unsupported = true;
|
||
refresh(&mut rt);
|
||
open_labs(&mut rt);
|
||
tap(&mut rt, "lab-live-typing");
|
||
assert!(
|
||
!rt.state.settings.labs.live_typing,
|
||
"the switch stays off where it can't work"
|
||
);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("This desktop doesn't offer the input method")),
|
||
"its card says why"
|
||
);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("On Wayland, show your words in the text box")),
|
||
"its description stays under the note"
|
||
);
|
||
|
||
// Already on, it can still be turned off.
|
||
rt.state.settings.labs.live_typing = true;
|
||
refresh(&mut rt);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("This desktop doesn't offer the input method")),
|
||
"the note stays while it's on"
|
||
);
|
||
tap(&mut rt, "lab-live-typing");
|
||
assert!(!rt.state.settings.labs.live_typing);
|
||
|
||
// A compositor that offers the input method turns it on.
|
||
rt.state.platform.live_typing_unsupported = false;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "lab-live-typing");
|
||
assert!(rt.state.settings.labs.live_typing);
|
||
}
|
||
|
||
/// Labs › Clean up with Apple Intelligence says why Apple Intelligence can't
|
||
/// run here, locks its switch while it is off, and still turns off once on.
|
||
#[test]
|
||
fn clean_up_says_why_apple_intelligence_cannot_run() {
|
||
use crate::rune_ui::platform::NotesAvailability;
|
||
// Tall enough that the Output group's cards sit inside the window, where
|
||
// a tap reaches their switches.
|
||
let mut rt = runtime("mac-labs", true, (980.0, 2400.0));
|
||
rt.state.platform.notes = NotesAvailability::NotEnabled;
|
||
refresh(&mut rt);
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-clean-up").is_some());
|
||
tap(&mut rt, "lab-clean-up");
|
||
assert!(
|
||
!rt.state.settings.labs.clean_up_with_apple_intelligence,
|
||
"the switch stays off where it can't work"
|
||
);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("Turn on Apple Intelligence in System Settings")),
|
||
"its card says why"
|
||
);
|
||
|
||
// Already on, it can still be turned off.
|
||
rt.state.settings.labs.clean_up_with_apple_intelligence = true;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "lab-clean-up");
|
||
assert!(!rt.state.settings.labs.clean_up_with_apple_intelligence);
|
||
|
||
// This Mac has Apple Intelligence: the switch turns on.
|
||
rt.state.platform.notes = NotesAvailability::Available;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "lab-clean-up");
|
||
assert!(rt.state.settings.labs.clean_up_with_apple_intelligence);
|
||
assert!(
|
||
!texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("Turn on Apple Intelligence in System Settings")),
|
||
"no note while it can run"
|
||
);
|
||
}
|
||
|
||
/// Labs › Neutral voice says why Apple Intelligence can't run here, locks its
|
||
/// switch while it is off, and still turns off once on.
|
||
#[test]
|
||
fn neutral_voice_says_why_apple_intelligence_cannot_run() {
|
||
use crate::rune_ui::platform::NotesAvailability;
|
||
// Tall enough that the Output group's cards sit inside the window, where
|
||
// a tap reaches their switches.
|
||
let mut rt = runtime("mac-labs", true, (980.0, 2800.0));
|
||
rt.state.platform.notes = NotesAvailability::NotEnabled;
|
||
refresh(&mut rt);
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-neutral-voice").is_some());
|
||
tap(&mut rt, "lab-neutral-voice");
|
||
assert!(
|
||
!rt.state.settings.labs.neutral_voice,
|
||
"the switch stays off where it can't work"
|
||
);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("Turn on Apple Intelligence in System Settings")),
|
||
"its card says why"
|
||
);
|
||
|
||
// Already on, it can still be turned off.
|
||
rt.state.settings.labs.neutral_voice = true;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "lab-neutral-voice");
|
||
assert!(!rt.state.settings.labs.neutral_voice);
|
||
|
||
// This Mac has Apple Intelligence: the switch turns on.
|
||
rt.state.platform.notes = NotesAvailability::Available;
|
||
refresh(&mut rt);
|
||
tap(&mut rt, "lab-neutral-voice");
|
||
assert!(rt.state.settings.labs.neutral_voice);
|
||
}
|
||
|
||
/// An organization's lock keeps the cleanup card off, disabled, and saying
|
||
/// so, instead of its Apple Intelligence note, whatever this Mac can run.
|
||
#[test]
|
||
fn a_managed_lock_holds_the_cleanup_lab_off() {
|
||
use crate::policy::{Lock, Policy};
|
||
let _locked = Policy::forced_for_test(Policy::default().with(Lock::Labs));
|
||
let mut rt = runtime("mac-labs", true, (980.0, 2400.0));
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-clean-up").is_some(), "the card still lists");
|
||
tap(&mut rt, "lab-clean-up");
|
||
assert!(
|
||
!rt.state.settings.labs.clean_up_with_apple_intelligence,
|
||
"a locked switch never turns on"
|
||
);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text == "Managed by your organization"),
|
||
"its row says why"
|
||
);
|
||
assert!(
|
||
!texts(&rt)
|
||
.iter()
|
||
.any(|text| text.starts_with("Turn on Apple Intelligence")),
|
||
"the Apple Intelligence note would replace the lock's words"
|
||
);
|
||
}
|
||
|
||
/// An organization's lock keeps the drop card off and saying so; the formats
|
||
/// line its copy is built from must not replace the lock's words.
|
||
#[test]
|
||
fn a_managed_lock_holds_the_drop_transcribe_lab_off() {
|
||
use crate::policy::{Lock, Policy};
|
||
let describe = |rt: &Runtime<Ui>| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| {
|
||
e.path.contains("lab-card-drop-transcribe") && e.path.ends_with("/description")
|
||
})
|
||
.and_then(|e| e.text)
|
||
};
|
||
let locked = Policy::forced_for_test(Policy::default().with(Lock::Labs));
|
||
let mut rt = runtime("mac-labs", true, (980.0, 2400.0));
|
||
open_labs(&mut rt);
|
||
assert_eq!(
|
||
describe(&rt).as_deref(),
|
||
Some("Managed by your organization"),
|
||
"its row says why"
|
||
);
|
||
|
||
drop(locked);
|
||
refresh(&mut rt);
|
||
assert!(
|
||
describe(&rt).is_some_and(|text| text.starts_with("Drop a ")),
|
||
"unlocked, the card names the formats the drop target offers"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn an_installed_driver_keeps_the_voice_filter_on() {
|
||
let mut rt = runtime("mac-voice-filter", true, (980.0, 1400.0));
|
||
assert!(fun_driver_installed(&rt));
|
||
rt.state.settings.experimental.hex_microphone = false;
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("nav-voice-filter").is_some(),
|
||
"the driver keeps it in the sidebar"
|
||
);
|
||
assert!(rt.find("fun-hex-microphone").is_some());
|
||
tap(&mut rt, "uninstall");
|
||
assert!(matches!(
|
||
asked(&rt).last(),
|
||
Some(PlatformRequest::UninstallHexMicrophone)
|
||
));
|
||
open_labs(&mut rt);
|
||
tap(&mut rt, "lab-voice-filter");
|
||
assert!(
|
||
!rt.state.settings.experimental.hex_microphone,
|
||
"the toggle is locked"
|
||
);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|t| t.starts_with("On while the Hex Microphone driver is installed")),
|
||
"its card says why"
|
||
);
|
||
assert!(rt.find("nav-voice-filter").is_some());
|
||
|
||
if let Some(driver) = &mut rt.state.platform.hex_microphone {
|
||
driver.driver_bundle_installed = false;
|
||
}
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("nav-voice-filter").is_none(),
|
||
"off once uninstalled"
|
||
);
|
||
tap(&mut rt, "lab-voice-filter");
|
||
assert!(
|
||
rt.state.settings.experimental.hex_microphone,
|
||
"without the driver the toggle works"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn a_stable_build_offers_only_uninstall_for_an_installed_driver() {
|
||
let _stable = crate::dev_build::pretend_stable();
|
||
let mut rt = runtime("mac-voice-filter", true, (980.0, 1400.0));
|
||
assert!(fun_driver_installed(&rt));
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("nav-voice-filter").is_some(),
|
||
"the driver keeps its pane"
|
||
);
|
||
assert!(rt.find("hex-mic-driver").is_some());
|
||
assert!(rt.find("fun-mode").is_none(), "but no filter to tune");
|
||
assert!(rt.find("fun-try-it").is_none());
|
||
tap(&mut rt, "uninstall");
|
||
assert!(matches!(
|
||
asked(&rt).last(),
|
||
Some(PlatformRequest::UninstallHexMicrophone)
|
||
));
|
||
if let Some(driver) = &mut rt.state.platform.hex_microphone {
|
||
driver.driver_bundle_installed = false;
|
||
}
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("nav-voice-filter").is_none(),
|
||
"gone once uninstalled, though its setting is on"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn a_stable_build_has_no_playground_or_voice_filter_lab() {
|
||
let _stable = crate::dev_build::pretend_stable();
|
||
let mut rt = runtime("mac-settings", true, (980.0, 4000.0));
|
||
rt.state.settings.labs.playground = true;
|
||
rt.state.settings.experimental.hex_microphone = true;
|
||
refresh(&mut rt);
|
||
assert!(rt.find("nav-playground").is_none());
|
||
open_labs(&mut rt);
|
||
unfold_labs(&mut rt);
|
||
assert!(rt.find("lab-live-text").is_some());
|
||
assert!(rt.find("lab-playground").is_none());
|
||
assert!(rt.find("lab-voice-filter").is_none());
|
||
}
|
||
|
||
fn fun_driver_installed(rt: &rune::Runtime<Ui>) -> bool {
|
||
rt.state
|
||
.platform
|
||
.hex_microphone
|
||
.as_ref()
|
||
.is_some_and(|status| status.driver_bundle_installed)
|
||
}
|
||
|
||
/// A pane longer than the window shows a scroll bar to drag, for a pointer
|
||
/// without a wheel (#1209).
|
||
#[test]
|
||
fn a_long_transcript_scrolls_by_dragging_its_scroll_bar() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
settle(&mut rt);
|
||
let at = |rt: &Runtime<Ui>, path: &str| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| e.path.ends_with(path))
|
||
.unwrap_or_else(|| panic!("no {path}"))
|
||
.rect
|
||
};
|
||
let thumb = at(
|
||
&rt,
|
||
"meeting-transcript-scroll-area/scroll-bar/thumb-slot/thumb",
|
||
);
|
||
assert!(thumb[3] > 0.0, "the transcript overflows, so its bar shows");
|
||
let top = at(&rt, "meeting-transcript/inset")[1];
|
||
let (x, y) = (thumb[0] + thumb[2] / 2.0, thumb[1] + 4.0);
|
||
rt.pointer_move(x, y);
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_move(x, y + 60.0);
|
||
rt.pointer_up(x, y + 60.0);
|
||
settle(&mut rt);
|
||
assert!(
|
||
at(&rt, "meeting-transcript/inset")[1] < top - 60.0,
|
||
"dragging the thumb scrolled the transcript"
|
||
);
|
||
assert!(
|
||
at(
|
||
&rt,
|
||
"meeting-transcript-scroll-area/scroll-bar/thumb-slot/thumb"
|
||
)[1] > thumb[1] + 59.0
|
||
);
|
||
}
|
||
|
||
/// The Labs store uses the same clearly visible pane thumb, and dragging it
|
||
/// scrolls the store.
|
||
#[test]
|
||
fn a_long_labs_store_scrolls_by_dragging_its_scroll_bar() {
|
||
let mut rt = runtime("linux-labs", true, PANE_SIZE);
|
||
unfold_labs(&mut rt);
|
||
settle(&mut rt);
|
||
let at = |rt: &Runtime<Ui>, path: &str| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| e.path.ends_with(path))
|
||
.unwrap_or_else(|| panic!("no {path}"))
|
||
};
|
||
let thumb = at(&rt, "scroll-scroll-area/scroll-bar/thumb-slot/thumb");
|
||
assert_eq!(thumb.fill, rune_theme_opencode::kit(true).c.text_faint);
|
||
assert_eq!(thumb.opacity, 1.0);
|
||
assert!(thumb.rect[2] >= 8.0, "the pane thumb is wide enough to see");
|
||
assert!(
|
||
thumb.rect[3] > 0.0,
|
||
"the Labs store overflows with every group open"
|
||
);
|
||
let top = at(&rt, "scroll-scroll-area/scroll/inset").rect[1];
|
||
let (x, y) = (thumb.rect[0] + thumb.rect[2] / 2.0, thumb.rect[1] + 4.0);
|
||
rt.pointer_move(x, y);
|
||
rt.pointer_down(x, y);
|
||
rt.pointer_move(x, y + 60.0);
|
||
rt.pointer_up(x, y + 60.0);
|
||
settle(&mut rt);
|
||
assert!(
|
||
at(&rt, "scroll-scroll-area/scroll/inset").rect[1] < top - 60.0,
|
||
"dragging the thumb scrolled the Labs store"
|
||
);
|
||
assert!(
|
||
at(&rt, "scroll-scroll-area/scroll-bar/thumb-slot/thumb").rect[1] > thumb.rect[1] + 59.0
|
||
);
|
||
}
|
||
|
||
/// A touchscreen taps like a click and a finger drag pans a long transcript
|
||
/// (#1337).
|
||
#[test]
|
||
fn a_finger_pans_the_transcript_and_taps_the_sidebar() {
|
||
use rune::TouchPhase::{Ended, Moved, Started};
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
settle(&mut rt);
|
||
let inset = |rt: &Runtime<Ui>| {
|
||
rt.elements()
|
||
.into_iter()
|
||
.find(|e| e.path.ends_with("meeting-transcript/inset"))
|
||
.expect("the transcript")
|
||
.rect[1]
|
||
};
|
||
let top = inset(&rt);
|
||
let thumb = rt
|
||
.elements()
|
||
.into_iter()
|
||
.find(|e| {
|
||
e.path
|
||
.ends_with("meeting-transcript-scroll-area/scroll-bar/thumb-slot/thumb")
|
||
})
|
||
.expect("the transcript's bar")
|
||
.rect;
|
||
let (x, y) = (thumb[0] - 80.0, thumb[1] + 200.0);
|
||
rt.touch(1, Started, x, y, 0.0);
|
||
for step in 1..=4 {
|
||
rt.touch(1, Moved, x, y - 30.0 * step as f32, 0.01 * f64::from(step));
|
||
}
|
||
rt.touch(1, Ended, x, y - 120.0, 0.5);
|
||
settle(&mut rt);
|
||
assert!(
|
||
inset(&rt) <= top - 110.0,
|
||
"the transcript followed the finger"
|
||
);
|
||
|
||
let (x, y) = rt.find("nav-labs").expect("the Labs item");
|
||
rt.touch(2, Started, x, y, 1.0);
|
||
rt.touch(2, Ended, x, y, 1.05);
|
||
settle(&mut rt);
|
||
assert!(rt.find("lede").is_some(), "the tap opened Labs");
|
||
}
|