Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md
- luxe remote puts the sessions on your computer in reach of your own phone or tablet over Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a paired device and your own Tailscale login. - luxe join lets another program on the same machine join a running session over the RPC protocol. - An AGENTS.md in a subfolder reaches the model the first time it works there. - Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing. - A session is open in one Luxe at a time, web_search shares results across its phrasings, and a grep glob starting with ! excludes. The CHANGELOG has the full list.
This commit is contained in:
141
crates/luxe-remote/src/render/github/tests/conversation.rs
Normal file
141
crates/luxe-remote/src/render/github/tests/conversation.rs
Normal file
@@ -0,0 +1,141 @@
|
||||
use super::an_hour_after;
|
||||
use crate::render::github::conversation;
|
||||
use luxe_core::github::overview::ConversationEntry;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// A `github_conversation_read` frame's opening entry, copied from a live session, its long
|
||||
/// dependabot body cut to its first line.
|
||||
const OPENING: &str = r#"{"kind": "opening", "author": {"login": "dependabot", "bot": true}, "body": "Bumps the actions group with 2 updates in the / directory.", "at": 1792259399}"#;
|
||||
|
||||
const CHANGED: u64 = 1_792_259_399;
|
||||
|
||||
/// When `CHANGED` was, as GitHub writes a comment's time.
|
||||
const CHANGED_TEXT: &str = "2026-10-17T17:49:59Z";
|
||||
|
||||
fn drawn(entries: Vec<Value>, opened_by_you: bool) -> String {
|
||||
let entries: Vec<ConversationEntry> =
|
||||
serde_json::from_value(json!(entries)).expect("entries as core sends them");
|
||||
conversation(&an_hour_after(CHANGED), &entries, opened_by_you)
|
||||
}
|
||||
|
||||
fn comment(author: &str, bot: bool, mine: bool, body: &str) -> Value {
|
||||
json!({"id": "IC_1", "author": author, "bot": bot, "mine": mine, "body": body,
|
||||
"created_at": CHANGED_TEXT, "url": "https://github.com/o/r/pull/1#issuecomment-1"})
|
||||
}
|
||||
|
||||
/// A comment as the timeline's own entry.
|
||||
fn said(author: &str, bot: bool, mine: bool, body: &str) -> Value {
|
||||
let mut entry = comment(author, bot, mine, body);
|
||||
entry["kind"] = json!("comment");
|
||||
entry
|
||||
}
|
||||
|
||||
fn review(verdict: &str, line_comments: usize, bot: bool) -> Value {
|
||||
let comment = comment("mara", bot, false, "Looks fine.");
|
||||
json!({"kind": "review", "comment": comment, "verdict": verdict, "line_comments": line_comments})
|
||||
}
|
||||
|
||||
fn thread(path: &str, resolved: bool, outdated: bool, said: &[(&str, &str)]) -> Value {
|
||||
let comments: Vec<Value> = said
|
||||
.iter()
|
||||
.map(|(author, body)| {
|
||||
json!({"author": author,
|
||||
"body": body, "created_at": CHANGED_TEXT, "url": "https://github.com/o/r/pull/1#r1"})
|
||||
})
|
||||
.collect();
|
||||
json!({"kind": "thread", "id": "PRRT_1", "path": path, "line": 42, "start_line": null,
|
||||
"side": "right", "outdated": outdated, "resolved": resolved, "file_level": false,
|
||||
"comments": comments, "total_comments": said.len(), "anchor_text": null,
|
||||
"can_reply": false, "can_resolve": false})
|
||||
}
|
||||
|
||||
/// The break this catches: the real opening entry drawn as a person's, without its age, or with
|
||||
/// its body rendered before its HTML was made readable.
|
||||
#[test]
|
||||
fn the_opening_reads_as_the_tuis() {
|
||||
let opening: Value = serde_json::from_str(OPENING).expect("an opening as core sends it");
|
||||
let html = drawn(vec![opening], false);
|
||||
assert!(html.contains("<section class=\"gh-card tone-quiet\">"), "{html}");
|
||||
let bot = "<span class=\"hue-muted\">@dependabot</span><span class=\"dim\"> bot</span>";
|
||||
assert!(html.contains(bot), "{html}");
|
||||
assert!(html.contains(">opened</span>"), "{html}");
|
||||
assert!(html.contains(">3600s ago</span>"), "{html}");
|
||||
assert!(html.contains("<md>R:Bumps the actions group"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: your own description or comment not named as yours, a person's
|
||||
/// comment drawn quiet, or a comment's time dropped.
|
||||
#[test]
|
||||
fn a_comment_names_its_speaker() {
|
||||
let opening = json!({"kind": "opening", "author": {"login": "me", "bot": false}, "body": "x", "at": CHANGED});
|
||||
let html = drawn(vec![opening], true);
|
||||
assert!(html.contains("<span class=\"gh-mine\">@me</span>"), "{html}");
|
||||
let html = drawn(vec![said("jo", false, false, "Hi.")], false);
|
||||
assert!(html.contains("<section class=\"gh-card tone-person\">"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-secondary\">@jo</span>"), "{html}");
|
||||
assert!(html.contains(">commented</span>"), "{html}");
|
||||
assert!(html.contains(">3600s ago</span>"), "{html}");
|
||||
let html = drawn(vec![said("me", false, true, "Hi.")], false);
|
||||
assert!(html.contains("<span class=\"gh-mine\">@me</span>"), "{html}");
|
||||
let html = drawn(vec![said("", false, false, "Hi.")], false);
|
||||
assert!(html.contains("<span class=\"hue-muted\">@ghost</span>"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: a verdict in the wrong words or tone, a bot's review toned like a
|
||||
/// person's, or the line comments miscounted.
|
||||
#[test]
|
||||
fn a_review_is_toned_by_its_verdict() {
|
||||
let html = drawn(vec![review("approved", 0, false)], false);
|
||||
assert!(html.contains("tone-approved"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-success\">approved</span>"), "{html}");
|
||||
assert!(!html.contains("line comment"), "{html}");
|
||||
let html = drawn(vec![review("changes_requested", 1, false)], false);
|
||||
assert!(html.contains("tone-changes"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-error\">requested changes</span>"), "{html}");
|
||||
assert!(html.contains(">1 line comment</span>"), "{html}");
|
||||
let html = drawn(vec![review("changes_requested", 3, true)], false);
|
||||
assert!(html.contains("tone-quiet"), "{html}");
|
||||
assert!(html.contains(">3 line comments</span>"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: a long comment drawn whole, or a short one folded behind a button.
|
||||
#[test]
|
||||
fn a_long_comment_folds() {
|
||||
let long = (1..=8).map(|n| format!("line {n}")).collect::<Vec<_>>().join("\n");
|
||||
let html = drawn(vec![said("jo", false, false, &long)], false);
|
||||
assert!(html.contains("tone-person folded"), "{html}");
|
||||
assert!(html.contains("<button type=\"button\" class=\"gh-unfold\">… Show all</button>"));
|
||||
let short = (1..=7).map(|n| format!("line {n}\n")).collect::<String>();
|
||||
let html = drawn(vec![said("jo", false, false, &short)], false);
|
||||
assert!(!html.contains("folded") && !html.contains("gh-unfold"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: an open thread not in the info tone, its place or reply count wrong,
|
||||
/// its last word missing while folded, or a reply left out once it's opened.
|
||||
#[test]
|
||||
fn an_open_thread_shows_its_last_word() {
|
||||
let said = [("mara", "Why\nthis?"), ("jo", "Because.")];
|
||||
let html = drawn(vec![thread("src/api/v1/hook.rs", false, false, &said)], false);
|
||||
assert!(html.contains("<details class=\"gh-card gh-thread tone-unresolved\">"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-secondary\">@mara</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"dim\"> \u{b7} </span>\u{2026}/v1/hook.rs:42"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-info\">unresolved</span>"), "{html}");
|
||||
assert!(html.contains(">1 reply</span>"), "{html}");
|
||||
let last = "<span class=\"gh-last\"><span class=\"hue-muted\">@jo: </span>Because.</span>";
|
||||
assert!(html.contains(last), "{html}");
|
||||
assert!(html.contains("<md>R:Why\nthis?</md>"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: a settled thread still toned as open, or a short path cut.
|
||||
#[test]
|
||||
fn a_settled_thread_is_quiet() {
|
||||
let said = [("mara", "Fixed.")];
|
||||
let html = drawn(vec![thread("crates/x/hook.rs", true, false, &said)], false);
|
||||
assert!(html.contains("tone-person"), "{html}");
|
||||
assert!(html.contains("</span>crates/x/hook.rs:42"), "{html}");
|
||||
assert!(html.contains("<span class=\"dim\">resolved</span>"), "{html}");
|
||||
assert!(!html.contains(" reply<"), "{html}");
|
||||
let html = drawn(vec![thread("src/hook.rs", false, true, &said)], false);
|
||||
assert!(html.contains("<span class=\"dim\">outdated</span>"), "{html}");
|
||||
assert!(html.contains("tone-person"), "{html}");
|
||||
}
|
||||
146
crates/luxe-remote/src/render/github/tests/list.rs
Normal file
146
crates/luxe-remote/src/render/github/tests/list.rs
Normal file
@@ -0,0 +1,146 @@
|
||||
use super::an_hour_after;
|
||||
use crate::render::github::list;
|
||||
use luxe_core::github::{rfc3339_seconds, ListedSection};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// A `github_listed` item, copied from a live session's "Pull requests" section.
|
||||
const ITEM: &str = r#"{"pull_request": true, "number": 211, "title": "chore: refresh the embedded models.dev snapshot", "url": "https://github.com/nora-quinn/luxe-dev/pull/211", "repository": "nora-quinn/luxe-dev", "author": "github-actions", "draft": false, "updated_at": "2026-10-19T12:25:08Z", "state": "open", "facts": {"author_bot": true, "additions": 2, "deletions": 2, "checks": {"passed": 0, "failed": 0, "pending": 0, "skipped": 0}, "review_decision": null, "comments": 0, "labels": [], "linked_pull_request": null}}"#;
|
||||
|
||||
const HERE: Option<&str> = Some("nora-quinn/luxe-dev");
|
||||
|
||||
fn item() -> Value {
|
||||
serde_json::from_str(ITEM).expect("a listed item as core sends it")
|
||||
}
|
||||
|
||||
fn section(items: Vec<Value>, total: Option<u64>) -> ListedSection {
|
||||
let section = json!({"name": "Pull requests", "items": items, "error": null, "total": total});
|
||||
serde_json::from_value(section).expect("a listed section as core sends it")
|
||||
}
|
||||
|
||||
/// When `ITEM` last changed.
|
||||
fn changed() -> u64 {
|
||||
rfc3339_seconds("2026-10-19T12:25:08Z").expect("the item's time reads")
|
||||
}
|
||||
|
||||
/// One section holding `item`, drawn an hour after it changed.
|
||||
fn drawn(item: Value) -> String {
|
||||
list(&an_hour_after(changed()), HERE, §ion(vec![item], Some(1)))
|
||||
}
|
||||
|
||||
/// The break this catches: a row the app can't open (number, kind or link missing), the mark in
|
||||
/// the wrong state color, a bot named as a person, the age keeping its "ago", or the diff counts
|
||||
/// dropped from line two.
|
||||
#[test]
|
||||
fn a_pull_request_row_reads_as_the_tuis() {
|
||||
let html = drawn(item());
|
||||
assert!(html.contains("data-number=\"211\" data-pull=\"true\""), "{html}");
|
||||
assert!(html.contains("data-url=\"https://github.com/nora-quinn/luxe-dev/pull/211\""));
|
||||
assert!(html.contains("<span class=\"gh-mark hue-success\">PR</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"dim\">#211 </span>"), "{html}");
|
||||
assert!(html.contains("refresh the embedded models.dev snapshot"), "{html}");
|
||||
let bot = "<span class=\"hue-muted\">github-actions</span><span class=\"dim\"> bot</span>";
|
||||
assert!(html.contains(bot), "{html}");
|
||||
assert!(html.contains("<span class=\"gh-right dim\">3600s</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"add\">+2</span>"), "{html}");
|
||||
assert!(!html.contains(">open<"), "an open pull request doesn't say so: {html}");
|
||||
}
|
||||
|
||||
/// The break this catches: the checks or the review left out of line two, or their marks crossed.
|
||||
#[test]
|
||||
fn a_pull_request_row_says_where_it_stands() {
|
||||
let mut failing = item();
|
||||
failing["facts"]["checks"] = json!({"passed": 3, "failed": 1, "pending": 2, "skipped": 0});
|
||||
failing["facts"]["review_decision"] = json!("changes_requested");
|
||||
let html = drawn(failing);
|
||||
assert!(html.contains("<span class=\"hue-error\">N 1 failing</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-error\">changes requested</span>"), "{html}");
|
||||
let mut running = item();
|
||||
running["facts"]["checks"] = json!({"passed": 3, "failed": 0, "pending": 2, "skipped": 0});
|
||||
running["facts"]["review_decision"] = json!("approved");
|
||||
let html = drawn(running);
|
||||
assert!(html.contains("<span class=\"hue-warning\">W running</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-success\">approved</span>"), "{html}");
|
||||
let mut passed = item();
|
||||
passed["facts"]["checks"] = json!({"passed": 3, "failed": 0, "pending": 0, "skipped": 0});
|
||||
assert!(drawn(passed).contains("<span class=\"hue-success\">Y checks</span>"));
|
||||
}
|
||||
|
||||
/// The break this catches: a draft or a merged pull request that doesn't say so, or its mark in
|
||||
/// the open color.
|
||||
#[test]
|
||||
fn a_row_names_any_state_but_open() {
|
||||
let mut draft = item();
|
||||
draft["draft"] = json!(true);
|
||||
let html = drawn(draft);
|
||||
assert!(html.contains("<span class=\"gh-mark hue-muted\">PR</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-muted\">draft</span>"), "{html}");
|
||||
let mut merged = item();
|
||||
merged["state"] = json!("merged");
|
||||
assert!(drawn(merged).contains("<span class=\"hue-secondary\">merged</span>"));
|
||||
}
|
||||
|
||||
/// The break this catches: an issue drawn with a pull request's mark or diff counts, its labels
|
||||
/// left out, or the pull request on it not named.
|
||||
#[test]
|
||||
fn an_issue_row_shows_its_labels_and_its_pull_request() {
|
||||
let mut issue = item();
|
||||
issue["pull_request"] = json!(false);
|
||||
issue["facts"]["labels"] = json!([{"name": "bug", "color": "d73a4a"}]);
|
||||
issue["facts"]["linked_pull_request"] = json!(9);
|
||||
let html = drawn(issue.clone());
|
||||
assert!(html.contains("data-pull=\"false\""), "{html}");
|
||||
assert!(html.contains(">IS</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-muted\">bug</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-warning\">W PR #9</span>"), "{html}");
|
||||
assert!(!html.contains("class=\"add\""), "an issue has no diff: {html}");
|
||||
issue["facts"]["linked_pull_request"] = json!(null);
|
||||
issue["facts"]["comments"] = json!(1);
|
||||
assert!(drawn(issue).contains("<span class=\"hue-muted\">1 comment</span>"));
|
||||
}
|
||||
|
||||
/// The break this catches: a row from another repository that doesn't say which, or one from
|
||||
/// this checkout that names it anyway.
|
||||
#[test]
|
||||
fn a_row_names_its_repository_only_when_it_is_elsewhere() {
|
||||
let one = section(vec![item()], Some(1));
|
||||
let here = list(&an_hour_after(changed()), HERE, &one);
|
||||
assert!(!here.contains("<span class=\"hue-muted\">nora-quinn/luxe-dev</span>"), "{here}");
|
||||
let elsewhere = list(&an_hour_after(changed()), Some("someone/else"), &one);
|
||||
let named = "<span class=\"hue-muted\">nora-quinn/luxe-dev</span>";
|
||||
assert!(elsewhere.contains(named), "{elsewhere}");
|
||||
}
|
||||
|
||||
/// The break this catches: a count that hides how many more GitHub has, says "of" when there
|
||||
/// are no more, or runs a big number together.
|
||||
#[test]
|
||||
fn the_count_says_how_many_of_how_many() {
|
||||
let cx = an_hour_after(0);
|
||||
let count = |total| list(&cx, HERE, §ion(vec![item()], total));
|
||||
assert!(count(Some(3250)).contains(">1 of 3,250</p>"), "{}", count(Some(3250)));
|
||||
assert!(count(Some(120_000)).contains(">1 of 120,000</p>"), "{}", count(Some(120_000)));
|
||||
assert!(count(Some(1)).contains(">1 shown</p>"), "{}", count(Some(1)));
|
||||
assert!(count(None).contains(">1 shown</p>"), "{}", count(None));
|
||||
}
|
||||
|
||||
/// The break this catches: an empty tab drawn as a blank, or a failed search's reason lost or
|
||||
/// let through unescaped.
|
||||
#[test]
|
||||
fn an_empty_or_failed_tab_says_so() {
|
||||
let cx = an_hour_after(0);
|
||||
let empty = list(&cx, HERE, §ion(Vec::new(), Some(0)));
|
||||
assert_eq!(empty, "<p class=\"gh-note dim\">Nothing matches this search</p>");
|
||||
let mut failed = section(Vec::new(), None);
|
||||
failed.error = Some("gh <auth> failed".into());
|
||||
let html = list(&cx, HERE, &failed);
|
||||
assert_eq!(html, "<p class=\"gh-note hue-error\">gh <auth> failed</p>");
|
||||
}
|
||||
|
||||
/// The break this catches: a stranger's title reaching the page as markup.
|
||||
#[test]
|
||||
fn a_title_is_escaped() {
|
||||
let mut hostile = item();
|
||||
hostile["title"] = json!("<img src=x onerror=alert(1)>");
|
||||
let html = drawn(hostile);
|
||||
assert!(html.contains("<img"), "{html}");
|
||||
assert!(!html.contains("<img"), "{html}");
|
||||
}
|
||||
171
crates/luxe-remote/src/render/github/tests/overview.rs
Normal file
171
crates/luxe-remote/src/render/github/tests/overview.rs
Normal file
@@ -0,0 +1,171 @@
|
||||
use super::an_hour_after;
|
||||
use crate::render::github::{header, overview};
|
||||
use luxe_core::github::overview::Overview;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// A `github_overview_read` frame's overview, copied from a live session, its long dependabot
|
||||
/// body cut to its first line.
|
||||
const PULL_REQUEST: &str = r#"{"kind": "pull_request", "overview": {"number": 235, "node_id": "PR_kwDOTyoMn88AAAABHrSs7g", "title": "ci: bump the actions group across 1 directory with 2 updates", "body": "Bumps the actions group with 2 updates.", "url": "https://github.com/nora-quinn/luxe-dev/pull/235", "repository": "nora-quinn/luxe-dev", "author": {"login": "dependabot", "bot": true}, "state": "open", "draft": false, "base_ref": "master", "head_ref": "dependabot/github_actions/actions-9d10962cbb", "head_oid": "60e64cfa2f3a722e189a82e06dc3be3808b548a5", "cross_repository": false, "additions": 8, "deletions": 8, "changed_files": 4, "commits": 1, "updated_at": 1792259399, "labels": [{"name": "dependencies", "color": "0366d6"}, {"name": "github_actions", "color": "000000"}], "merge_status": "unknown", "review_decision": null, "reviewers": [], "checks": {"passed": 8, "failed": 0, "pending": 0, "skipped": 0}, "failing": [], "unresolved_threads": 0, "stack": null, "viewer": {"author": false, "can_push": true, "can_merge": true}, "merge_methods": ["merge", "squash", "rebase"], "merge_settings": {"last_method": "merge", "deletes_branch": false, "can_auto_merge": false, "can_cancel_auto_merge": false, "auto_merge": null}, "conversation_count": 1}}"#;
|
||||
|
||||
/// An issue's overview in core's shape; the repository the session ran in has no issues to copy.
|
||||
const ISSUE: &str = r#"{"kind": "issue", "overview": {"number": 41, "title": "Crash on start", "body": "It crashes.", "url": "https://github.com/o/r/issues/41", "repository": "o/r", "author": {"login": "mara", "bot": false}, "state": "open", "updated_at": 1792259399, "labels": [], "assignees": [], "milestone": null, "linked": [], "conversation_count": 0}}"#;
|
||||
|
||||
const CHANGED: u64 = 1_792_259_399;
|
||||
|
||||
fn value(json: &str) -> Value {
|
||||
serde_json::from_str(json).expect("an overview as core sends it")
|
||||
}
|
||||
|
||||
fn parsed(value: Value) -> Overview {
|
||||
serde_json::from_value(value).expect("an overview as core sends it")
|
||||
}
|
||||
|
||||
fn headed(value: Value) -> String {
|
||||
header(&an_hour_after(CHANGED), &parsed(value))
|
||||
}
|
||||
|
||||
fn sections(value: Value) -> String {
|
||||
overview(&an_hour_after(CHANGED), &parsed(value))
|
||||
}
|
||||
|
||||
/// The break this catches: the number, title, author, branches, size or age left out of the
|
||||
/// header, a bot named as a person, or the state chip in the wrong color.
|
||||
#[test]
|
||||
fn a_pull_requests_header_reads_as_the_tuis() {
|
||||
let html = headed(value(PULL_REQUEST));
|
||||
assert!(html.contains("<span class=\"dim\">#235 </span>ci: bump the actions group"), "{html}");
|
||||
let bot = "<span class=\"hue-muted\">dependabot</span><span class=\"dim\"> bot</span>";
|
||||
assert!(html.contains(bot), "{html}");
|
||||
let branches = "master <span class=\"hue-muted\">\u{2190}</span> dependabot/github_actions";
|
||||
assert!(html.contains(branches), "{html}");
|
||||
assert!(html.contains("<span class=\"add\">+8</span>"), "{html}");
|
||||
assert!(html.contains("in 4 files</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"dim\">3600s ago</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"gh-state hue-success\">open</span>"), "{html}");
|
||||
assert!(html.contains("\u{25cf}</span> dependencies</span>"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: "1 files", or a header that shows every label however many there are.
|
||||
#[test]
|
||||
fn the_header_counts_one_file_and_caps_its_labels() {
|
||||
let mut pull_request = value(PULL_REQUEST);
|
||||
pull_request["overview"]["changed_files"] = json!(1);
|
||||
let labels: Vec<Value> =
|
||||
(1..=5).map(|n| json!({"name": format!("l{n}"), "color": "000000"})).collect();
|
||||
pull_request["overview"]["labels"] = json!(labels);
|
||||
let html = headed(pull_request);
|
||||
assert!(html.contains("in 1 file</span>"), "{html}");
|
||||
assert!(html.contains("> l4</span>"), "{html}");
|
||||
assert!(!html.contains("> l5</span>"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: an issue's header drawn with a pull request's branches, or its closed
|
||||
/// state in the pull request's red.
|
||||
#[test]
|
||||
fn an_issues_header_has_no_branches() {
|
||||
let mut issue = value(ISSUE);
|
||||
issue["overview"]["state"] = json!("closed");
|
||||
let html = headed(issue);
|
||||
assert!(html.contains("<span class=\"dim\">#41 </span>Crash on start"), "{html}");
|
||||
assert!(!html.contains('\u{2190}'), "{html}");
|
||||
assert!(html.contains("<span class=\"gh-state hue-secondary\">closed</span>"), "{html}");
|
||||
}
|
||||
|
||||
/// The break this catches: a blocker drawn with a passing mark or quiet, the count of what's
|
||||
/// incomplete dropped, or the stack's "open #N" (the one action that only reads) missing.
|
||||
#[test]
|
||||
fn the_status_marks_what_blocks_a_merge() {
|
||||
let mut draft = value(PULL_REQUEST);
|
||||
draft["overview"]["draft"] = json!(true);
|
||||
draft["overview"]["stack"] = json!({"trunk": "master", "trunk_is_default": true, "above": [],
|
||||
"below": [{"number": 230, "title": "base", "head_ref": "base", "draft": false, "checked": true}]});
|
||||
let html = sections(draft);
|
||||
assert!(
|
||||
html.contains("<h3 class=\"gh-section\">Status<span class=\"gh-right dim\">"),
|
||||
"{html}"
|
||||
);
|
||||
assert!(html.contains("incomplete</span></h3>"), "{html}");
|
||||
let blocker = "<span class=\"gh-mark hue-error\">N</span><span class=\"gh-label\">Draft</span>\
|
||||
<span class=\"gh-evidence\"><span class=\"\">still a draft</span>";
|
||||
assert!(html.contains(blocker), "{html}");
|
||||
let open = "<button type=\"button\" class=\"gh-open\" data-number=\"230\" data-pull=\"true\">\
|
||||
open #230</button>";
|
||||
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("<span class=\"gh-mark hue-success\">Y</span><span class=\"gh-label\">Checks"));
|
||||
assert!(html.contains("<span class=\"hue-muted\">"), "{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</span></h3>"), "{html}");
|
||||
assert!(html.contains("<span class=\"gh-label\">mara</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-success\">approved</span>"), "{html}");
|
||||
assert!(html.contains("\u{b7} 3600s ago"), "{html}");
|
||||
assert!(html.contains(
|
||||
"<span class=\"hue-error\">changes requested</span><span class=\"dim\"> \u{b7} team</span>"
|
||||
));
|
||||
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("<md>R:one\n\ntwo\nthree\nfour\nfive\n</md>"), "{long}");
|
||||
let more = "data-tab=\"conversation\">… 2 more lines in Conversation</button>";
|
||||
assert!(long.contains(more), "{long}");
|
||||
let short = body("one\ntwo\nthree\nfour\nfive");
|
||||
assert!(short.contains("five\n</md>") && !short.contains("gh-more"), "{short}");
|
||||
assert!(body(" ").contains("<p class=\"gh-note dim\">No description</p>"));
|
||||
}
|
||||
|
||||
/// 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("<span class=\"hue-muted\">unassigned</span>"), "{html}");
|
||||
assert!(html.contains("<span class=\"hue-muted\">none yet</span>"), "{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("<span class=\"hue-secondary\">mara, jo</span>"), "{html}");
|
||||
assert!(html.contains("data-number=\"7\" data-pull=\"true\">#7</button>"), "{html}");
|
||||
assert!(!html.contains("data-number=\"8\""), "{html}");
|
||||
assert!(
|
||||
html.contains("<span class=\"gh-label\">Milestone</span><span class=\"gh-evidence\">v1")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user