test: the agent chat's long-message layout check waits for agent detection (#3349)
`a_long_message_keeps_the_buttons_in_the_window` failed now and then on CI (Send 914.5 -> 888.5, also on #2893): looking for agents runs on its own thread, and what it finds (and the status it reports) can land between the two measurements and change what is around the panel. The test now waits for the search to finish and measures the buttons from the panel's bottom, which is what the box growing upwards keeps fixed. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1414,24 +1414,35 @@ fn an_agents_markdown_is_drawn_as_blocks() {
|
||||
}
|
||||
|
||||
/// A long message scrolls inside its box: the buttons under the box stay in the window (#2224).
|
||||
/// Measured against the panel's bottom once the agents on this machine have been looked for:
|
||||
/// what that finds (and the status it reports) arrives in its own time and may change what is
|
||||
/// around the panel, which is not what this checks.
|
||||
#[test]
|
||||
fn a_long_message_keeps_the_buttons_in_the_window() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.call("ui.resize", json!({"width": 1600.0, "height": 1000.0}));
|
||||
h.call("ui.agent_chat", json!({"open": true}));
|
||||
h.frames(8);
|
||||
let began = std::time::Instant::now();
|
||||
while h.app.agent_chat.detecting.is_some() && began.elapsed() < std::time::Duration::from_secs(30) {
|
||||
h.frame();
|
||||
std::thread::sleep(std::time::Duration::from_millis(5));
|
||||
}
|
||||
h.frames(4);
|
||||
let bottom = |h: &crate::scenario::Harness| f64::from(h.app.agent_chat.panel_rect.map(|r| r.bottom()).expect("the panel is drawn"));
|
||||
let [_, rest] = h.widget("Send").expect("the Send button is drawn");
|
||||
let box_before = h.app.agent_chat.panel_rect.map(|r| r.bottom());
|
||||
let rest = bottom(&h) - rest;
|
||||
h.app.agent_chat.input = "Please make the plate thicker and then add a fillet on every outside edge.\n".repeat(60);
|
||||
h.frames(8);
|
||||
let window = 1000.0;
|
||||
for name in ["Send", "Attach view"] {
|
||||
let [_, y] = h.widget(name).unwrap_or_else(|| panic!("{name} is drawn"));
|
||||
assert!(y < window, "{name} is at {y}, below the window's bottom at {window}");
|
||||
// The box is pinned to the bottom and grows upwards: the buttons do not move.
|
||||
assert!((y - rest).abs() < 1.0, "{name} moved from {rest} to {y}");
|
||||
// The box is pinned to the bottom and grows upwards: the buttons stay where they were
|
||||
// above the panel's bottom.
|
||||
let above = bottom(&h) - y;
|
||||
assert!((above - rest).abs() < 1.0, "{name} moved from {rest} to {above} above the panel's bottom");
|
||||
}
|
||||
assert_eq!(h.app.agent_chat.panel_rect.map(|r| r.bottom()), box_before, "the panel keeps its size");
|
||||
}
|
||||
|
||||
fn test_png(colour: [u8; 4], width: u32) -> Vec<u8> {
|
||||
|
||||
Reference in New Issue
Block a user