Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Refactor: Consolidate integration tests for better organization

Maximilian Roos7d64cdb05132
diff --git a/tests/integration_tests/column_alignment.rs b/tests/integration_tests/column_alignment.rs
deleted file mode 100644
index 3513bf000..000000000
--- a/tests/integration_tests/column_alignment.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-use crate::common::TestRepo;
-use insta::Settings;
-use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
-use std::process::Command;
-
-/// Helper for testing with specific terminal width
-fn snapshot_list_with_width(test_name: &str, repo: &TestRepo, width: usize) {
- let mut settings = Settings::clone_current();
- settings.set_snapshot_path("../snapshots");
-
- // Normalize paths
- settings.add_filter(repo.root_path().to_str().unwrap(), "[REPO]");
- for (name, path) in &repo.worktrees {
- settings.add_filter(
- path.to_str().unwrap(),
- format!("[WORKTREE_{}]", name.to_uppercase().replace('-', "_")),
- );
- }
-
- // Normalize git SHAs
- settings.add_filter(r"\b[0-9a-f]{7,40}\b", "[SHA] ");
- settings.add_filter(r"\\", "/");
-
- settings.bind(|| {
- let mut cmd = Command::new(get_cargo_bin("wt"));
- repo.clean_cli_env(&mut cmd);
- cmd.arg("list")
- .current_dir(repo.root_path())
- .env("COLUMNS", width.to_string());
- assert_cmd_snapshot!(test_name, cmd);
- });
-}
-
-#[test]
-fn test_column_alignment_varying_diff_widths() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
-
- // Create worktrees with varying diff sizes to test alignment
- repo.add_worktree("feature-small", "feature-small");
- repo.add_worktree("feature-medium", "feature-medium");
- repo.add_worktree("feature-large", "feature-large");
-
- // Add files to create diffs with different digit counts
- let small_path = repo.worktrees.get("feature-small").unwrap();
- for i in 0..5 {
- std::fs::write(small_path.join(format!("file{}.txt", i)), "content").unwrap();
- }
-
- let medium_path = repo.worktrees.get("feature-medium").unwrap();
- for i in 0..50 {
- std::fs::write(medium_path.join(format!("file{}.txt", i)), "content").unwrap();
- }
-
- let large_path = repo.worktrees.get("feature-large").unwrap();
- for i in 0..500 {
- std::fs::write(large_path.join(format!("file{}.txt", i)), "content").unwrap();
- }
-
- // Test at a width where WT +/- column is visible
- snapshot_list_with_width("alignment_varying_diffs", &repo, 180);
-}
-
-#[test]
-fn test_column_alignment_with_empty_diffs() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
-
- // Mix of worktrees with and without diffs
- repo.add_worktree("no-changes", "no-changes");
-
- repo.add_worktree("with-changes", "with-changes");
- let changes_path = repo.worktrees.get("with-changes").unwrap();
- std::fs::write(changes_path.join("file.txt"), "content").unwrap();
-
- repo.add_worktree("also-no-changes", "also-no-changes");
-
- // Path column should align even when some rows have diffs and others don't
- snapshot_list_with_width("alignment_empty_diffs", &repo, 180);
-}
-
-#[test]
-fn test_column_alignment_extreme_diff_sizes() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
-
- // Create worktrees with extreme diff size differences
- repo.add_worktree("tiny", "tiny");
- repo.add_worktree("huge", "huge");
-
- let tiny_path = repo.worktrees.get("tiny").unwrap();
- std::fs::write(tiny_path.join("file.txt"), "x").unwrap();
-
- let huge_path = repo.worktrees.get("huge").unwrap();
- for i in 0..9999 {
- std::fs::write(huge_path.join(format!("file{}.txt", i)), "content").unwrap();
- }
-
- snapshot_list_with_width("alignment_extreme_diffs", &repo, 180);
-}
diff --git a/tests/integration_tests/column_alignment_verification.rs b/tests/integration_tests/column_alignment_verification.rs
index abd830335..d409be642 100644
--- a/tests/integration_tests/column_alignment_verification.rs
+++ b/tests/integration_tests/column_alignment_verification.rs
@@ -1,3 +1,16 @@
+//! Column Alignment Verification Tests
+//!
+//! NOTE: These tests may appear duplicative with snapshot tests, but they serve a critical purpose.
+//! LLMs are poor at assessing precise positional/alignment values in text snapshots. When reviewing
+//! snapshot changes, an LLM might approve misaligned columns that look "close enough" visually.
+//!
+//! These imperative tests explicitly verify that:
+//! - Column headers and data align at exact character positions
+//! - Unicode width calculations are correct (not just byte lengths)
+//! - Sparse columns (empty cells) don't break alignment
+//!
+//! The detailed verification logic here catches alignment bugs that would slip through snapshot review.
+
use crate::common::TestRepo;
use insta_cmd::get_cargo_bin;
use std::process::Command;
diff --git a/tests/integration_tests/completion.rs b/tests/integration_tests/completion.rs
index 052ec84da..ab54ddb37 100644
--- a/tests/integration_tests/completion.rs
+++ b/tests/integration_tests/completion.rs
@@ -52,7 +52,7 @@ fn test_complete_switch_shows_all_branches_including_worktrees() {
.output()
.unwrap();
- // Test completion
+ // Test completion - should show branches WITH worktrees and WITHOUT worktrees
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
@@ -120,7 +120,7 @@ fn test_complete_base_flag_shows_all_branches() {
.output()
.unwrap();
- // Test completion for --base flag
+ // Test completion for --base flag (long form)
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
@@ -143,52 +143,8 @@ fn test_complete_base_flag_shows_all_branches() {
// Should show all branches as potential base
assert!(branches.iter().any(|b| b.contains("develop")));
assert!(branches.iter().any(|b| b.contains("feature/existing")));
-}
-
-#[test]
-fn test_complete_outside_git_repo_returns_empty() {
- let temp = tempfile::tempdir().unwrap();
-
- // Test completion outside a git repo
- let mut cmd = Command::cargo_bin("wt").unwrap();
- let output = cmd
- .current_dir(temp.path())
- .args(["complete", "wt", "switch", ""])
- .output()
- .unwrap();
-
- // Should succeed but return no branches
- assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
- assert_eq!(stdout.trim(), "");
-}
-
-#[test]
-fn test_init_fish_includes_no_file_flag() {
- // Test that fish init includes -f flag to disable file completion
- let mut cmd = Command::cargo_bin("wt").unwrap();
- let output = cmd.arg("init").arg("fish").output().unwrap();
-
- assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
-
- // Check that completions include -f flag
- assert!(stdout.contains("-f -a '(__wt_complete)'"));
-}
-
-#[test]
-fn test_complete_base_flag_short_form() {
- let temp = TestRepo::new();
- temp.commit("initial");
-
- // Create branches
- StdCommand::new("git")
- .args(["branch", "develop"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
- // Test completion for -b flag (short form of --base)
+ // Test completion for -b flag (short form)
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
@@ -208,27 +164,77 @@ fn test_complete_base_flag_short_form() {
let stdout = String::from_utf8_lossy(&output.stdout);
let branches: Vec<&str> = stdout.lines().collect();
- // Should show all branches as potential base
+ // Should show all branches as potential base (short form works too)
assert!(branches.iter().any(|b| b.contains("develop")));
}
#[test]
-fn test_complete_empty_repo_returns_empty() {
- let temp = TestRepo::new();
- // No commits, no branches
+fn test_complete_edge_cases_return_empty() {
+ // Test 1: Outside git repo
+ let temp = tempfile::tempdir().unwrap();
+ let mut cmd = Command::cargo_bin("wt").unwrap();
+ let output = cmd
+ .current_dir(temp.path())
+ .args(["complete", "wt", "switch", ""])
+ .output()
+ .unwrap();
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
- // Test completion in empty repo
+ // Test 2: Empty repo (no commits)
+ let repo = TestRepo::new();
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.args(["complete", "wt", "switch", ""])
.output()
.unwrap();
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
+
+ // Test 3: Unknown command
+ let repo = TestRepo::new();
+ repo.commit("initial");
+ let mut cmd = Command::cargo_bin("wt").unwrap();
+ let output = cmd
+ .current_dir(repo.root_path())
+ .args(["complete", "wt", "unknown-command", ""])
+ .output()
+ .unwrap();
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
+
+ // Test 4: Commands that don't take branch arguments (list, remove)
+ let mut cmd = Command::cargo_bin("wt").unwrap();
+ let output = cmd
+ .current_dir(repo.root_path())
+ .args(["complete", "wt", "list", ""])
+ .output()
+ .unwrap();
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
+
+ let mut cmd = Command::cargo_bin("wt").unwrap();
+ let output = cmd
+ .current_dir(repo.root_path())
+ .args(["complete", "wt", "remove", ""])
+ .output()
+ .unwrap();
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
+}
+
+#[test]
+fn test_init_fish_includes_no_file_flag() {
+ // Test that fish init includes -f flag to disable file completion
+ let mut cmd = Command::cargo_bin("wt").unwrap();
+ let output = cmd.arg("init").arg("fish").output().unwrap();
- // Should succeed but return no branches
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
- assert_eq!(stdout.trim(), "");
+
+ // Check that completions include -f flag
+ assert!(stdout.contains("-f -a '(__wt_complete)'"));
}
#[test]
@@ -414,32 +420,6 @@ fn test_complete_merge_shows_branches() {
assert!(branches.iter().any(|b| b.contains("hotfix/bug")));
}
-#[test]
-fn test_complete_unknown_command_returns_empty() {
- let temp = TestRepo::new();
- temp.commit("initial");
-
- // Create some branches
- StdCommand::new("git")
- .args(["branch", "feature/test"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
-
- // Test completion for unknown command
- let mut cmd = Command::cargo_bin("wt").unwrap();
- let output = cmd
- .current_dir(temp.root_path())
- .args(["complete", "wt", "unknown-command", ""])
- .output()
- .unwrap();
-
- // Should succeed but return no completions
- assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
- assert_eq!(stdout.trim(), "");
-}
-
#[test]
fn test_complete_with_special_characters_in_branch_names() {
let temp = TestRepo::new();
@@ -483,81 +463,52 @@ fn test_complete_with_special_characters_in_branch_names() {
}
#[test]
-fn test_complete_list_command_returns_empty() {
+fn test_complete_stops_after_branch_provided() {
let temp = TestRepo::new();
temp.commit("initial");
// Create branches
StdCommand::new("git")
- .args(["branch", "feature/test"])
+ .args(["branch", "feature/one"])
.current_dir(temp.root_path())
.output()
.unwrap();
- // Test completion for list command (doesn't take branch arguments)
- let mut cmd = Command::cargo_bin("wt").unwrap();
- let output = cmd
+ StdCommand::new("git")
+ .args(["branch", "feature/two"])
.current_dir(temp.root_path())
- .args(["complete", "wt", "list", ""])
.output()
.unwrap();
- // Should succeed but return no completions
- assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
- assert_eq!(stdout.trim(), "");
-}
-
-#[test]
-fn test_complete_finish_command_returns_empty() {
- let temp = TestRepo::new();
- temp.commit("initial");
-
- // Test completion for remove command (doesn't take arguments)
+ // Test that switch stops completing after branch is provided
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
- .args(["complete", "wt", "remove", ""])
+ .args(["complete", "wt", "switch", "feature/one", ""])
.output()
.unwrap();
-
- // Should succeed but return no completions
assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
- assert_eq!(stdout.trim(), "");
-}
-
-#[test]
-fn test_complete_switch_stops_after_branch_provided() {
- let temp = TestRepo::new();
- temp.commit("initial");
-
- // Create branches
- StdCommand::new("git")
- .args(["branch", "feature/one"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
- StdCommand::new("git")
- .args(["branch", "feature/two"])
+ // Test that push stops completing after branch is provided
+ let mut cmd = Command::cargo_bin("wt").unwrap();
+ let output = cmd
.current_dir(temp.root_path())
+ .args(["complete", "wt", "push", "feature/one", ""])
.output()
.unwrap();
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
- // Test completion after branch is already provided
+ // Test that merge stops completing after branch is provided
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
- .args(["complete", "wt", "switch", "feature/one", ""])
+ .args(["complete", "wt", "merge", "feature/one", ""])
.output()
.unwrap();
-
assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
-
- // Should return no completions (branch already provided)
- assert_eq!(stdout.trim(), "");
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
}
#[test]
@@ -565,53 +516,31 @@ fn test_complete_switch_with_create_flag_no_completion() {
let temp = TestRepo::new();
temp.commit("initial");
- // Create branches
StdCommand::new("git")
.args(["branch", "feature/existing"])
.current_dir(temp.root_path())
.output()
.unwrap();
- // Test completion with --create flag (should not complete branch names)
+ // Test with --create flag (long form)
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
.args(["complete", "wt", "switch", "--create", ""])
.output()
.unwrap();
-
assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
-
- // Should return no completions (creating new branch, not completing existing)
- assert_eq!(stdout.trim(), "");
-}
-
-#[test]
-fn test_complete_switch_with_create_short_flag_no_completion() {
- let temp = TestRepo::new();
- temp.commit("initial");
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
- // Create branches
- StdCommand::new("git")
- .args(["branch", "feature/existing"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
-
- // Test completion with -c flag (should not complete branch names)
+ // Test with -c flag (short form)
let mut cmd = Command::cargo_bin("wt").unwrap();
let output = cmd
.current_dir(temp.root_path())
.args(["complete", "wt", "switch", "-c", ""])
.output()
.unwrap();
-
assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
-
- // Should return no completions (creating new branch)
- assert_eq!(stdout.trim(), "");
+ assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");
}
#[test]
@@ -648,69 +577,3 @@ fn test_complete_switch_base_flag_after_branch() {
// Should complete base flag value with branches
assert!(stdout.contains("develop"));
}
-
-#[test]
-fn test_complete_push_stops_after_branch_provided() {
- let temp = TestRepo::new();
- temp.commit("initial");
-
- // Create branches
- StdCommand::new("git")
- .args(["branch", "feature/one"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
-
- StdCommand::new("git")
- .args(["branch", "feature/two"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
-
- // Test completion after branch is already provided
- let mut cmd = Command::cargo_bin("wt").unwrap();
- let output = cmd
- .current_dir(temp.root_path())
- .args(["complete", "wt", "push", "feature/one", ""])
- .output()
- .unwrap();
-
- assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
-
- // Should return no completions (branch already provided)
- assert_eq!(stdout.trim(), "");
-}
-
-#[test]
-fn test_complete_merge_stops_after_branch_provided() {
- let temp = TestRepo::new();
- temp.commit("initial");
-
- // Create branches
- StdCommand::new("git")
- .args(["branch", "feature/one"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
-
- StdCommand::new("git")
- .args(["branch", "feature/two"])
- .current_dir(temp.root_path())
- .output()
- .unwrap();
-
- // Test completion after branch is already provided
- let mut cmd = Command::cargo_bin("wt").unwrap();
- let output = cmd
- .current_dir(temp.root_path())
- .args(["complete", "wt", "merge", "feature/one", ""])
- .output()
- .unwrap();
-
- assert!(output.status.success());
- let stdout = String::from_utf8_lossy(&output.stdout);
-
- // Should return no completions (branch already provided)
- assert_eq!(stdout.trim(), "");
-}
diff --git a/tests/integration_tests/e2e_shell.rs b/tests/integration_tests/e2e_shell.rs
index 4eed52ab0..828376708 100644
--- a/tests/integration_tests/e2e_shell.rs
+++ b/tests/integration_tests/e2e_shell.rs
@@ -105,10 +105,10 @@ fn path_export_syntax(shell: &str, bin_path: &str) -> String {
}
#[rstest]
-// Tier 1: Shells available in standard Ubuntu repos
+// Test with bash (POSIX baseline) and fish (different syntax)
+// zsh removed - too similar to bash
#[case("bash")]
#[case("fish")]
-#[case("zsh")]
// Tier 2: Shells requiring extra setup
#[cfg_attr(feature = "tier-2-integration-tests", case("elvish"))]
#[cfg_attr(feature = "tier-2-integration-tests", case("nushell"))]
@@ -148,10 +148,10 @@ fn test_e2e_switch_changes_directory(#[case] shell: &str) {
}
#[rstest]
-// Tier 1: Shells available in standard Ubuntu repos
+// Test with bash (POSIX baseline) and fish (different syntax)
+// zsh removed - too similar to bash
#[case("bash")]
#[case("fish")]
-#[case("zsh")]
// Tier 2: Shells requiring extra setup
#[cfg_attr(feature = "tier-2-integration-tests", case("elvish"))]
#[cfg_attr(feature = "tier-2-integration-tests", case("nushell"))]
diff --git a/tests/integration_tests/e2e_shell_post_start.rs b/tests/integration_tests/e2e_shell_post_start.rs
index 208d87ee8..1ab979f0a 100644
--- a/tests/integration_tests/e2e_shell_post_start.rs
+++ b/tests/integration_tests/e2e_shell_post_start.rs
@@ -121,10 +121,10 @@ fn path_export_syntax(shell: &str, bin_path: &str) -> String {
/// Test that post-start background commands work with shell integration
#[rstest]
-// Tier 1: Shells available in standard Ubuntu repos
+// Test with bash (POSIX baseline) and fish (different syntax)
+// zsh removed - too similar to bash
#[case("bash")]
#[case("fish")]
-#[case("zsh")]
// Tier 2: Shells requiring extra setup
#[cfg_attr(feature = "tier-2-integration-tests", case("elvish"))]
#[cfg_attr(feature = "tier-2-integration-tests", case("nushell"))]
diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rs
index 62df05eb2..c7545b8bd 100644
--- a/tests/integration_tests/list.rs
+++ b/tests/integration_tests/list.rs
@@ -161,19 +161,7 @@ fn test_list_locked_no_reason() {
snapshot_list("locked_no_reason", &repo);
}
-#[test]
-fn test_list_long_branch_name() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
-
- // Create worktree with very long branch name
- repo.add_worktree(
- "feature-this-is-a-very-long-branch-name-that-should-test-column-alignment",
- "feature-this-is-a-very-long-branch-name-that-should-test-column-alignment",
- );
-
- snapshot_list("long_branch_name", &repo);
-}
+// Removed: test_list_long_branch_name - covered by spacing_edge_cases.rs
#[test]
fn test_list_long_commit_message() {
@@ -188,17 +176,7 @@ fn test_list_long_commit_message() {
snapshot_list("long_commit_message", &repo);
}
-#[test]
-fn test_list_unicode_branch_name() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
-
- // Create worktree with Unicode in branch name
- repo.add_worktree("feature-日本語-test", "feature-日本語-test");
- repo.add_worktree("fix-émoji-🎉", "fix-émoji-🎉");
-
- snapshot_list("unicode_branch_name", &repo);
-}
+// Removed: test_list_unicode_branch_name - covered by spacing_edge_cases.rs
#[test]
fn test_list_unicode_commit_message() {
@@ -231,24 +209,8 @@ fn test_list_many_worktrees_with_varied_stats() {
snapshot_list("many_worktrees_varied", &repo);
}
-#[test]
-fn test_list_json_single_worktree() {
- let repo = TestRepo::new();
- repo.commit("Initial commit");
-
- snapshot_list_json("json_single_worktree", &repo);
-}
-
-#[test]
-fn test_list_json_multiple_worktrees() {
- let mut repo = TestRepo::new();
- repo.commit("Initial commit");
-
- repo.add_worktree("feature-a", "feature-a");
- repo.add_worktree("feature-b", "feature-b");
-
- snapshot_list_json("json_multiple_worktrees", &repo);
-}
+// Removed: test_list_json_single_worktree and test_list_json_multiple_worktrees
+// Basic JSON serialization is covered by test_list_json_with_metadata
#[test]
fn test_list_json_with_metadata() {
diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rs
index a46bb6179..80319e448 100644
--- a/tests/integration_tests/mod.rs
+++ b/tests/integration_tests/mod.rs
@@ -1,4 +1,4 @@
-pub mod column_alignment;
+// column_alignment merged into spacing_edge_cases
pub mod column_alignment_verification;
pub mod completion;
pub mod completion_validation;
diff --git a/tests/integration_tests/spacing_edge_cases.rs b/tests/integration_tests/spacing_edge_cases.rs
index d37dca8a5..917eb72bc 100644
--- a/tests/integration_tests/spacing_edge_cases.rs
+++ b/tests/integration_tests/spacing_edge_cases.rs
@@ -151,3 +151,74 @@ fn test_terminal_width_150_shows_all_columns() {
snapshot_list_with_width("terminal_width_150", &repo, 150);
}
+
+// Column alignment tests with varying diff sizes
+// (Merged from column_alignment.rs)
+
+#[test]
+fn test_column_alignment_varying_diff_widths() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Create worktrees with varying diff sizes to test alignment
+ repo.add_worktree("feature-small", "feature-small");
+ repo.add_worktree("feature-medium", "feature-medium");
+ repo.add_worktree("feature-large", "feature-large");
+
+ // Add files to create diffs with different digit counts
+ let small_path = repo.worktrees.get("feature-small").unwrap();
+ for i in 0..5 {
+ std::fs::write(small_path.join(format!("file{}.txt", i)), "content").unwrap();
+ }
+
+ let medium_path = repo.worktrees.get("feature-medium").unwrap();
+ for i in 0..50 {
+ std::fs::write(medium_path.join(format!("file{}.txt", i)), "content").unwrap();
+ }
+
+ let large_path = repo.worktrees.get("feature-large").unwrap();
+ for i in 0..500 {
+ std::fs::write(large_path.join(format!("file{}.txt", i)), "content").unwrap();
+ }
+
+ // Test at a width where WT +/- column is visible
+ snapshot_list_with_width("alignment_varying_diffs", &repo, 180);
+}
+
+#[test]
+fn test_column_alignment_with_empty_diffs() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Mix of worktrees with and without diffs
+ repo.add_worktree("no-changes", "no-changes");
+
+ repo.add_worktree("with-changes", "with-changes");
+ let changes_path = repo.worktrees.get("with-changes").unwrap();
+ std::fs::write(changes_path.join("file.txt"), "content").unwrap();
+
+ repo.add_worktree("also-no-changes", "also-no-changes");
+
+ // Path column should align even when some rows have diffs and others don't
+ snapshot_list_with_width("alignment_empty_diffs", &repo, 180);
+}
+
+#[test]
+fn test_column_alignment_extreme_diff_sizes() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Create worktrees with extreme diff size differences
+ repo.add_worktree("tiny", "tiny");
+ repo.add_worktree("huge", "huge");
+
+ let tiny_path = repo.worktrees.get("tiny").unwrap();
+ std::fs::write(tiny_path.join("file.txt"), "x").unwrap();
+
+ let huge_path = repo.worktrees.get("huge").unwrap();
+ for i in 0..9999 {
+ std::fs::write(huge_path.join(format!("file{}.txt", i)), "content").unwrap();
+ }
+
+ snapshot_list_with_width("alignment_extreme_diffs", &repo, 180);
+}
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
new file mode 100644
index 000000000..ff424a849
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
@@ -0,0 +1,30 @@
+---
+source: tests/integration_tests/spacing_edge_cases.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "180"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: /dev/null
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ LANG: C
+ LC_ALL: C
+ SOURCE_DATE_EPOCH: "1704067200"
+---
+success: true
+exit_code: 0
+----- stdout -----
+Branch  Age  WT +/- Commit  Message  Path
+main  9 months ago b834638e Initial commit ./main
+also-no-changes 9 months ago b834638e Initial commit ./also-no-changes
+no-changes 9 months ago b834638e Initial commit ./no-changes
+with-changes 9 months ago +1 -1 b834638e Initial commit ./with-changes
+
+Showing 4 worktrees, 1 with changes
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
new file mode 100644
index 000000000..15ccd7167
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
@@ -0,0 +1,29 @@
+---
+source: tests/integration_tests/spacing_edge_cases.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "180"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: /dev/null
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ LANG: C
+ LC_ALL: C
+ SOURCE_DATE_EPOCH: "1704067200"
+---
+success: true
+exit_code: 0
+----- stdout -----
+Branch Age  WT +/- Commit  Message  Path
+main  9 months ago b834638e Initial commit ./main
+huge 9 months ago b834638e Initial commit ./huge
+tiny 9 months ago +1 -1 b834638e Initial commit ./tiny
+
+Showing 3 worktrees, 1 with changes
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
new file mode 100644
index 000000000..f64b37d05
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
@@ -0,0 +1,30 @@
+---
+source: tests/integration_tests/spacing_edge_cases.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "180"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: /dev/null
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ LANG: C
+ LC_ALL: C
+ SOURCE_DATE_EPOCH: "1704067200"
+---
+success: true
+exit_code: 0
+----- stdout -----
+Branch  Age  Commit  Message  Path
+main  9 months ago b834638e Initial commit ./main
+feature-large 9 months ago b834638e Initial commit ./feature-large
+feature-medium 9 months ago b834638e Initial commit ./feature-medium
+feature-small 9 months ago b834638e Initial commit ./feature-small
+
+Showing 4 worktrees
+
+----- stderr -----