From 72e29ce47d17ea2356ebe549191250475dd12684 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 14:06:33 -0800 Subject: [PATCH] Recolor Artwork: the preview test checks the group's new colors saving_a_group_with_a_swatch_that_is_not_a_color_is_refused_while_previewing checked only that the previewed group kept its gradient swatch, so it still passed when the preview left the group's colors as they were. It now sets the red row's new color to black and checks that each color swatch takes its row's new color, in order. --- crates/ui-egui/src/dialogs/recolor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index b3cb557b61..6fe0d2f9be 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -3619,13 +3619,17 @@ mod tests { let undo = undo_len(&app); let d = app.ui.dialog.as_mut().unwrap(); let mut rs = super::rows(d); - rs[0]["to"] = json!("rgb 0 0 0"); + let row_of = |rs: &[Value], hex: &str| rs.iter().position(|r| super::from_colors(r).iter().any(|c| c.to_hex() == hex)).unwrap(); + let red_row = row_of(&rs, "#ff0000"); + rs[red_row]["to"] = json!("rgb 0 0 0"); + let blue_to = super::to_color(&rs[row_of(&rs, "#0000ff")]).unwrap().to_hex(); d.fields.insert("rows".into(), Value::Array(rs)); frame(&mut app, &ctx, 0.1, vec![], 0); assert!(app.session.in_interaction(), "the art previews"); let previewed = app.session.doc().unwrap().doc.swatch_groups.iter().find(|g| g.name == "Mixed").map(|g| g.swatches.clone()); assert_eq!(previewed.as_ref().map(Vec::len), Some(3), "the preview's rewrite of the group keeps its other swatch"); assert_eq!(previewed.and_then(|s| s.last().cloned()), Some(fade_swatch()), "with its paint"); + assert_eq!(group_hex(&app, "Mixed"), Some(vec!["#000000".into(), blue_to]), "each color swatch takes its row's new color"); let refused: Result<(), String> = Err("color group `Mixed` holds swatches that are not colors, which Save Changes can't keep".into()); assert_eq!(act(&mut app, &ctx, 0.2, "save"), refused); crate::dialogs::cancel(&mut app);