use super::{Section, Target, detail};
use crate::{store::RunView, test_request::request};
use serde_json::json;
#[test]
fn eval_detail_keeps_request_instruction_and_result_outside_technical() {
let request = request(
"app/check",
"GREEN",
json!({
"payload":{"instruction":"Check the release notes."},
"result":{"verdict":"GREEN","note":"Release notes match."},
"fingerprint":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"key":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
}),
);
let run: RunView = serde_json::from_value(json!({
"id":"run-1",
"repoPath":crate::test_os::temp_root().join("repo"),
"stateDir":crate::test_os::temp_root().join("state"),
"status":"GREEN",
"createdAt":"2026-01-01T00:00:00Z",
"completedAt":"2026-01-01T00:00:01Z",
"selection":{"kind":"all"},
"definitions":{"artifacts":{},"evals":[]},
"validation":null,
"requests":[request.request]
}))
.unwrap();
let target = Target::Eval("app/check".parse().unwrap());
let now = run.run.created_at.time();
let detail = detail(&run, &[request], &target, now);
let visible = detail
.fields
.iter()
.filter(|(key, _)| Section::of(key) != Section::Technical)
.map(|(key, value)| (*key, value.as_str()))
.collect::<Vec<_>>();
assert!(visible.contains(&("Request", "run-1-app-check")));
assert!(visible.contains(&("Instruction", "Check the release notes.")));
let result = visible
.iter()
.find_map(|(key, value)| (*key == "Result").then_some(*value))
.expect("the result is visible without unfolding Technical");
assert!(result.contains("GREEN"));
assert!(result.contains("Release notes match."));
for key in ["Fingerprint", "Key"] {
assert!(detail.field(key).is_some_and(|value| !value.is_empty()));
assert!(!visible.iter().any(|(name, _)| *name == key));
}
}
#[test]
fn artifact_detail_groups_waits_without_dropping_equal_eval_names() {
let run: RunView = serde_json::from_value(json!({
"id":"run-1",
"repoPath":crate::test_os::temp_root().join("repo"),
"stateDir":crate::test_os::temp_root().join("state"),
"status":"INCOMPLETE",
"createdAt":"2026-01-01T00:00:00Z",
"completedAt":"2026-01-01T00:00:01Z",
"selection":{"kind":"all"},
"definitions":{
"artifacts":{"app":{"name":"app"},"plan":{"name":"plan"},"reference":{"name":"reference"}},
"evals":[
{"id":"app/first","target":"app","deps":["plan","reference"]},
{"id":"app/second","target":"app","deps":["plan"]},
{"id":"plan/check","target":"plan","deps":[]},
{"id":"reference/check","target":"reference","deps":[]}
]
},
"validation":null,
"requests":[]
}))
.unwrap();
let target = Target::Artifact("app".parse().unwrap());
let shown = detail(&run, &[], &target, run.run.created_at.time());
let waits = shown
.field("Waits for")
.expect("the Artifact exposes its evals' waits");
assert_eq!(
waits
.lines()
.filter(|line| line.starts_with("↑ plan "))
.count(),
1
);
assert_eq!(
waits
.lines()
.filter(|line| line.starts_with("↑ reference "))
.count(),
1
);
assert_eq!(
waits.lines().filter(|line| line.starts_with(" ")).count(),
2,
"equal pending eval names from different inputs both remain visible"
);
assert!(waits.contains("check not in this Run"), "{waits}");
assert_eq!(Section::of("Waits for"), Section::Waits);
}