mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-10 04:19:48 -06:00
Two leftovers of the merge of origin/main (25881a8e), neither a textual
conflict: `Chart` gained a `data_table` field, which the `push_object`
helper of the model's object test did not set (it is `None`, as in
`insert.chart`); and chart_data_table.rs set the `selected_chart` field
this branch replaced by `selected_object`. The test selects its chart as
a floating object, as the branch's other tests do.
34 lines
1.5 KiB
Rust
34 lines
1.5 KiB
Rust
use egui::accesskit::Role;
|
|
use egui_kittest::kittest::Queryable;
|
|
use gridcraft_engine::Session;
|
|
use gridcraft_engine::model::{ObjKind, ObjRef};
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
fn format_chart_pane_controls_the_engine_data_table() {
|
|
let mut session = Session::new();
|
|
session.new_workbook();
|
|
session.execute("range.setValues", json!({"range": "A1", "values": [["Quarter", "North", "South"], ["Q1", 10, 30], ["Q2", 30, 10]]})).unwrap();
|
|
let id = session.execute("insert.chart", json!({"range": "A1:C3", "type": "column", "at": "E3"})).unwrap()["chart"].as_u64().unwrap() as u32;
|
|
let mut h = crate::support::harness(session, 4);
|
|
h.state_mut().selected_object = Some(ObjRef::new(ObjKind::Chart, id));
|
|
h.state_mut().grid.pane = Some("formatChart".into());
|
|
h.run_steps(2);
|
|
h.get_by_role_and_label(Role::DisclosureTriangle, "Data Table").click();
|
|
h.run_steps(2);
|
|
let table = |h: &crate::common::Harness| h.state().session.active().unwrap().wb.active().unwrap().charts[0].data_table.clone();
|
|
assert_eq!(table(&h), None);
|
|
h.get_by_label("Show Data Table").click();
|
|
h.run_steps(2);
|
|
assert!(table(&h).unwrap().show_keys);
|
|
h.get_by_label("Show Legend Keys").click();
|
|
h.run_steps(2);
|
|
assert!(!table(&h).unwrap().show_keys);
|
|
h.get_by_label("Horizontal Borders").click();
|
|
h.run_steps(2);
|
|
assert!(!table(&h).unwrap().horizontal_border);
|
|
h.get_by_label("Show Data Table").click();
|
|
h.run_steps(2);
|
|
assert_eq!(table(&h), None);
|
|
}
|