From 5ce23377158eb1642d0a9967cafbf81112f11613 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 11 Nov 2026 13:20:45 -0800 Subject: [PATCH] Tests: malformed id cases check and restore isolation mode and the shown mask malformed_ids_are_refused_by_commands_that_default_to_the_selection put back the document, the selection and the undo history after a case that changed them, but not isolation mode or the opacity mask view. If object.isolate entered isolation mode while refusing a bad id, the test did not report it, and the later transparency.editOpacityMask and transparency.viewOpacityMask cases failed with "exit isolation mode first" instead. Each case now also compares isolation mode and the shown mask before and after the command, and puts them back when they changed, so a failure is reported against the command that caused it. --- crates/engine/src/tests.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index ca0501c8f7..c19a0a72d2 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -4245,8 +4245,8 @@ fn given_targets_are_used_as_given_and_range_style_takes_the_selected_type() { /// #785: commands whose `ids` or `id` the shared check doesn't read (it reads `id` where it stands /// for `ids` of one) refuse one that isn't an object id. They don't act on the selection, the -/// current layer or a new object instead, and the document, the selection and the undo history -/// stay as they are. +/// current layer or a new object instead, and the document, the selection, the undo history, +/// isolation mode and the shown opacity mask stay as they are. #[test] fn malformed_ids_are_refused_by_commands_that_default_to_the_selection() { let mut s = session(); @@ -4294,17 +4294,19 @@ fn malformed_ids_are_refused_by_commands_that_default_to_the_selection() { if let Some(p) = p.as_object_mut() { p.insert(key.into(), bad.clone()); } - let (doc, selection, undo) = (s.doc().unwrap().doc.clone(), s.doc().unwrap().selection.clone(), s.doc().unwrap().history.undo.len()); + let st = s.doc().unwrap(); + let (doc, selection, undo, modes) = (st.doc.clone(), st.selection.clone(), st.history.undo.len(), (st.isolation, st.mask_view)); let r = s.execute(cmd, &p); let named = |e: &str| e.contains("object id") || e.contains("step reference") || e.contains(&format!("`{key}` must be")); let refused = r.as_ref().err().map(|e| e.to_string()).is_some_and(|e| named(&e)); - let same = s.doc().unwrap().doc == doc && s.doc().unwrap().selection == selection && s.doc().unwrap().history.undo.len() == undo; + let st = s.doc().unwrap(); + let same = st.doc == doc && st.selection == selection && st.history.undo.len() == undo && (st.isolation, st.mask_view) == modes; if !(refused && same) { wrong.push(format!("{cmd} {p}: {r:?}, document unchanged: {same}")); } if !same { let st = s.doc_mut().unwrap(); - (st.doc, st.selection) = (doc, selection); + (st.doc, st.selection, (st.isolation, st.mask_view)) = (doc, selection, modes); st.history.undo.truncate(undo); } }