Skip to content

Commit c45c4f3

Browse files
committed
test(tui): isolate render geometry from global state
1 parent 8ca9b99 commit c45c4f3

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

crates/jcode-tui/src/tui/app/tests/scroll_copy_01/part_01.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ fn create_scroll_test_app(
3333
crate::tui::mermaid::clear_streaming_preview_diagram();
3434

3535
let mut app = create_test_app();
36+
if diagrams == 0 {
37+
// Process-global diagrams can be registered by sibling tests after the
38+
// clear above. Keep text-only geometry deterministic at the App level.
39+
app.diagram_mode = crate::config::DiagramDisplayMode::Off;
40+
app.diagram_pane_enabled = false;
41+
}
3642
let content = App::build_scroll_test_content(diagrams, padding, None);
3743
app.display_messages = vec![
3844
DisplayMessage {
@@ -365,6 +371,7 @@ fn test_chat_native_scrollbar_hides_scroll_counters() {
365371

366372
#[test]
367373
fn test_streaming_repaint_does_not_leave_bracket_artifact() {
374+
let _render_lock = scroll_render_test_lock();
368375
let mut app = create_test_app();
369376
let backend = ratatui::backend::TestBackend::new(90, 20);
370377
let mut terminal = ratatui::Terminal::new(backend).expect("failed to create test terminal");
@@ -975,6 +982,7 @@ fn test_prompt_jump_ctrl_brackets() {
975982
#[cfg(target_os = "macos")]
976983
#[test]
977984
fn test_prompt_jump_ctrl_esc_fallback_on_macos() {
985+
let _render_lock = scroll_render_test_lock();
978986
let (mut app, mut terminal) = create_scroll_test_app(100, 30, 1, 20);
979987

980988
render_and_snap(&app, &mut terminal);

crates/jcode-tui/src/tui/app/tests/scroll_copy_01/part_02.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ fn test_remote_prompt_jump_ctrl_brackets() {
234234
#[cfg(target_os = "macos")]
235235
#[test]
236236
fn test_remote_prompt_jump_ctrl_esc_fallback_on_macos() {
237+
let _render_lock = scroll_render_test_lock();
237238
let (mut app, mut terminal) = create_scroll_test_app(100, 30, 1, 20);
238239
let rt = tokio::runtime::Runtime::new().unwrap();
239240
let _guard = rt.enter();

crates/jcode-tui/src/tui/app/tests/scroll_copy_02/part_02.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ fn test_try_open_link_at_opens_clicked_url_and_sets_notice() {
560560
fn test_mouse_click_in_input_moves_cursor_to_clicked_position() {
561561
let _render_lock = scroll_render_test_lock();
562562
let mut app = create_test_app();
563+
// A persisted first-run state can otherwise replace the composer with the
564+
// suggestion welcome screen, leaving a zero-height input hit target.
565+
app.push_display_message(DisplayMessage::assistant("seed transcript"));
566+
app.diagram_mode = crate::config::DiagramDisplayMode::Off;
567+
app.diagram_pane_enabled = false;
563568
app.input = "hello world".to_string();
564569
app.cursor_pos = app.input.len();
565570
app.set_centered(false);
@@ -630,6 +635,10 @@ fn test_mouse_click_in_main_chat_switches_focus_from_side_panel() {
630635
fn test_mouse_click_in_input_switches_focus_from_side_panel() {
631636
let _render_lock = scroll_render_test_lock();
632637
let mut app = create_test_app();
638+
// Keep first-run suggestions from replacing the composer under test.
639+
app.push_display_message(DisplayMessage::assistant("seed transcript"));
640+
app.diagram_mode = crate::config::DiagramDisplayMode::Off;
641+
app.diagram_pane_enabled = false;
633642
app.diff_mode = crate::config::DiffDisplayMode::Inline;
634643
app.diff_pane_focus = true;
635644
app.side_panel = crate::side_panel::SidePanelSnapshot {
@@ -678,6 +687,10 @@ fn test_mouse_click_in_input_switches_focus_from_side_panel() {
678687
fn test_mouse_click_in_wrapped_input_moves_cursor_to_second_visual_line() {
679688
let _render_lock = scroll_render_test_lock();
680689
let mut app = create_test_app();
690+
// Keep first-run suggestions from replacing the composer under test.
691+
app.push_display_message(DisplayMessage::assistant("seed transcript"));
692+
app.diagram_mode = crate::config::DiagramDisplayMode::Off;
693+
app.diagram_pane_enabled = false;
681694
app.input = "abcdefghij".to_string();
682695
app.cursor_pos = 0;
683696
app.set_centered(false);

crates/jcode-tui/src/tui/app/tests/state_model_poke_02/part_01.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ fn test_handterm_native_scroll_client_roundtrips_over_socket() {
253253
use std::os::unix::net::UnixListener;
254254

255255
let _lock = crate::storage::lock_test_env();
256+
let _render_lock = scroll_render_test_lock();
256257
let dir = tempfile::tempdir().expect("tempdir");
257258
let socket_path = dir.path().join("handterm-scroll.sock");
258259
let listener = UnixListener::bind(&socket_path).expect("bind unix listener");

0 commit comments

Comments
 (0)