Merge pull request #6674 from dotCooCoo/fix/malformed-ids-test-isolation

Tests: malformed id cases check and restore isolation mode and the shown mask
This commit is contained in:
BFlat authored and GitHub committed 2026-11-12 09:23:23 +07:00
commit 66896602d6
1 file changed
+7 -5
+7 -5
View File
@@ -4247,8 +4247,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();
@@ -4296,17 +4296,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);
}
}