mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* Onboarding: slower Without Hex comedy with a start button, a real conversation, and one focus at a time * Onboarding comedy v2: Launch Room, visible slip, rewind into Hex Jay's question is up before the click and the first reply comes 0.35 s after it. The deady/dead slip holds long enough to read, then Return flashes red with a heavy clunk. The scene is one iMessage group: the removal is a red pill that wipes a frantic draft mid-word and locks the field. With Hex rewinds the disaster, melts the keys down to the lit shortcut, and raises the HUD before the key goes down. The caret no longer sits under a word as it lands. Adds original chat sounds, a score counted in whole seconds with a chime, and a live first run that waits for Continue. * Onboarding comedy v3: one-way melt, clean act breaks, upward rewind, Skip * Test that Skip appears two seconds in and leaves the comedy * Fill the keyboard's pocket back in once the HUD has gone * Onboarding comedy v4 engine: presenting pill, tapbacks, heartbeat, slow motion and the autocorrect slam * Onboarding: scenes as plain-text files, with a celebration in With Hex Each scene sets its own room, people, pill, ending and With Hex payoff (replies, tapbacks, status pills, confetti and fireworks with their own sounds). The validator reports line-numbered mistakes and the limits a scene can hold. * Scenes: document the limits and the folder check * Onboarding: tapbacks stay on the line above, the pill keeps its own row, and With Hex can change it * Polish the practice game: themed messages, transcript and high score, real Dot scope, logo build, Replay onboarding * Scene folder check prints every scene's length * Flush the ready soundtrack once the logo is built * Scenes: only the theme's colours, and a clear error for any other * Check the whole Advanced fold, down to Replay onboarding * C-plus: v3's scene with the over-the-top With Hex * Drop the whole-pixel bob now that Rune glides text with its box * Onboarding chat: the real Messages sounds from macOS, pill in the header Received, sent and each tapback's sound load at run time from macOS's own files, peak-matched to Hex's stand-ins, which still play where a file is missing and off macOS. The presenting pill moves into the conversation header, level with the title. * Follow the dictation/ move, and keep a resized golden's render for CI * Onboarding: keep Reply::Lines' shape so the game's card is untouched The autocorrect mark goes to chat() as its own argument, and notice() draws sent_bubbles again as dev does. * Golden: the whole Advanced fold, down to Replay onboarding * Onboarding comedy: Model M typing, a real heartbeat, three triumph takes The Without Hex keys are now cut from a CC0 recording of an IBM Model M (scripts/sounds/comedy/SOURCE.md): eight presses at three pitches, a deeper space bar and a heavier delete, each at a slightly different level, whatever key sound the reader picked. The heartbeat is a synthesized lub-dub under the clicks (HEX_ONBOARDING_HEARTBEAT=off drops it), and HEX_ONBOARDING_TRIUMPH=1..3 picks brass, a chime run, or a cheer and pop. scripts/sounds/comedy.py rebuilds them all. * Follow dev: audio::input_level, and drop Labs' last icon_row import * Onboarding comedy: tapbacks drawn like Messages Round badges on the bubble's top corner with a ring in the card's colour and two tail dots, grey for other people and blue for the reader's own, every glyph a vector shape including the two-line HA HA. Stacks put the newest on top. Prototypes/Onboarding/Tapbacks shows them all. * Move the game's pieces into game/ and its share card into game/share.rs for the code-shape gate * Labs: hold Paste last dictation to pick recent dictations (macOS) * Unify the first run: Without Hex, microphone, the practice game, Accessibility * Let the first run story play itself, game included * Count the sound cues' third field in the logo-build tests * Sound the comedy's triumph on the game's first score; Hex Test.app opens the new first run * Move the stories' side panel into stories/side.rs for the code-shape gate * First run: play the scripted With Hex payoff after Without Hex; start the heartbeat at the first typo * Onboarding round 2: Launch Room inbox row, Messages-style senders, ending hold, float-off grants, idle HUD pill, Launch at login on Ready, Settings guide reopen * Start the heartbeat at the first sent typo, much quieter * Open the Launch Room like an island: a pointer clicks the row and it grows into the chat Every first run autoplays: the row arrives with two even rings, a scripted pointer glides in and presses it, and the row grows into the conversation (width first, then height, on one straight path) while the group's faces, the title and Jay's question fly over as themselves. The rest fades in once the flights clear. Reduce Motion fades instead. * Add a replay strip to the first run in test and debug builds Restart, Back one beat, Joke (cycles the bundled scenes) and a fake download speed (real, 100 Mbps, 25 Mbps; Restart downloads again at it). Every build logs how long the download showed for. The swearing scenes A and B are only in builds with hex_dev_onboarding (debug or HEX_TEST_BUILD=1). * First run: Watch another one while the model downloads Almost ready shows the download as a quiet bar with its size and time left, and a button that plays one of three short Without Hex sketches. The bar moves to the top pill while one plays; a finished download goes on to the game at the sketch's next stop, after a reply has gone out. The button goes once all three have played. * First run: a whole-run story with a slow download and a sketch * Onboarding: sound for the whole first run, the Launch Room opens itself, and a motion gate - SfxTrack::clear keeps cues already fired, so the offline track keeps its first 73 s; the scripted game, the words and the cards burning get cues. - The download pill no longer flies over the words it passes; the Launch Room opens itself 5 s after it parks. - A motion gate over the first run in dark, light and Reduce Motion, plus a pixel check of the conversation opening: fixes its surface blinking as the plate hands over, Jay's doubled typing dots, the badge's one-frame pop and the preview's text swap. * Onboarding: the Launch Room's click taps, whether a person or the pointer clicks * Rune e6371c48: the motion gate checks what the first run paints - Bump rune, rune-kit, rune-theme-opencode and rune-motion to e6371c48 (rune#71); nix outputHash follows. - Mark the first run's deliberate motion where it's written (tapback bounces, the badge pop, keys, the game's shake) and narrow the allowlist to scoped, capped rows. - The empty avatar slot keeps its border while its fill fades, so the ring no longer vanishes a frame early. * Onboarding: the first run's clock runs on drawn frames, and its later pipelines warm on a thread (t1328) * Onboarding: call out keyboard and voice-first modes, punch in on autocorrect, prototype first-screen backdrops * Onboarding: drop the first-screen backdrop prototypes (t1328) * Onboarding: prototype a bigger HUD and an up-next row on Setting up Hex (t1328) * Onboarding: the Linux tests' page helper knows the two permission steps (t1328) * Onboarding goldens: the voice-first chip beside the heading (t1328) * Onboarding: first-screen prototype shows download size and an on-device note (t1328) * Onboarding: the first screen shows download size and that your voice stays on this Mac (t1328) * Onboarding: a failed download drops the size and privacy line; goldens for the first screen (t1328) * Onboarding: drop the render scratch the branch carried 673 frames and one-off scripts under .render/ were the scratch of the session that built this, not part of the change. * Keep render scratch and scene stills out of the tree * Onboarding: the scene tests that need a dev-only scene skip release builds A and B swear, so release builds leave them out of the bundle; two tests still asked for A by name and panicked where it was missing (the Nix package's test run). * Onboarding: goldens from the Linux run after the merge Seventeen onboarding renders moved: the first screen's download size and privacy line, the mic line from #1420, and dark text that sits a few pixels lower with dev's Rune pin. * Onboarding: a tighter opening and fireworks that light the page The first run's Setting up Hex holds a second, then the Launch Room's conversation is there as the download flies up: Jay's messages land in it with their sounds instead of on an inbox row a pointer clicks open. The Keyboard mode stamp goes (the heading's chip says it), Without Hex's heading is one line, and the privacy line also shows on the microphone step. With Hex's fireworks move to the GPU: three shells rise on trails and burst beside the conversation into a few hundred sparks each, white-hot to hue to crackling embers under drag and gravity. Each burst lights the page under it for a moment, multiplying what's drawn so surfaces brighten by their own colour and the dark page barely does. Reduce Motion gets one soft flash. The shipping scene drops its confetti. * Onboarding: sketches keep their own opening; the motion gate follows the shorter intro Sketches built their scenes from the first run's timing, so its shorter opening reached them. The slow-download fixture lands the model 6.8 s sooner, as much as the intro shrank, so the gate's windows see the same story; the practice game's shake can still be moving as the handoff window ends. * Fireworks: stars light as they leave the break, the shell's glitter is quieter, and the page light fades with no edge * Onboarding: fireworks in depth, and three compositions to compare Fireworks burst in two layers. Far shells sit behind the conversation, smaller, dimmer and softer, lighting it a little; near shells draw in front, bigger and brighter, their sparks falling across the card's edges for a moment and their light hitting it hard, with their cores kept beside it. A break opens as a bloom: packed stars share its light until the shell has spread, since sRGB-encoded blending adds a hundred faint stars up to a white disc. The demo's composition is now a layout the run picks, as it picks its scene, with three playground variants beside today's: A, a tighter centre (one two-line heading for both scenes, a larger conversation, the keyboard tucked under it, Skip in the corner); B, a split (the mode, a big title and one line in a left column, the conversation and its keyboard on the right, the fireworks in the open page); and C, a laptop (the conversation as its screen, the keyboard on its deck). Today's layout is unchanged. * Onboarding: the score pill hugs its count, and a near burst's break stays compact The practice game's score pill was a fixed 112 pt with its content left aligned, so "1 destroyed" sat 12 pt from its left edge and about 40 pt from its right. It's now as wide as its number and label need, with 12 pt either side in every language, and the share card folds back to that width. A near burst's bloom no longer spreads into a wide, faint, whitish disc that read as smoke. Headless renders take HEX_RENDER_LANGUAGE to check copy in another language. * feedback: the onboarding's cues in their own file, under the size limit * Onboarding: the card's landing nudge is a kick, and the motion gate gets the time it needs * Onboarding: goldens after dev's language-switch change and the microphone step's privacy line; the playground's two-line heading stays English * Onboarding motion: the game's idle pill fades on its clock, sent bubbles leave the field whole, and the Accessibility helper line fades out From per-frame traces of the whole scripted run: - The practice game's stage lands every change at once, so the idle pill's springs never ran: it vanished and reappeared in one frame at every take, and when the score card came and went. Its fade and settle are now worked out on the game's clock, from when the scope last came or went, and it steps aside with the chrome. - A sent line is launched out of the field, but its bubble faded in on its own, so each send started as a ghost of the text it left (five sends in Without Hex, the spoken answer in With Hex). The bubble now enters with its line. - The escaping Accessibility panel dropped its "Accessibility helper" line in one frame; it fades as the panel starts to move. * Onboarding motion: the idle pill's spring is settled before the first take, not NaN * Onboarding motion: a sent bubble's words leave the field at full strength too * Onboarding fireworks: a burst opens on a point of light, not a grey disc The bang was a wide glow at a quarter of white, which sRGB-encoded blending flattens into a grey-beige disc for three frames before the stars show. It is now small and brighter than white, gone as they open. On light pages the bursts' tint has a soft shoulder instead of a flat plateau of colour, and sparks paint a deeper hue so gold shows on white. * Onboarding copy: the certificate's sentence, the game's full stop, Accessibility's row on one line - "I hereby certify that I have completed Hex onboarding." - The game's lead ends its sentence, as every other lead does. - Accessibility's row drops "in any app", which the line above it says: allowed, it wrapped and left "app" alone on a second line. - The permission pages' headings are translated like their titles. * Onboarding: alignment and one main action - Skip steps aside while autocorrect's camera is pushed in: the keyboard swelled down over it. - The score card's two lines sit on the middle of the number. - The score pill is as tall as Done beside it. - Hex is ready keeps one contrast button: beside Start using Hex, Launch at login is a neutral one. * Onboarding pacing: Setting up Hex holds long enough to read, the removal holds once Setting up Hex held 1.0 s before the download flew up; 1.6 s reads. The first run held the removal for the scene's own 2.0 s and 1.6 s more, 3.6 s of silence; now 2.8 s. The game's screen shake is marked where it's written, a kick and steps, rather than allowed by where a gate window happens to end. * Onboarding: the certificate in its own file, and no unused import The motion fixes took game.rs past its size ceiling and left Spring imported with no use; the certificate moves out to game/certificate.rs. * Onboarding goldens: the game's full stop, and Launch at login beside Start using Hex
2817 lines
98 KiB
Rust
2817 lines
98 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, "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",
|
||
"detected-calls",
|
||
"hex-mic-driver",
|
||
"command-model-notice",
|
||
] {
|
||
assert!(!present(&mac, key), "macOS General has no {key}");
|
||
}
|
||
|
||
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, "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, 2000.0));
|
||
open_labs(&mut rt);
|
||
for row in [
|
||
"lab-mouse-shortcuts",
|
||
"lab-pause-browser",
|
||
"lab-keep-on-clipboard",
|
||
"lab-copy-only",
|
||
"lab-return-to-app",
|
||
"lab-spoken-formatting",
|
||
"lab-filler-words",
|
||
"lab-spoken-symbols",
|
||
"lab-caps-lock-dictation",
|
||
] {
|
||
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.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.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.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, 2400.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(),
|
||
"macOS and Windows"
|
||
);
|
||
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-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);
|
||
}
|
||
|
||
/// 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());
|
||
}
|
||
|
||
/// The separate Keep audio row follows its Labs toggle and saves the window.
|
||
#[test]
|
||
fn keep_audio_shows_with_its_lab_and_saves_its_window() {
|
||
use crate::app_settings::MeetingRetention;
|
||
let mut rt = runtime("portal", true, TALL_SIZE);
|
||
rt.state.settings.meetings.enabled = true;
|
||
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 the lab is off"
|
||
);
|
||
|
||
rt.state.settings.labs.expire_meeting_audio = 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("Follow Keep meetings")
|
||
);
|
||
pick(&mut rt, "meeting-audio-retention", 2);
|
||
assert_eq!(
|
||
rt.state.settings.meetings.audio_retention,
|
||
Some(MeetingRetention::Week)
|
||
);
|
||
}
|
||
|
||
/// 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 the
|
||
/// automatic choice 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.open);
|
||
tap(&mut rt, "model-picker-option-0");
|
||
assert_eq!(rt.state.settings.meetings.opencode_model, None);
|
||
assert!(
|
||
texts(&rt)
|
||
.iter()
|
||
.any(|text| text == "Hex picks a fast 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.explainer.open);
|
||
}
|
||
|
||
#[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.explainer.open);
|
||
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.explainer.open);
|
||
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.explainer.open);
|
||
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.explainer.open);
|
||
|
||
// 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.explainer.open);
|
||
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.explainer.open, "the picker closes the explainer");
|
||
explainer::open(&mut rt.state);
|
||
assert!(!rt.state.picker.open, "and the explainer the picker");
|
||
|
||
rt.state
|
||
.select_pane(Pane::History, &mut rune::Tx::default());
|
||
assert!(!rt.state.explainer.open);
|
||
picker::open(&mut rt.state);
|
||
rt.state
|
||
.select_pane(Pane::General, &mut rune::Tx::default());
|
||
assert!(!rt.state.picker.open);
|
||
}
|
||
|
||
#[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);
|
||
tap(&mut rt, "meeting-rename");
|
||
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_with_its_lab() {
|
||
let mut rt = runtime("portal", true, PANE_SIZE);
|
||
rt.state.build_preview = Some(BuildKind::Release);
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("release-notes").is_none(),
|
||
"off, the footer is unchanged"
|
||
);
|
||
|
||
rt.state.settings.labs.release_notes_link = true;
|
||
refresh(&mut rt);
|
||
assert!(rt.find("release-notes").is_some());
|
||
assert!(texts(&rt).iter().any(|text| text == "Release notes"));
|
||
|
||
for (kind, name) in [(BuildKind::Local, "local"), (BuildKind::Test, "test")] {
|
||
rt.state.build_preview = Some(kind);
|
||
refresh(&mut rt);
|
||
assert!(
|
||
rt.find("release-notes").is_none(),
|
||
"the lab is on, but 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 == "What's new"));
|
||
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-enabled");
|
||
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());
|
||
}
|
||
|
||
#[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]);
|
||
use crate::app_settings::MeetingPolicy;
|
||
let policy = |rt: &Runtime<Ui>, key: &str| {
|
||
rt.state
|
||
.settings
|
||
.meetings
|
||
.providers
|
||
.iter()
|
||
.find(|choice| choice.key == key)
|
||
.map(|choice| choice.policy)
|
||
};
|
||
// Known services first (Zoom is second), then the sites and apps chosen for.
|
||
pick(&mut rt, "call1-policy", 1);
|
||
assert_eq!(
|
||
policy(&rt, "us.zoom.xos"),
|
||
Some(MeetingPolicy::AlwaysRecord)
|
||
);
|
||
pick(&mut rt, "call8-policy", 0);
|
||
assert_eq!(
|
||
policy(&rt, "problems.kitlangton.com"),
|
||
Some(MeetingPolicy::Ask)
|
||
);
|
||
assert!(rt.find("call8").is_some());
|
||
tap(&mut rt, "meetings-enabled");
|
||
assert!(!rt.state.settings.meetings.enabled);
|
||
assert!(rt.find("meeting-folder").is_none());
|
||
assert!(rt.find("meetings-enabled").is_some(), "the opt-in remains");
|
||
}
|
||
|
||
#[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));
|
||
}
|
||
|
||
#[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)]
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn meetings_rename_from_the_title_field() {
|
||
let mut rt = runtime("meetings", true, PANE_SIZE);
|
||
tap(&mut rt, "meeting-rename");
|
||
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 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()
|
||
))]
|
||
);
|
||
}
|
||
|
||
#[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(
|
||
"/Users/kit/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(
|
||
"/Users/kit/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(
|
||
"/Users/kit/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 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);
|
||
}
|
||
|
||
#[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, PANE_SIZE);
|
||
tap(&mut rt, "fun-mode/segment1");
|
||
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, "fun-mode/segment3");
|
||
assert!(
|
||
rt.find("fun-slider-strength").is_none(),
|
||
"Normal has no sliders"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn voice_filter_sliders_set_the_filter_from_the_pointer() {
|
||
let mut rt = runtime("mac-voice-filter", true, PANE_SIZE);
|
||
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 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, "fun-play-call-hears");
|
||
tap(&mut rt, "fun-demo-source/segment1");
|
||
assert_eq!(
|
||
asked(&rt),
|
||
[
|
||
PlatformRequest::HexMicrophoneDemo(DemoRequest::Record),
|
||
PlatformRequest::HexMicrophoneDemo(DemoRequest::Play(
|
||
crate::audio::hex_microphone::DemoPlaybackTrack::CallHears
|
||
)),
|
||
PlatformRequest::HexMicrophoneDemo(DemoRequest::SelectSource(
|
||
crate::audio::hex_microphone::DemoSourceKind::Recording
|
||
)),
|
||
]
|
||
);
|
||
let mut rt = runtime("mac-voice-filter-muted", true, PANE_SIZE);
|
||
tap(&mut rt, "fun-play-call-hears");
|
||
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, 2000.0));
|
||
rt.state.settings.experimental.hex_microphone = false;
|
||
rt.state.platform.hex_microphone = None;
|
||
refresh(&mut rt);
|
||
for hidden in [
|
||
"nav-meetings",
|
||
"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-biasing", settings.labs.vocabulary_biasing),
|
||
("lab-return-to-app", settings.labs.return_to_app),
|
||
("lab-speakers-only", settings.labs.speakers_only),
|
||
] {
|
||
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-biasing");
|
||
assert!(rt.state.settings.labs.vocabulary_biasing);
|
||
tap(&mut rt, "lab-meetings");
|
||
assert!(rt.find("nav-meetings").is_none(), "hidden while off");
|
||
|
||
// 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, 2000.0));
|
||
assert!(rt.find("terminal-paste").is_none());
|
||
open_labs(&mut rt);
|
||
assert!(rt.find("lab-return-to-app").is_none(), "macOS only");
|
||
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"
|
||
);
|
||
}
|
||
|
||
#[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::VocabularyBiasing;
|
||
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-biasing").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::VocabularyBiasing.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 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::SubtitleExport;
|
||
assert!(rt.find("lab-card-subtitle-export").is_some());
|
||
tap(&mut rt, "lab-card-subtitle-export");
|
||
assert!(
|
||
!feature.on(&rt.state.settings),
|
||
"pressing a card flips nothing"
|
||
);
|
||
tap(&mut rt, "lab-subtitle-export");
|
||
assert!(
|
||
feature.on(&rt.state.settings),
|
||
"the card's switch turns it on"
|
||
);
|
||
tap(&mut rt, "lab-subtitle-export");
|
||
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").is_none(), "hidden while off");
|
||
tap(&mut rt, "lab-unload-idle");
|
||
assert!(rt.state.settings.labs.unload_idle);
|
||
assert!(rt.find("unload-idle-minutes").is_some());
|
||
}
|
||
|
||
#[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 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());
|
||
}
|
||
|
||
#[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 mut lone = false;
|
||
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();
|
||
lone |= widths.len() % 2 == 1;
|
||
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:?}"
|
||
);
|
||
}
|
||
assert!(lone, "some chip leaves a card alone in its row");
|
||
}
|
||
|
||
#[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));
|
||
}
|
||
|
||
/// 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| e.key?.strip_prefix("lab-card-").map(str::to_string))
|
||
.collect()
|
||
};
|
||
for (scene, has, lacks) in [
|
||
("windows-labs", "terminal-paste", "mouse-shortcuts"),
|
||
("linux-labs", "section-key", "terminal-paste"),
|
||
("mac-labs", "mouse-shortcuts", "section-key"),
|
||
] {
|
||
let mut rt = runtime(scene, true, (980.0, 4000.0));
|
||
unfold_labs(&mut rt);
|
||
let shown = cards(&rt);
|
||
assert!(shown.contains(&has.to_string()), "{scene} shows {has}");
|
||
assert!(!shown.contains(&lacks.to_string()), "{scene} hides {lacks}");
|
||
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")
|
||
);
|
||
}
|
||
|
||
#[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("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);
|
||
}
|
||
|
||
#[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");
|
||
}
|