Phase 5: fix broken unit tests; cargo test --lib green again

The lib unit tests had gone stale (time values became newtypes) and no longer
compiled. Updated the test code to the current API and fixed the few real issues
the now-running tests surfaced.

Test-only:
- Wrap raw f64 time literals in Beats(...) where the API now takes Beats
  (automation.rs); pass &TempoMap / Beats where signatures changed (clip.rs,
  effect_layer.rs).
- shape.rs: assert the documented no-fill default (fill_color None) instead of Some.
- add_clip_instance / trim_clip_instances tests: register a vector clip with the
  test's clip_id so the action's get_clip_duration lookup succeeds.

Production fix (delete_folder.rs):
- DeleteFolderAction(MoveToParent) reparented child subfolders to the deleted
  folder's parent but never restored them on undo, orphaning them. Track the moved
  subfolder ids and restore their parent on rollback.

Result: daw-backend lib 17 passed; lightningbeam-core lib 264 passed.
This commit is contained in:
Skyler Lehmkuhl
2026-06-19 16:45:23 -04:00
parent 4ad95e6755
commit 6d386a884e
7 changed files with 66 additions and 37 deletions
@@ -316,8 +316,11 @@ mod tests {
let layer_id = layer.layer.id;
document.root_mut().add_child(AnyLayer::Vector(layer));
// Create a clip instance (using a fake clip_id since we're just testing the action)
// Register a vector clip so get_clip_duration succeeds
let clip_id = Uuid::new_v4();
let clip = crate::clip::VectorClip::with_id(clip_id, "Test Clip", 100.0, 100.0, 5.0);
document.vector_clips.insert(clip_id, clip);
let clip_instance = ClipInstance::new(clip_id);
let instance_id = clip_instance.id;
@@ -37,6 +37,9 @@ pub struct DeleteFolderAction {
/// Asset IDs that were deleted (for DeleteRecursive strategy)
deleted_asset_ids: Vec<Uuid>,
/// Subfolder IDs that were reparented to the deleted folder's parent (for MoveToParent strategy)
moved_subfolder_ids: Vec<Uuid>,
}
impl DeleteFolderAction {
@@ -55,6 +58,7 @@ impl DeleteFolderAction {
removed_folders: Vec::new(),
moved_asset_ids: Vec::new(),
deleted_asset_ids: Vec::new(),
moved_subfolder_ids: Vec::new(),
}
}
}
@@ -130,6 +134,7 @@ impl Action for DeleteFolderAction {
for subfolder_id in subfolder_ids {
if let Some(subfolder) = tree.folders.get_mut(&subfolder_id) {
subfolder.parent_id = parent_id;
self.moved_subfolder_ids.push(subfolder_id);
}
}
}
@@ -259,6 +264,13 @@ impl Action for DeleteFolderAction {
tree.add_folder(folder.clone());
}
// Restore reparented subfolders back under the deleted folder
for subfolder_id in &self.moved_subfolder_ids {
if let Some(subfolder) = tree.folders.get_mut(subfolder_id) {
subfolder.parent_id = Some(self.folder_id);
}
}
match self.strategy {
DeleteStrategy::MoveToParent => {
// Restore folder_id for moved assets
@@ -312,6 +324,7 @@ impl Action for DeleteFolderAction {
self.removed_folders.clear();
self.moved_asset_ids.clear();
self.deleted_asset_ids.clear();
self.moved_subfolder_ids.clear();
Ok(())
}
@@ -547,6 +547,8 @@ mod tests {
// Create a clip ID (ClipInstance references clip by ID)
let clip_id = uuid::Uuid::new_v4();
let clip = crate::clip::VectorClip::with_id(clip_id, "Test Clip", 100.0, 100.0, 10.0);
document.vector_clips.insert(clip_id, clip);
let mut vector_layer = VectorLayer::new("Layer 1");
@@ -607,6 +609,8 @@ mod tests {
// Create a clip ID (ClipInstance references clip by ID)
let clip_id = uuid::Uuid::new_v4();
let clip = crate::clip::VectorClip::with_id(clip_id, "Test Clip", 100.0, 100.0, 10.0);
document.vector_clips.insert(clip_id, clip);
let mut vector_layer = VectorLayer::new("Layer 1");