Files
gridcraft/crates/ui-egui/tests/it/undo_while_grouping.rs
T
skylar taylor-barrick 41769f1d16 Migrate GridCraft to egui 0.37 (#2543)
* E37: migrate GridCraft to egui 0.37

Pin the reviewed fork and shared dependencies, adapt input and rendering to the
new frame lifecycle, and preserve bounded capture handling and font notices.
Add representative accessibility checks and meaningful control labels.

Validation: full repository CI passed all ten stages, with 2,249 tests passed,
zero failed and one existing timing test ignored. Native workflows and paired
performance qualification remain documented separately.

* egui037: record final published pins and local qualification

* M0.37: fix RTL clipping and preserve screenshot budgets

* test: share migrated GridCraft UI harness setup

* egui037: document migrated UI and regression contracts

* egui-037: align popup test fonts and avoid redundant tooltip probes
2026-10-25 14:55:00 -04:00

58 lines
2.2 KiB
Rust

//! Undo and Redo on the Quick Access Toolbar follow the commands' own availability: while an undo
//! group is open on the document (an action that spans several calls is still running), both
//! buttons are off, and a click neither runs the command nor raises its refusal.
use egui_kittest::kittest::{NodeT as _, Queryable as _};
use gridcraft_engine::Session;
use gridcraft_ui_egui::SheetApp;
use serde_json::json;
type Harness = egui_kittest::Harness<'static, SheetApp>;
fn harness() -> Harness {
let mut s = Session::new();
s.new_workbook();
s.execute("cell.set", json!({"cell": "A1", "input": "1"})).unwrap();
s.execute("cell.set", json!({"cell": "A1", "input": "2"})).unwrap();
s.execute("edit.undo", json!({})).unwrap();
let mut h = crate::common::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
|ui, app: &mut SheetApp| {
app.logic(ui.ctx());
app.ui(ui);
},
crate::common::app(s),
);
h.run_steps(4);
h
}
fn history(h: &Harness) -> (usize, usize) {
let d = h.state().session.active().unwrap();
(d.undo.len(), d.redo.len())
}
#[test]
fn undo_and_redo_wait_while_an_undo_group_is_open() {
let mut h = harness();
assert_eq!(history(&h), (1, 1));
let token = h.state_mut().session.group_begin("Long action").unwrap();
h.run_steps(2);
for button in ["Undo", "Redo"] {
assert!(h.get_by_label(button).accesskit_node().is_disabled(), "{button} is off while the group is open");
h.get_by_label(button).click();
h.run_steps(2);
assert!(h.state().message.is_none(), "{button}: no refusal is raised while the group is open");
assert_eq!(history(&h), (1, 1), "{button}: the history is as it was");
}
h.state_mut().session.group_end(token).unwrap();
h.run_steps(2);
assert!(!h.get_by_label("Undo").accesskit_node().is_disabled() && !h.get_by_label("Redo").accesskit_node().is_disabled());
// With the group ended, the buttons work again.
h.get_by_label("Undo").click();
h.run_steps(2);
assert_eq!(history(&h), (0, 2));
h.get_by_label("Redo").click();
h.run_steps(2);
assert_eq!(history(&h), (1, 1));
}