From da0d3357c8f3e334941f83d893aa96ea6629b685 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 16:03:05 -0800 Subject: [PATCH 1/4] Exercise Simplify dialog preview and outline after a drawing switch --- crates/ui-egui/src/dialogs/path_ops.rs | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs index 64176e93ac..343a2d9e19 100644 --- a/crates/ui-egui/src/dialogs/path_ops.rs +++ b/crates/ui-egui/src/dialogs/path_ops.rs @@ -339,6 +339,81 @@ pub(crate) fn open_simplify(app: &mut VectorcraftApp, tolerance: f64) { open_dialog(app, PathOp::Simplify, simplify_dialog(tolerance), None); } + +#[cfg(test)] +mod simplify_options_tests { + use super::*; + use crate::dialogs::tests::{app, cancel, confirm, frame, set}; + + fn dense_path(app: &mut VectorcraftApp, top: f64) -> u64 { + let anchors: Vec<_> = (0..20).map(|i| json!({"x": 30 + i * 15, "y": top + (i % 2) as f64 * 0.1})).collect(); + let id = app.run("path.create", json!({"anchors": anchors})).unwrap()["id"].as_u64().unwrap(); + app.run("select.anchors", json!({"id": id, "anchors": [[0, 19]]})).unwrap(); + id + } + + fn drawings() -> (VectorcraftApp, NodeId) { + let mut app = app(); + let id = dense_path(&mut app, 50.0); + app.run("file.new", json!({"width": 500, "height": 400})).unwrap(); + let other = dense_path(&mut app, 180.0); + assert_eq!(id, other, "the two drawings use the same path ID"); + app.run("document.activate", json!({"index": 0})).unwrap(); + (app, NodeId(id)) + } + + fn more_options(app: &mut VectorcraftApp) { + crate::menus::invoke(app, "object.path.simplify", json!({})); + crate::dialogs::simplify_slider::more_options(app).unwrap(); + } + + #[test] + fn simplify_options_skip_the_other_drawings_artwork() { + for from_slider in [false, true] { + let (mut app, _) = drawings(); + if from_slider { + more_options(&mut app); + } else { + let ctx = app.ui_ctx.clone().unwrap(); + set_saved_value(&ctx, &SIMPLIFY_KEY, Some(simplify_dialog(DEFAULT_TOLERANCE))); + crate::menus::invoke(&mut app, "object.path.simplify", json!({})); + } + set(&mut app, "preview", json!(true)); + app.run("document.activate", json!({"index": 1})).unwrap(); + let other = app.session.doc().unwrap().doc.clone(); + let undo = app.session.doc().unwrap().history.undo.len(); + + frame(&mut app, vec![]); + + assert!(app.session.doc().unwrap().doc == other, "Simplify preview leaves the other drawing unchanged"); + assert!(!app.session.in_interaction()); + assert!(!confirm(&mut app), "the draft stays with the opening drawing"); + assert_eq!(app.session.doc().unwrap().history.undo.len(), undo); + app.run("document.activate", json!({"index": 0})).unwrap(); + frame(&mut app, vec![]); + assert!(app.session.in_interaction()); + assert!(confirm(&mut app)); + } + } + + #[test] + fn simplify_options_never_outline_another_drawings_same_id() { + let (mut app, id) = drawings(); + more_options(&mut app); + set(&mut app, "showOriginal", json!(true)); + set(&mut app, "preview", json!(true)); + frame(&mut app, vec![]); + assert_eq!(original_paths(&app).iter().map(|(path, _)| *path).collect::>(), [id]); + + app.run("document.activate", json!({"index": 1})).unwrap(); + app.session.begin_interaction("Other edit").unwrap(); + + assert!(original_paths(&app).is_empty(), "Show Original leaves the other drawing's canvas alone"); + assert!(cancel(&mut app)); + assert!(app.session.in_interaction(), "Cancel leaves the other drawing's edit in progress"); + } +} + fn open_dialog(app: &mut VectorcraftApp, op: PathOp, fields: DialogFields, remember: Option) { let Some(ctx) = app.ui_ctx.clone() else { app.status("There is no window to show the dialog in."); From 65b52aed876c7ca1a1ab5e6b9675ba6be07abc97 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 16:07:21 -0800 Subject: [PATCH 2/4] Exercise Offset Path preview in a second drawing --- crates/ui-egui/src/dialogs/path_ops.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs index 343a2d9e19..37ea857dd6 100644 --- a/crates/ui-egui/src/dialogs/path_ops.rs +++ b/crates/ui-egui/src/dialogs/path_ops.rs @@ -339,9 +339,8 @@ pub(crate) fn open_simplify(app: &mut VectorcraftApp, tolerance: f64) { open_dialog(app, PathOp::Simplify, simplify_dialog(tolerance), None); } - #[cfg(test)] -mod simplify_options_tests { +mod preview_document_tests { use super::*; use crate::dialogs::tests::{app, cancel, confirm, frame, set}; @@ -412,6 +411,28 @@ mod simplify_options_tests { assert!(cancel(&mut app)); assert!(app.session.in_interaction(), "Cancel leaves the other drawing's edit in progress"); } + + #[test] + fn offset_path_skips_the_other_drawings_artwork() { + let mut app = app(); + app.run("shape.rectangle", json!({"x": 10, "y": 20, "width": 100, "height": 60})).unwrap(); + app.run("select.all", json!({})).unwrap(); + crate::menus::invoke(&mut app, "object.path.offsetPath", json!({})); + set(&mut app, "offset", json!(12.0)); + set(&mut app, "preview", json!(true)); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 140, "y": 30, "width": 80, "height": 100})).unwrap(); + app.run("select.all", json!({})).unwrap(); + let other = app.session.doc().unwrap().doc.clone(); + + frame(&mut app, vec![]); + + assert!(app.session.doc().unwrap().doc == other, "Offset Path preview leaves the other drawing unchanged"); + assert!(!confirm(&mut app)); + app.run("document.activate", json!({"index": 0})).unwrap(); + assert!(confirm(&mut app)); + assert_eq!(app.session.doc().unwrap().doc.layers[0].children().unwrap().len(), 2); + } } fn open_dialog(app: &mut VectorcraftApp, op: PathOp, fields: DialogFields, remember: Option) { From 78ebac9eab9928bc770609cf18a8c2f123c4872b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 16:10:46 -0800 Subject: [PATCH 3/4] Keep Simplify and Offset Path previews in the opening drawing --- crates/ui-egui/src/dialogs/path_ops.rs | 115 +++++++++++++++++++------ 1 file changed, 90 insertions(+), 25 deletions(-) diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs index 37ea857dd6..7351a70863 100644 --- a/crates/ui-egui/src/dialogs/path_ops.rs +++ b/crates/ui-egui/src/dialogs/path_ops.rs @@ -3,6 +3,8 @@ //! Every dialog is a held parameter dialog: its OK is the closure given to `open_held`, a refusal keeps it open with //! the reason, and [`pump`] only runs the live preview of the kinds that have one. +use std::sync::{Arc, Weak}; + // PLAN: the framework import paths below are assumed from the contract rows (craft-ui-patterns re-exports contract and // runtime; the form-dialog items live under `patterns::form_dialogs`; `Field` and `NumberField` under craft-ui-widgets). use craft::behavior::ColumnWidth; @@ -19,7 +21,7 @@ use craft::ui::runtime::memory::{SaveKey, saved_value, set_saved_value}; use craft::ui::text::{NumberField, NumberOutput}; use craft::ui::value_drag::SliderScale; use serde_json::{Map, Value, json}; -use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_doc::{NodeId, NodeKind, Selection}; use vectorcraft_geom::PathData; use super::form; @@ -111,7 +113,10 @@ impl PathOp { pub(crate) struct Open { op: PathOp, id: DialogId, + document: u64, preview: LivePreview, + /// A distinct selection snapshot identifies the interaction that ran this preview. + preview_selection: Option>, /// The params the preview last answered for. last: Value, /// Simplify: the paths the preview ran on. @@ -309,6 +314,36 @@ fn take_open(app: &mut VectorcraftApp, op: PathOp) -> Option { Some(app.object_dialogs.path.remove(i)) } +impl Open { + fn owns_preview(&self, app: &VectorcraftApp) -> bool { + let Some(selection) = &self.preview_selection else { return false }; + app.session.active().is_some_and(|state| { + state.uid == self.document + && state.interaction.as_ref().is_some_and(|interaction| selection.as_ptr() == Arc::as_ptr(&interaction.selection)) + }) + } + + fn cancel(self, app: &mut VectorcraftApp) { + if self.owns_preview(app) { + self.preview.cancel(app); + } + } + + fn commit(&mut self, app: &mut VectorcraftApp, cmd: &str, params: Value) -> Result<(), String> { + if app.session.active().is_none_or(|state| state.uid != self.document) { + return Err(tl!("Return to the document where this dialog opened.").to_owned()); + } + if app.session.in_interaction() && !self.owns_preview(app) { + return Err(tl!("Finish the active edit before confirming.").to_owned()); + } + self.preview_selection = None; + self.last = Value::Null; + self.original.clear(); + self.shown = false; + std::mem::take(&mut self.preview).commit(app, cmd, params).map(drop) + } +} + /// Whether Object › Path › Simplify opens its dialog (the user kept its settings) instead of the slider. pub(crate) fn retained_simplify(app: &VectorcraftApp) -> bool { let Some(ctx) = app.ui_ctx.as_ref() else { return false }; @@ -440,6 +475,11 @@ fn open_dialog(app: &mut VectorcraftApp, op: PathOp, fields: DialogFields, remem app.status("There is no window to show the dialog in."); return; }; + let document = app.session.active().map(|state| state.uid); + if op.previews() && document.is_none() { + app.status("Open a document before editing paths."); + return; + } let lengths = crate::canvas::general_lengths(app); let opening = op.opening(); let key = op.key(); @@ -455,17 +495,11 @@ fn open_dialog(app: &mut VectorcraftApp, op: PathOp, fields: DialogFields, remem }); let ok = move |app: &mut VectorcraftApp, result: &craft::ui::patterns::form_dialogs::ParamResult| { let (cmd, params) = command(op, &result.fields); - match take_open(app, op) { - Some(record) => { - let id = record.id; - record.preview.commit(app, cmd, params).map(drop).inspect_err(|_| { - // The dialog stays open on the refusal, so it keeps previewing. - app.object_dialogs.path.push(Open { op, id, preview: LivePreview::default(), last: Value::Null, original: vec![], shown: false }); - })?; - } - None => { - app.run(cmd, params).map(drop)?; - } + if op.previews() { + let Some(mut record) = take_open(app, op) else { return Err(tl!("The path dialog is closed.").to_owned()) }; + record.commit(app, cmd, params).inspect_err(|_| app.object_dialogs.path.push(record))?; + } else { + app.run(cmd, params).map(drop)?; } match op { PathOp::Simplify => { @@ -479,24 +513,40 @@ fn open_dialog(app: &mut VectorcraftApp, op: PathOp, fields: DialogFields, remem Ok(()) }; if let Some(old) = take_open(app, op) { - old.preview.cancel(app); + old.cancel(app); } let id = if op.previews() { let cancel = Box::new(move |app: &mut VectorcraftApp| { + // A cancelled opening can leave a replacement with the same dialog ID. + let id = app.object_dialogs.path.iter().find(|record| record.op == op).map(|record| record.id); + if let Some(id) = id + && app.dialogs().is_some_and(|dialogs| dialogs.with(|host| host.get_by_id::(id).is_some())) + { + return; + } if let Some(record) = take_open(app, op) { - record.preview.cancel(app); + record.cancel(app); } }); open_held_with(app, dialog, ok, HeldOptions { parent: None, cancel: Some(cancel) }) } else { open_held(app, dialog, ok) }; - match id { - Some(id) if op.previews() => { - app.object_dialogs.path.push(Open { op, id, preview: LivePreview::default(), last: Value::Null, original: vec![], shown: false }) + match (id, document) { + (Some(id), Some(document)) if op.previews() => { + app.object_dialogs.path.push(Open { + op, + id, + document, + preview: LivePreview::default(), + preview_selection: None, + last: Value::Null, + original: vec![], + shown: false, + }); } - Some(_) => {} - None => app.status("There is no window to show the dialog in."), + (Some(_), _) => {} + (None, _) => app.status("There is no window to show the dialog in."), } } @@ -568,6 +618,17 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { fn step(app: &mut VectorcraftApp, r: &mut Open) { let Some((on, fields)) = dialog_state(app, r.id) else { return }; + let Some(state) = app.session.active().filter(|state| state.uid == r.document) else { return }; + if !r.owns_preview(app) { + r.preview = LivePreview::default(); + r.preview_selection = None; + r.last = Value::Null; + r.original.clear(); + r.shown = false; + if state.interaction.is_some() { + return; + } + } let (cmd, params) = command(r.op, &fields); let stale = !on || r.last != params; if stale { @@ -575,13 +636,17 @@ fn step(app: &mut VectorcraftApp, r: &mut Open) { } if !on { r.last = Value::Null; + r.preview_selection = None; } let mut counts = stale.then_some(None); - if let Some(Ok(answer)) = r.preview.run(app, on, r.op.title(), cmd, ¶ms) { - r.last = params; - if r.op == PathOp::Simplify { - r.original = answer["ids"].as_array().into_iter().flatten().filter_map(|id| id.as_u64().map(NodeId)).collect(); - counts = Some(Some(json!({"before": answer["before"], "after": answer["after"]}))); + if let Some(answer) = r.preview.run(app, on, r.op.title(), cmd, ¶ms) { + r.preview_selection = app.session.active().and_then(|state| state.interaction.as_ref()).map(|it| Arc::downgrade(&it.selection)); + if let Ok(answer) = answer { + r.last = params; + if r.op == PathOp::Simplify { + r.original = answer["ids"].as_array().into_iter().flatten().filter_map(|id| id.as_u64().map(NodeId)).collect(); + counts = Some(Some(json!({"before": answer["before"], "after": answer["after"]}))); + } } } r.shown = on && fields.bool("showOriginal").unwrap_or(false); @@ -602,7 +667,7 @@ fn step(app: &mut VectorcraftApp, r: &mut Open) { /// on, with its id, as it was before the preview (from the interaction's snapshot). Empty /// otherwise. pub(crate) fn original_paths(app: &VectorcraftApp) -> Vec<(NodeId, &PathData)> { - let Some(r) = app.object_dialogs.path.iter().find(|r| r.op == PathOp::Simplify && r.shown) else { return vec![] }; + let Some(r) = app.object_dialogs.path.iter().find(|r| r.op == PathOp::Simplify && r.shown && r.owns_preview(app)) else { return vec![] }; let Some(it) = app.session.active().and_then(|st| st.interaction.as_ref()) else { return vec![] }; r.original .iter() From 00d41a7c7ce4e05dbc10abfdd2c1bb793c0ce184 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 16:47:16 -0800 Subject: [PATCH 4/4] Place Path Ops regression tests after the implementation --- crates/ui-egui/src/dialogs/path_ops.rs | 192 ++++++++++++------------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs index 7351a70863..fc99b2c20c 100644 --- a/crates/ui-egui/src/dialogs/path_ops.rs +++ b/crates/ui-egui/src/dialogs/path_ops.rs @@ -374,102 +374,6 @@ pub(crate) fn open_simplify(app: &mut VectorcraftApp, tolerance: f64) { open_dialog(app, PathOp::Simplify, simplify_dialog(tolerance), None); } -#[cfg(test)] -mod preview_document_tests { - use super::*; - use crate::dialogs::tests::{app, cancel, confirm, frame, set}; - - fn dense_path(app: &mut VectorcraftApp, top: f64) -> u64 { - let anchors: Vec<_> = (0..20).map(|i| json!({"x": 30 + i * 15, "y": top + (i % 2) as f64 * 0.1})).collect(); - let id = app.run("path.create", json!({"anchors": anchors})).unwrap()["id"].as_u64().unwrap(); - app.run("select.anchors", json!({"id": id, "anchors": [[0, 19]]})).unwrap(); - id - } - - fn drawings() -> (VectorcraftApp, NodeId) { - let mut app = app(); - let id = dense_path(&mut app, 50.0); - app.run("file.new", json!({"width": 500, "height": 400})).unwrap(); - let other = dense_path(&mut app, 180.0); - assert_eq!(id, other, "the two drawings use the same path ID"); - app.run("document.activate", json!({"index": 0})).unwrap(); - (app, NodeId(id)) - } - - fn more_options(app: &mut VectorcraftApp) { - crate::menus::invoke(app, "object.path.simplify", json!({})); - crate::dialogs::simplify_slider::more_options(app).unwrap(); - } - - #[test] - fn simplify_options_skip_the_other_drawings_artwork() { - for from_slider in [false, true] { - let (mut app, _) = drawings(); - if from_slider { - more_options(&mut app); - } else { - let ctx = app.ui_ctx.clone().unwrap(); - set_saved_value(&ctx, &SIMPLIFY_KEY, Some(simplify_dialog(DEFAULT_TOLERANCE))); - crate::menus::invoke(&mut app, "object.path.simplify", json!({})); - } - set(&mut app, "preview", json!(true)); - app.run("document.activate", json!({"index": 1})).unwrap(); - let other = app.session.doc().unwrap().doc.clone(); - let undo = app.session.doc().unwrap().history.undo.len(); - - frame(&mut app, vec![]); - - assert!(app.session.doc().unwrap().doc == other, "Simplify preview leaves the other drawing unchanged"); - assert!(!app.session.in_interaction()); - assert!(!confirm(&mut app), "the draft stays with the opening drawing"); - assert_eq!(app.session.doc().unwrap().history.undo.len(), undo); - app.run("document.activate", json!({"index": 0})).unwrap(); - frame(&mut app, vec![]); - assert!(app.session.in_interaction()); - assert!(confirm(&mut app)); - } - } - - #[test] - fn simplify_options_never_outline_another_drawings_same_id() { - let (mut app, id) = drawings(); - more_options(&mut app); - set(&mut app, "showOriginal", json!(true)); - set(&mut app, "preview", json!(true)); - frame(&mut app, vec![]); - assert_eq!(original_paths(&app).iter().map(|(path, _)| *path).collect::>(), [id]); - - app.run("document.activate", json!({"index": 1})).unwrap(); - app.session.begin_interaction("Other edit").unwrap(); - - assert!(original_paths(&app).is_empty(), "Show Original leaves the other drawing's canvas alone"); - assert!(cancel(&mut app)); - assert!(app.session.in_interaction(), "Cancel leaves the other drawing's edit in progress"); - } - - #[test] - fn offset_path_skips_the_other_drawings_artwork() { - let mut app = app(); - app.run("shape.rectangle", json!({"x": 10, "y": 20, "width": 100, "height": 60})).unwrap(); - app.run("select.all", json!({})).unwrap(); - crate::menus::invoke(&mut app, "object.path.offsetPath", json!({})); - set(&mut app, "offset", json!(12.0)); - set(&mut app, "preview", json!(true)); - app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); - app.run("shape.rectangle", json!({"x": 140, "y": 30, "width": 80, "height": 100})).unwrap(); - app.run("select.all", json!({})).unwrap(); - let other = app.session.doc().unwrap().doc.clone(); - - frame(&mut app, vec![]); - - assert!(app.session.doc().unwrap().doc == other, "Offset Path preview leaves the other drawing unchanged"); - assert!(!confirm(&mut app)); - app.run("document.activate", json!({"index": 0})).unwrap(); - assert!(confirm(&mut app)); - assert_eq!(app.session.doc().unwrap().doc.layers[0].children().unwrap().len(), 2); - } -} - fn open_dialog(app: &mut VectorcraftApp, op: PathOp, fields: DialogFields, remember: Option) { let Some(ctx) = app.ui_ctx.clone() else { app.status("There is no window to show the dialog in."); @@ -677,3 +581,99 @@ pub(crate) fn original_paths(app: &VectorcraftApp) -> Vec<(NodeId, &PathData)> { }) .collect() } + +#[cfg(test)] +mod preview_document_tests { + use super::*; + use crate::dialogs::tests::{app, cancel, confirm, frame, set}; + + fn dense_path(app: &mut VectorcraftApp, top: f64) -> u64 { + let anchors: Vec<_> = (0..20).map(|i| json!({"x": 30 + i * 15, "y": top + (i % 2) as f64 * 0.1})).collect(); + let id = app.run("path.create", json!({"anchors": anchors})).unwrap()["id"].as_u64().unwrap(); + app.run("select.anchors", json!({"id": id, "anchors": [[0, 19]]})).unwrap(); + id + } + + fn drawings() -> (VectorcraftApp, NodeId) { + let mut app = app(); + let id = dense_path(&mut app, 50.0); + app.run("file.new", json!({"width": 500, "height": 400})).unwrap(); + let other = dense_path(&mut app, 180.0); + assert_eq!(id, other, "the two drawings use the same path ID"); + app.run("document.activate", json!({"index": 0})).unwrap(); + (app, NodeId(id)) + } + + fn more_options(app: &mut VectorcraftApp) { + crate::menus::invoke(app, "object.path.simplify", json!({})); + crate::dialogs::simplify_slider::more_options(app).unwrap(); + } + + #[test] + fn simplify_options_skip_the_other_drawings_artwork() { + for from_slider in [false, true] { + let (mut app, _) = drawings(); + if from_slider { + more_options(&mut app); + } else { + let ctx = app.ui_ctx.clone().unwrap(); + set_saved_value(&ctx, &SIMPLIFY_KEY, Some(simplify_dialog(DEFAULT_TOLERANCE))); + crate::menus::invoke(&mut app, "object.path.simplify", json!({})); + } + set(&mut app, "preview", json!(true)); + app.run("document.activate", json!({"index": 1})).unwrap(); + let other = app.session.doc().unwrap().doc.clone(); + let undo = app.session.doc().unwrap().history.undo.len(); + + frame(&mut app, vec![]); + + assert!(app.session.doc().unwrap().doc == other, "Simplify preview leaves the other drawing unchanged"); + assert!(!app.session.in_interaction()); + assert!(!confirm(&mut app), "the draft stays with the opening drawing"); + assert_eq!(app.session.doc().unwrap().history.undo.len(), undo); + app.run("document.activate", json!({"index": 0})).unwrap(); + frame(&mut app, vec![]); + assert!(app.session.in_interaction()); + assert!(confirm(&mut app)); + } + } + + #[test] + fn simplify_options_never_outline_another_drawings_same_id() { + let (mut app, id) = drawings(); + more_options(&mut app); + set(&mut app, "showOriginal", json!(true)); + set(&mut app, "preview", json!(true)); + frame(&mut app, vec![]); + assert_eq!(original_paths(&app).iter().map(|(path, _)| *path).collect::>(), [id]); + + app.run("document.activate", json!({"index": 1})).unwrap(); + app.session.begin_interaction("Other edit").unwrap(); + + assert!(original_paths(&app).is_empty(), "Show Original leaves the other drawing's canvas alone"); + assert!(cancel(&mut app)); + assert!(app.session.in_interaction(), "Cancel leaves the other drawing's edit in progress"); + } + + #[test] + fn offset_path_skips_the_other_drawings_artwork() { + let mut app = app(); + app.run("shape.rectangle", json!({"x": 10, "y": 20, "width": 100, "height": 60})).unwrap(); + app.run("select.all", json!({})).unwrap(); + crate::menus::invoke(&mut app, "object.path.offsetPath", json!({})); + set(&mut app, "offset", json!(12.0)); + set(&mut app, "preview", json!(true)); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 140, "y": 30, "width": 80, "height": 100})).unwrap(); + app.run("select.all", json!({})).unwrap(); + let other = app.session.doc().unwrap().doc.clone(); + + frame(&mut app, vec![]); + + assert!(app.session.doc().unwrap().doc == other, "Offset Path preview leaves the other drawing unchanged"); + assert!(!confirm(&mut app)); + app.run("document.activate", json!({"index": 0})).unwrap(); + assert!(confirm(&mut app)); + assert_eq!(app.session.doc().unwrap().doc.layers[0].children().unwrap().len(), 2); + } +}