test(tui): avoid Windows Instant underflow

Make the sidebar expiry test avoid subtracting from a fresh Instant on Windows runners, falling back to a short sleep only when an older Instant cannot be represented.
This commit is contained in:
Hunter Bown
2026-05-14 07:33:02 -05:00
committed by GitHub
parent 8fd82be1ee
commit 89e78d75db
+12 -4
View File
@@ -2037,10 +2037,8 @@ mod tests {
})),
);
app.active_cell = Some(active);
app.active_tool_entry_completed_at.insert(
0,
Instant::now() - ACTIVE_TOOL_COMPLETED_ROW_TTL - Duration::from_secs(1),
);
let expired_at = instant_older_than(ACTIVE_TOOL_COMPLETED_ROW_TTL + Duration::from_secs(1));
app.active_tool_entry_completed_at.insert(0, expired_at);
let text = lines_to_text(&task_panel_lines(&app, 64, 8));
@@ -2050,6 +2048,16 @@ mod tests {
);
}
fn instant_older_than(age: Duration) -> Instant {
if let Some(instant) = Instant::now().checked_sub(age) {
return instant;
}
let instant = Instant::now();
std::thread::sleep(age);
instant
}
#[test]
fn tasks_panel_lingers_fresh_completed_active_tool_rows() {
let mut app = create_test_app();