"), "{html}");
let blocker = "NDraft\
still a draft";
assert!(html.contains(blocker), "{html}");
let open = "";
assert!(html.contains(open), "{html}");
}
/// The break this catches: a passing check drawn as a blocker, or "0 incomplete" on a pull
/// request with nothing left to do.
#[test]
fn a_passing_check_is_quiet() {
let mut ready = value(PULL_REQUEST);
ready["overview"]["merge_status"] = json!("clean");
let html = sections(ready);
assert!(html
.contains("YChecks"));
assert!(html.contains(""), "{html}");
assert!(!html.contains("incomplete"), "{html}");
}
/// The break this catches: the approval count wrong, a verdict in the wrong color, a team not
/// named as one, or a Reviewers heading over nobody.
#[test]
fn reviewers_say_what_they_said() {
let mut reviewed = value(PULL_REQUEST);
reviewed["overview"]["reviewers"] = json!([
{"login": "mara", "kind": "user", "verdict": "approved", "at": CHANGED},
{"login": "core", "kind": "team", "verdict": "changes_requested", "at": null}
]);
let html = sections(reviewed);
assert!(html.contains(">1 of 2 approved"), "{html}");
assert!(html.contains("mara"), "{html}");
assert!(html.contains("approved"), "{html}");
assert!(html.contains("\u{b7} 3600s ago"), "{html}");
assert!(html.contains(
"changes requested \u{b7} team"
));
assert!(!sections(value(PULL_REQUEST)).contains("Reviewers"));
}
/// The break this catches: the excerpt quoting more or fewer than five lines that say something,
/// a blank line spending one of the five, the count of the rest wrong, or a body rendered without
/// its HTML made readable first.
#[test]
fn the_description_quotes_five_lines() {
let body = |text: &str| {
let mut pull_request = value(PULL_REQUEST);
pull_request["overview"]["body"] = json!(text);
sections(pull_request)
};
let long = body("one\n\ntwo\nthree\nfour\nfive\nsix\nseven");
assert!(long.contains("R:one\n\ntwo\nthree\nfour\nfive\n"), "{long}");
let more = "data-tab=\"conversation\">… 2 more lines in Conversation";
assert!(long.contains(more), "{long}");
let short = body("one\ntwo\nthree\nfour\nfive");
assert!(short.contains("five\n") && !short.contains("gh-more"), "{short}");
assert!(body(" ").contains("
No description
"));
}
/// The break this catches: an issue's assignees, closing pull requests or milestone left out,
/// a pull request that only mentions the issue listed as closing it, or nothing said when nobody
/// is on it.
#[test]
fn an_issue_says_who_is_on_it() {
let html = sections(value(ISSUE));
assert!(html.contains("unassigned"), "{html}");
assert!(html.contains("none yet"), "{html}");
assert!(!html.contains("Milestone"), "{html}");
let mut staffed = value(ISSUE);
staffed["overview"]["assignees"] = json!(["mara", "jo"]);
staffed["overview"]["milestone"] = json!("v1");
staffed["overview"]["linked"] = json!([
{"number": 7, "title": "Fix", "state": "open", "draft": false, "author": "jo", "closes": true},
{"number": 8, "title": "See", "state": "open", "draft": false, "author": "jo", "closes": false}
]);
let html = sections(staffed);
assert!(html.contains("mara, jo"), "{html}");
assert!(html.contains("data-number=\"7\" data-pull=\"true\">#7"), "{html}");
assert!(!html.contains("data-number=\"8\""), "{html}");
assert!(
html.contains("Milestonev1")
);
}