mod common;
use common::{init_project, normalize_output, run_commands, run_dynamic_commands, today};
#[test]
fn test_move_queue_to_active() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[
&["work", "new", "Test task"],
&["work", "list", "all"],
&["work", "move", "WI-<DATE>-001", "active"],
&["work", "list", "all"],
],
);
let output = output.replace("WI-<DATE>-001", &format!("WI-{}-001", date));
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_active_to_done_with_criteria() {
let temp_dir = init_project();
let date = today();
let setup_commands: Vec<Vec<String>> = vec![
vec![
"work".to_string(),
"new".to_string(),
"Test task".to_string(),
"--active".to_string(),
],
vec![
"work".to_string(),
"add".to_string(),
format!("WI-{}-001", date),
"acceptance_criteria".to_string(),
"add: Task done".to_string(),
],
];
let _ = run_dynamic_commands(temp_dir.path(), &setup_commands);
let output = run_commands(
temp_dir.path(),
&[
&[
"work",
"tick",
&format!("WI-{}-001", date),
"acceptance_criteria",
"Task done",
"-s",
"done",
],
&["work", "move", &format!("WI-{}-001", date), "done"],
&["work", "list", "all"],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_to_done_without_criteria_fails() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[
&["work", "new", "Test task", "--active"],
&["work", "move", &format!("WI-{}-001", date), "done"],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_to_done_with_pending_criteria_fails() {
let temp_dir = init_project();
let date = today();
let setup_commands: Vec<Vec<String>> = vec![
vec![
"work".to_string(),
"new".to_string(),
"Test task".to_string(),
"--active".to_string(),
],
vec![
"work".to_string(),
"add".to_string(),
format!("WI-{}-001", date),
"acceptance_criteria".to_string(),
"add: Task done".to_string(),
],
];
let _ = run_dynamic_commands(temp_dir.path(), &setup_commands);
let output = run_commands(
temp_dir.path(),
&[&["work", "move", &format!("WI-{}-001", date), "done"]],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_active_to_cancelled() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[
&["work", "new", "Cancelled task", "--active"],
&["work", "move", &format!("WI-{}-001", date), "cancelled"],
&["work", "list", "all"],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_queue_to_cancelled() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[
&["work", "new", "Skipped task"],
&["work", "move", &format!("WI-{}-001", date), "cancelled"],
&["work", "list", "all"],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_by_work_item_id() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[
&["work", "new", "Task with ID ref"],
&["work", "move", &format!("WI-{}-001", date), "active"],
&["work", "list", "all"],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_nonexistent_work_item() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[&["work", "move", "WI-9999-99-999", "active"]],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_sets_started_date() {
let temp_dir = init_project();
let date = today();
let output = run_commands(
temp_dir.path(),
&[
&["work", "new", "Task to start"],
&["work", "show", &format!("WI-{}-001", date)],
&["work", "move", &format!("WI-{}-001", date), "active"],
&["work", "show", &format!("WI-{}-001", date)],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}
#[test]
fn test_move_sets_completed_date() {
let temp_dir = init_project();
let date = today();
let setup_commands: Vec<Vec<String>> = vec![
vec![
"work".to_string(),
"new".to_string(),
"Task to complete".to_string(),
"--active".to_string(),
],
vec![
"work".to_string(),
"add".to_string(),
format!("WI-{}-001", date),
"acceptance_criteria".to_string(),
"add: Done".to_string(),
],
];
let _ = run_dynamic_commands(temp_dir.path(), &setup_commands);
let output = run_commands(
temp_dir.path(),
&[
&[
"work",
"tick",
&format!("WI-{}-001", date),
"acceptance_criteria",
"Done",
"-s",
"done",
],
&["work", "show", &format!("WI-{}-001", date)],
&["work", "move", &format!("WI-{}-001", date), "done"],
&["work", "show", &format!("WI-{}-001", date)],
],
);
insta::assert_snapshot!(normalize_output(&output, temp_dir.path(), &date));
}