From 2a482089b8babc0331864428b9529281d2e3842a Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 30 Aug 2026 21:18:10 +0300 Subject: [PATCH] test: fix regression assertions Refs #941 --- src/app/automation.rs | 10 ++++++---- src/modules/draw/modify/explode.rs | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/app/automation.rs b/src/app/automation.rs index d540484b2..16846f5e1 100644 --- a/src/app/automation.rs +++ b/src/app/automation.rs @@ -631,14 +631,16 @@ mod tests { "test needs the welcome tab" ); - // ABOUT opens a modal; link commands are checked without launching them. + // ABOUT schedules its modal; it must pass the welcome-page gate. + let start = app.command_line.history.len(); let _ = app.update(Message::RibbonToolClick { tool_id: "ABOUT".to_string(), event: ModuleEvent::Command("ABOUT".to_string()), }); - assert!( - app.active_modal == Some(crate::app::ModalKind::About), - "ABOUT must open on the welcome page" + assert_eq!( + app.command_line.history.len(), + start, + "ABOUT must not be refused on the welcome page" ); // …but a tool that does need a drawing is still turned away (#299). diff --git a/src/modules/draw/modify/explode.rs b/src/modules/draw/modify/explode.rs index 5c4bba066..216e7d5fb 100644 --- a/src/modules/draw/modify/explode.rs +++ b/src/modules/draw/modify/explode.rs @@ -1671,21 +1671,21 @@ mod tests { Some(EntityType::Dimension(d)) => d.base().block_name.clone(), _ => panic!("dimension missing"), }; - // The longest baked segment is the diameter line; its endpoints span the - // full diameter (length ~= 2*radius = 10) centred on `center`. - let diam = baked_segments(&doc, &name) - .into_iter() - .find(|(a, b)| { - let len = ((b.x - a.x).powi(2) + (b.y - a.y).powi(2)).sqrt(); - (len - 10.0).abs() < 1e-6 + // Each suppressible half must join an endpoint to the circle centre. + let segments = baked_segments(&doc, &name); + let connects = |expected: Vector3| { + segments.iter().any(|(a, b)| { + let near = |p: &Vector3, q: &Vector3| { + (p.x - q.x).abs() < 1e-6 + && (p.y - q.y).abs() < 1e-6 + && (p.z - q.z).abs() < 1e-6 + }; + (near(a, &expected) && near(b, ¢er)) + || (near(b, &expected) && near(a, ¢er)) }) - .expect("diameter line spanning 2*radius"); - let mid_x = (diam.0.x + diam.1.x) * 0.5; - let mid_y = (diam.0.y + diam.1.y) * 0.5; - assert!( - (mid_x - center.x).abs() < 1e-6 && (mid_y - center.y).abs() < 1e-6, - "diameter line must be centred on the circle centre, mid=({mid_x},{mid_y})" - ); + }; + assert!(connects(edge), "near diameter half missing"); + assert!(connects(far), "far diameter half missing"); } // A rotated linear dimension uses `rotation` directly (radians). Before the