Files
gridcraft/crates/ui-egui/tests/dialog_button_row.rs
T
dantebertuzziandClaude Opus 5.5 bdc0552a92 Dialogs: OK and Cancel in a row, so form dialogs fit their content
`ok_cancel` put the buttons in a right-to-left layout straight in the
window. That layout takes all the height it is offered, so every form
dialog (Greater Than…, New Name, Remove Duplicates, …) grew to the
screen's height with OK and Cancel floating halfway down. The buttons
now sit in a horizontal row as tall as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 21:38:34 -03:00

28 lines
1.0 KiB
Rust

//! Form dialogs fit their content: OK and Cancel sit right under the last field, not halfway down
//! a window stretched to the screen's height.
use egui_kittest::kittest::Queryable as _;
use gridcraft_engine::Session;
use gridcraft_ui_egui::SheetApp;
use serde_json::json;
#[test]
fn ok_and_cancel_sit_under_the_last_field() {
let mut s = Session::new();
s.new_workbook();
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 1000.0)).build_ui_state(
|ui, app: &mut SheetApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
SheetApp::new(s, Default::default()),
);
h.state_mut().open_dialog("cfQuick", json!({"type": "cellIs", "operator": "greaterThan", "title": "Greater Than…"}));
h.run_steps(4);
let last = h.get_by_label("Red Border").rect();
let ok = h.get_by_label_contains("OK").rect();
let gap = ok.top() - last.bottom();
assert!((0.0..40.0).contains(&gap), "OK is {gap} points under the last option");
}