fix: hide commentless reviews from CLI listings
This commit is contained in:
+41
-8
@@ -115,6 +115,17 @@ fn cli_deletes_only_the_requested_comment_and_preserves_failed_targets() {
|
||||
assert!(empty.comments.is_empty());
|
||||
assert_eq!(empty.storage_revision, loaded.storage_revision + 1);
|
||||
assert_eq!(empty.summary, review.summary);
|
||||
let output = cli("repo", &["list", "--json"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(list["reviews"], serde_json::json!([]));
|
||||
let output = cli("repo", &["list"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
assert!(
|
||||
String::from_utf8(output.stdout)
|
||||
.unwrap()
|
||||
.contains("No stored reviews.")
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.load(&other.root, other.storage_id.unwrap())
|
||||
@@ -178,6 +189,8 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
|
||||
other.comments = review.comments.clone();
|
||||
store.save(&mut other).unwrap();
|
||||
let mut source = Review::new(review.root.clone());
|
||||
source.summary = "Progress without comments".into();
|
||||
source.verdict = Some(Verdict::LooksGood);
|
||||
store.save(&mut source).unwrap();
|
||||
let mut reversed = Review::new(review.root.clone());
|
||||
reversed.comparison = Some(["working:frozen-tip".into(), "frozen-base".into()]);
|
||||
@@ -272,20 +285,32 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
|
||||
let output = cli("repo", &["list", "--json"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(list["reviews"].as_array().unwrap().len(), 3);
|
||||
assert_eq!(
|
||||
list["reviews"][0]["comparison"],
|
||||
serde_json::json!(reversed.comparison)
|
||||
list["reviews"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|review| review["id"].as_i64().unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![id]
|
||||
);
|
||||
assert!(list["reviews"][1]["comparison"].is_null());
|
||||
assert_eq!(list["reviews"][2]["comparison"], json["comparison"]);
|
||||
assert_eq!(list["reviews"][2]["counts"], json["counts"]);
|
||||
assert_eq!(list["reviews"][0]["comparison"], json["comparison"]);
|
||||
assert_eq!(list["reviews"][0]["counts"], json["counts"]);
|
||||
let output = cli("repo", &["list"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let text = String::from_utf8(output.stdout).unwrap();
|
||||
assert!(text.contains("Scope: source"));
|
||||
assert!(!text.contains("Progress without comments"));
|
||||
assert!(text.contains("Scope: comparison frozen-base → working:frozen-tip"));
|
||||
assert!(text.contains("Scope: comparison working:frozen-tip → frozen-base"));
|
||||
assert!(!text.contains("Scope: comparison working:frozen-tip → frozen-base"));
|
||||
assert_eq!(fs::read(&path).unwrap(), before);
|
||||
let output = cli(
|
||||
"repo",
|
||||
&["show", &source.storage_id.unwrap().to_string(), "--json"],
|
||||
);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let shown: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(shown["summary"], source.summary);
|
||||
assert_eq!(shown["verdict"], "looks_good");
|
||||
let output = cli("repo", &["resolve", &id_text, "2"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let text = String::from_utf8(output.stdout).unwrap();
|
||||
@@ -293,6 +318,14 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
|
||||
let loaded = store.load(&review.root, id).unwrap();
|
||||
assert_eq!(loaded.storage_revision, review.storage_revision + 2);
|
||||
assert!(loaded.comments.iter().all(|comment| comment.resolved));
|
||||
let output = cli("repo", &["list", "--json"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(list["reviews"][0]["id"], id);
|
||||
assert_eq!(
|
||||
list["reviews"][0]["counts"],
|
||||
serde_json::json!({"total": 3, "resolved": 3, "unresolved": 0})
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.load(&other.root, other.storage_id.unwrap())
|
||||
|
||||
Reference in New Issue
Block a user