The old ids live only in crates/engine/src/legacy_ids.rs (the legacy migration table): find_command maps them, so old scripts, recipes and control calls keep working, and saved shortcuts, recent and pinned commands are migrated on load (designs store no command ids). Parity maps the observed catalog ids to ours through xtask/data/fusion-ids.tsv. The agent rule now reads: our own dotted id, never another product's. Cargo.toml's repository points at github.com/bherbruck/solvecraft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.5 KiB
Rust
72 lines
2.5 KiB
Rust
//! Regression tests: editing a sketch from the Browser or timeline can always be left again.
|
|
|
|
use crate::{Services, SolveApp};
|
|
use solvecraft_engine::Session;
|
|
use solvecraft_engine::doc::FeatureKind;
|
|
|
|
fn sample_app() -> SolveApp {
|
|
let mut s = Session::default();
|
|
s.run_script(&solvecraft_engine::sample::script()).unwrap();
|
|
SolveApp::new(s, Services::default())
|
|
}
|
|
|
|
fn first_sketch(app: &SolveApp) -> u64 {
|
|
app.session.doc.features.iter().find(|f| matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.id).unwrap()
|
|
}
|
|
|
|
#[test]
|
|
fn edit_sketch_rolls_back_and_finish_restores() {
|
|
let mut app = sample_app();
|
|
let marker = app.session.doc.marker;
|
|
let id = first_sketch(&app);
|
|
app.edit_sketch(id);
|
|
assert_eq!(app.session.active_sketch, Some(id));
|
|
let idx = app.session.doc.feature_index(id).unwrap();
|
|
assert_eq!(app.session.doc.marker, Some(idx + 1), "later features are rolled back");
|
|
app.finish_sketch();
|
|
assert_eq!(app.session.active_sketch, None);
|
|
assert_eq!(app.session.doc.marker, marker, "marker restored");
|
|
}
|
|
|
|
#[test]
|
|
fn editing_twice_does_not_nest() {
|
|
let mut app = sample_app();
|
|
let marker = app.session.doc.marker;
|
|
let id = first_sketch(&app);
|
|
app.edit_sketch(id);
|
|
app.edit_sketch(id);
|
|
app.edit_feature(id);
|
|
app.finish_sketch();
|
|
assert_eq!(app.session.active_sketch, None);
|
|
assert_eq!(app.session.doc.marker, marker);
|
|
}
|
|
|
|
#[test]
|
|
fn editing_another_sketch_switches_cleanly() {
|
|
let mut app = sample_app();
|
|
let marker = app.session.doc.marker;
|
|
let ids: Vec<u64> = app.session.doc.features.iter().filter(|f| matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.id).collect();
|
|
app.edit_sketch(ids[0]);
|
|
app.edit_sketch(ids[1]);
|
|
assert_eq!(app.session.active_sketch, Some(ids[1]));
|
|
app.finish_sketch();
|
|
assert_eq!(app.session.active_sketch, None);
|
|
assert_eq!(app.session.doc.marker, marker);
|
|
}
|
|
|
|
#[test]
|
|
fn toolbar_finish_and_other_feature_edit_leave_the_sketch() {
|
|
let mut app = sample_app();
|
|
let marker = app.session.doc.marker;
|
|
let id = first_sketch(&app);
|
|
app.edit_sketch(id);
|
|
app.start("sketch.finish");
|
|
assert_eq!(app.session.active_sketch, None);
|
|
assert_eq!(app.session.doc.marker, marker);
|
|
// Double-clicking a solid feature while sketching finishes the sketch first.
|
|
app.edit_sketch(id);
|
|
let extrude = app.session.doc.features.iter().find(|f| !matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.id).unwrap();
|
|
app.edit_feature(extrude);
|
|
assert_eq!(app.session.active_sketch, None);
|
|
}
|