Commands: view.transparencyGrid lists session as what it writes

The grid is view state of each open document, with no undo step, so its schema's x-writes is session rather than the default document. A test pins x-writes for all six View commands, and the level 1 schema hash is updated.
This commit is contained in:
dotCooCoo
2026-11-09 14:37:28 -08:00
parent 2e6ba25598
commit 4ec99c7cd9
2 changed files with 22 additions and 2 deletions
+2 -1
View File
@@ -52,7 +52,8 @@ static TRANSPARENCY_GRID: ParamSchema = ParamSchema::new(
&[Param::new("on", Type::Boolean).default_note("toggle").null_omitted()],
"show the transparency grid behind the active document's artboards (each document has its own setting)",
)
.returns("{on}");
.returns("{on}")
.writes(Writes::Session);
static GLYPH_SNAP: ParamSchema = ParamSchema::new(
&[
+20 -1
View File
@@ -29,7 +29,7 @@ use crate::{EngineError, Result};
pub const API_VERSION: u32 = 1;
/// [`schema_hash`] at each API level, oldest first; the last row is [`API_VERSION`]'s.
pub const SCHEMA_HASHES: &[(u32, u64)] = &[(1, 0x7552_6395_fcbb_1b90)];
pub const SCHEMA_HASHES: &[(u32, u64)] = &[(1, 0xda5b_4c1e_fe4e_c697)];
/// The hash of every built-in command's schema ([`vectorcraft_apischema::hash`]).
pub fn schema_hash() -> u64 {
@@ -312,6 +312,25 @@ mod tests {
assert!(without.get("schema").is_none());
}
/// The listing says what each View command changes when it runs. Only the commands that make an
/// undo step list `document`.
#[test]
fn each_view_command_lists_what_it_writes() {
let listed: Vec<(&str, Value)> = schemas().into_iter().map(|(id, schema)| (id, schema.to_json()["x-writes"].clone())).collect();
let expected = [
("view.capsLock", "session"),
("view.saved.new", "document"),
("view.saved.edit", "document"),
("view.saved.list", "nothing"),
("view.transparencyGrid", "session"),
("view.snapToGlyph.options", "preferences"),
];
for (id, writes) in expected {
let got = listed.iter().find(|(c, _)| *c == id).map(|(_, w)| w.clone());
assert_eq!(got, Some(json!(writes)), "{id}");
}
}
/// Values of type `ty` that pass it.
fn valid(ty: Type) -> BoxedStrategy<Value> {
fn number(min: Option<Bound>, max: Option<Bound>) -> BoxedStrategy<Value> {