Files
max-sixty__worktrunk/tests/common/list_snapshots.rs
Maximilian Roos 49c15097ff refactor(tests): simplify snapshot testing with auto-bound settings (#396)
* refactor(tests): simplify snapshot testing with auto-bound settings

- Auto-bind snapshot settings in TestRepo::new() via _snapshot_guard field
- Remove manual setup_snapshot_settings().bind() wrappers from tests
- Inline make_snapshot_cmd calls directly in assert_cmd_snapshot! macros
- Remove unused helper functions (json_settings, bind, bind_json)
- Use auto-naming from test function names (explicit names only for multi-snapshot tests)
- Fix directive file guard lifetime in test_remove_internal_mode
- Clean up orphaned snapshot files and let git detect renames

Net reduction: -183 lines in test files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: update statusline tests for fish-abbreviated paths

The auto-bound snapshot settings from TestRepo use `_REPO_` filters
for full paths, but the statusline command uses fish-style path
abbreviation (e.g., `/p/v/f/.../repo`). These abbreviated paths
weren't matched by the existing filters.

Updated `claude_code_snapshot_settings()` to:
- Filter fish-abbreviated paths ending in `/repo` to `[PATH]`
- Strip leading ANSI reset codes from output
- Remove unused `repo` parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: normalize statusline paths across platforms

The statusline output varies by platform:
- Linux: Raw path filtered by auto-bound settings to `_REPO_`
- macOS: Fish-style abbreviation bypasses auto-bound filters

Updated claude_code_snapshot_settings() to normalize both cases
to a consistent `[PATH]` placeholder for cross-platform tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-03 01:00:10 -08:00

27 lines
751 B
Rust

// Functions here are conditionally used based on platform (#[cfg(not(windows))]).
#![allow(dead_code)]
use super::{TestRepo, wt_command};
use std::path::Path;
use std::process::Command;
use worktrunk::styling::DEFAULT_HELP_WIDTH;
pub fn command(repo: &TestRepo, cwd: &Path) -> Command {
let mut cmd = wt_command();
repo.configure_wt_cmd(&mut cmd);
cmd.arg("list").current_dir(cwd);
cmd
}
pub fn command_readme(repo: &TestRepo, cwd: &Path) -> Command {
let mut cmd = command(repo, cwd);
cmd.env("COLUMNS", DEFAULT_HELP_WIDTH.to_string());
cmd
}
pub fn command_with_width(repo: &TestRepo, width: usize) -> Command {
let mut cmd = command(repo, repo.root_path());
cmd.env("COLUMNS", width.to_string());
cmd
}