Files
vectorcraft/crates/engine/src/tests_transparencygrid.rs
T
bflatasticandClaude Opus 5.5 799b507564 M3.88: Show Transparency Grid is per-document engine view state
view.transparencyGrid {on?} -> {on} is now an engine command (DocState.
transparency_grid; not undoable, doesn't dirty the document), so agents can
turn the grid on headless and each open document keeps its own setting. The
menu item, its Show/Hide label, the shortcut and the Properties panel button
use the same id; the canvas draws the grid for the active document only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 03:11:04 +07:00

29 lines
1.2 KiB
Rust

//! View → Show Transparency Grid is engine view state of each open document (M3.88).
use serde_json::json;
use super::*;
#[test]
fn transparency_grid_is_per_document_view_state() {
let mut s = Session::new();
s.execute("file.new", &json!({})).unwrap();
let grid = |s: &Session| s.doc().unwrap().transparency_grid;
assert!(!grid(&s));
assert_eq!(s.execute("view.transparencyGrid", &json!({})).unwrap(), json!({"on": true}));
assert!(grid(&s));
// Not an edit: nothing to undo, the document stays clean, the journal skips it.
let st = s.doc().unwrap();
assert!(st.history.undo.is_empty() && !st.is_dirty());
// Another document has its own setting.
s.execute("file.new", &json!({})).unwrap();
assert!(!grid(&s));
assert_eq!(s.execute("view.transparencyGrid", &json!({"on": false})).unwrap(), json!({"on": false}));
s.execute("document.activate", &json!({"index": 0})).unwrap();
assert!(grid(&s));
assert_eq!(s.execute("view.transparencyGrid", &json!({})).unwrap(), json!({"on": false}));
assert_eq!(s.execute("view.transparencyGrid", &json!({"on": true})).unwrap(), json!({"on": true}));
s.execute("document.activate", &json!({"index": 1})).unwrap();
assert!(!grid(&s));
}