`worklane tui` takes any number of paths, each resolved to the first `.worklane` at or above it the way the working directory always was. With more than one board there is a tab per project plus an `all` tab merging them, and `tab`/`shift+tab` between them. The selection moves onto `Tab`: sharing one column and card index across projects would point it at whatever unrelated ticket sat in the same place. The merge is sorted through `by_priority_then_title`, now exported, rather than concatenated, so its order does not depend on the order of the arguments. On the merge a card and the overlay border name the project after the id, since across boards seven characters of uuid are not an address. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
151 lines
5.2 KiB
Rust
151 lines
5.2 KiB
Rust
use assert_cmd::Command;
|
|
use assert_fs::TempDir;
|
|
use assert_fs::fixture::{PathChild, PathCreateDir};
|
|
|
|
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
|
|
|
fn setup_worklane(temp: &TempDir) {
|
|
let worklane = temp.child(".worklane");
|
|
worklane.create_dir_all().unwrap();
|
|
|
|
for dir in ["backlog", "committed", "reviewing", "done"] {
|
|
worklane.child(dir).create_dir_all().unwrap();
|
|
}
|
|
}
|
|
|
|
/// A project inside the temp directory, for the path arguments. The temp directory
|
|
/// itself is left without a board, so a path that resolves has to resolve to this one.
|
|
fn setup_project(temp: &TempDir, name: &str) -> std::path::PathBuf {
|
|
let project = temp.child(name);
|
|
let worklane = project.child(".worklane");
|
|
worklane.create_dir_all().unwrap();
|
|
|
|
for dir in ["backlog", "committed", "reviewing", "done"] {
|
|
worklane.child(dir).create_dir_all().unwrap();
|
|
}
|
|
|
|
project.path().to_path_buf()
|
|
}
|
|
|
|
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
|
cmd.current_dir(temp.path()).args(args);
|
|
cmd.assert().get_output().clone()
|
|
}
|
|
|
|
/// Same message every other command gives. Checked before the terminal is, so the
|
|
/// missing board is what gets reported rather than the missing tty.
|
|
#[test]
|
|
fn the_tui_outside_a_worklane_directory_gives_the_usual_message() {
|
|
let temp = TempDir::new().unwrap();
|
|
|
|
for args in [vec!["tui"], vec![]] {
|
|
let out = run(&temp, &args);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
|
assert!(
|
|
stderr.contains("No .worklane directory found"),
|
|
"{args:?}: {stderr:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Raw mode on a pipe fails with a bare "No such device or address", which says nothing
|
|
/// about the mistake. A bare `worklane` is how the board opens, so a script that lands
|
|
/// here by accident has to be pointed at a subcommand.
|
|
#[test]
|
|
fn the_tui_without_a_terminal_says_so_and_names_an_alternative() {
|
|
let temp = TempDir::new().unwrap();
|
|
setup_worklane(&temp);
|
|
|
|
for args in [vec!["tui"], vec![]] {
|
|
let out = run(&temp, &args);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
|
assert!(stderr.contains("needs a terminal"), "{args:?}: {stderr:?}");
|
|
assert!(stderr.contains("worklane ls"), "{args:?}: {stderr:?}");
|
|
assert!(
|
|
!stderr.contains("os error"),
|
|
"the raw mode error leaked: {stderr:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The subcommands must keep working now that the subcommand is optional.
|
|
#[test]
|
|
fn an_unknown_subcommand_is_still_a_usage_error() {
|
|
let temp = TempDir::new().unwrap();
|
|
setup_worklane(&temp);
|
|
|
|
assert_eq!(run(&temp, &["nonsense"]).status.code(), Some(2));
|
|
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
|
|
}
|
|
|
|
/// A path argument is resolved before the terminal is, the same way the working
|
|
/// directory is: reaching the tty complaint is what says the board was found.
|
|
#[test]
|
|
fn a_path_argument_names_the_board_to_open() {
|
|
let temp = TempDir::new().unwrap();
|
|
let project = setup_project(&temp, "project");
|
|
|
|
// Run from a directory with no board of its own, so only the argument can find one.
|
|
let out = run(&temp, &["tui", project.to_str().unwrap()]);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
|
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
|
}
|
|
|
|
/// And several of them, which is the point of taking paths at all.
|
|
#[test]
|
|
fn several_path_arguments_are_accepted() {
|
|
let temp = TempDir::new().unwrap();
|
|
let first = setup_project(&temp, "first");
|
|
let second = setup_project(&temp, "second");
|
|
|
|
let out = run(
|
|
&temp,
|
|
&["tui", first.to_str().unwrap(), second.to_str().unwrap()],
|
|
);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
|
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
|
}
|
|
|
|
/// With several paths, "No .worklane directory found" does not say which one was wrong.
|
|
#[test]
|
|
fn a_path_with_no_board_is_named_in_the_failure() {
|
|
let temp = TempDir::new().unwrap();
|
|
let project = setup_project(&temp, "project");
|
|
|
|
let elsewhere = temp.child("elsewhere");
|
|
elsewhere.create_dir_all().unwrap();
|
|
let path = elsewhere.path().to_str().unwrap().to_string();
|
|
|
|
// The first path resolves, the second does not.
|
|
let out = run(&temp, &["tui", project.to_str().unwrap(), &path]);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
|
assert!(stderr.contains(&path), "the failing path is not named: {stderr:?}");
|
|
assert!(
|
|
stderr.contains("No .worklane directory found"),
|
|
"the usual message is gone: {stderr:?}"
|
|
);
|
|
}
|
|
|
|
/// `tui` has to appear in the help, or nothing points at it.
|
|
#[test]
|
|
fn the_help_lists_the_tui_command() {
|
|
let temp = TempDir::new().unwrap();
|
|
|
|
let out = run(&temp, &["--help"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert!(out.status.success());
|
|
assert!(stdout.contains("tui"), "{stdout:?}");
|
|
}
|