@@ -876,8 +876,12 @@ unit "unit_to_be_untouched" {
876876 fromWorktree := worktreePair .FromWorktree .Path
877877 toWorktree := worktreePair .ToWorktree .Path
878878
879- // All paths are worktree paths - no translation needed
880- assert .ElementsMatch (t , components , component.Components {
879+ // All paths are worktree paths - no translation needed.
880+ //
881+ // NOTE: Discovery may attach additional state (e.g., partially-parsed configs) that isn't relevant
882+ // to this test's intent. We normalize the discovered components by clearing that state so a simple
883+ // deep comparison remains stable over time.
884+ expected := component.Components {
881885 // Stacks
882886 component .NewStack (filepath .Join (toWorktree , stackToBeAddedRel )).WithDiscoveryContext (
883887 & component.DiscoveryContext {
@@ -976,7 +980,22 @@ unit "unit_to_be_untouched" {
976980 Args : []string {"-destroy" },
977981 },
978982 ),
979- })
983+ }
984+
985+ for _ , c := range components {
986+ switch v := c .(type ) {
987+ case * component.Unit :
988+ // Normalize fields that may be populated during discovery, but are irrelevant to this test's assertions.
989+ v .StoreConfig (nil )
990+ // Normalize slices so deep equality is stable (nil vs empty differs in reflect.DeepEqual).
991+ v .SetReading ()
992+ case * component.Stack :
993+ v .StoreConfig (nil )
994+ v .SetReading ()
995+ }
996+ }
997+
998+ assert .ElementsMatch (t , components , expected )
980999}
9811000
9821001// TestWorktreeDiscoveryDetectsFileRename verifies that renaming a file within a unit
0 commit comments