Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/dwarves

dwarves-gui/tests/checkbox_tooltip_click.rs

//! A checkbox that carries a hover tooltip still toggles on a click — the hover
//! comes first, as a user's pointer always does.
//!
//! Added 2026-10-02 with the egui 0.35 -> 0.36 bump. `robot_thin_appliance`'s
//! WireGuard toggle (a checkbox with `on_hover_text`) went red once during that
//! bump and could not be reproduced afterwards (8/8 green; that test reads its
//! recipe from whatever gunnar checkout `$HOME` holds, which other work changes).
//! This pins the widget behaviour itself, with no repo on disk involved, so an
//! egui change that lets a tooltip swallow the click is caught here by name.

use egui_kittest::{kittest::Queryable, Harness};

fn click_with_tooltip(hover_first: bool) -> bool {
    let mut on = true;
    {
        let mut h = Harness::new_ui(|ui| {
            ui.horizontal(|ui| {
                ui.checkbox(&mut on, egui::RichText::new("WireGuard-klient").strong())
                    .on_hover_text("av ⇒ wg-client byggs INTE in i den packade binären");
            });
        });
        h.run();
        if hover_first {
            h.get_by_label("WireGuard-klient").hover();
            h.run();
        }
        h.get_by_label("WireGuard-klient").click();
        h.run();
    }
    on
}

#[test]
fn a_checkbox_with_a_tooltip_toggles_on_click() {
    assert!(!click_with_tooltip(false), "a plain click must untick it");
}

#[test]
fn a_checkbox_toggles_even_after_its_tooltip_has_opened() {
    assert!(
        !click_with_tooltip(true),
        "hover (tooltip open) then click must untick it"
    );
}