diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs index aaa39ecab4..0bb4cc1015 100644 --- a/codex-rs/tui/src/chatwidget/tests.rs +++ b/codex-rs/tui/src/chatwidget/tests.rs @@ -4,6 +4,8 @@ //! the TUI output. Many assertions are snapshot-based so that layout regressions and status/header //! changes show up as stable, reviewable diffs. +mod jobs; + use super::*; use crate::app_event::AppEvent; use crate::app_event::ExitMode; @@ -68,8 +70,6 @@ use codex_app_server_protocol::ServerNotification; use codex_app_server_protocol::SkillSummary; use codex_app_server_protocol::ThreadClosedNotification; use codex_app_server_protocol::ThreadItem as AppServerThreadItem; -use codex_app_server_protocol::ThreadJob; -use codex_app_server_protocol::ThreadJobFiredNotification; use codex_app_server_protocol::Turn as AppServerTurn; use codex_app_server_protocol::TurnCompletedNotification; use codex_app_server_protocol::TurnError as AppServerTurnError; @@ -11772,53 +11772,6 @@ async fn app_server_mcp_startup_failure_renders_warning_history() { ); } -#[tokio::test] -async fn thread_job_fired_renders_prompt_history() { - let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; - - chat.handle_server_notification( - ServerNotification::ThreadJobFired(ThreadJobFiredNotification { - thread_id: ThreadId::new().to_string(), - job: ThreadJob { - id: "job-1".to_string(), - cron_expression: "@after-turn".to_string(), - prompt: "Give me a random animal name.".to_string(), - run_once: false, - created_at: 0, - next_run_at: None, - last_run_at: None, - }, - }), - /*replay_kind*/ None, - ); - - let cells = drain_insert_history(&mut rx); - let rendered = lines_to_single_string(&cells[0]); - assert_snapshot!(rendered, @"• Give me a random animal name. Running thread job • @after-turn -"); -} - -#[tokio::test] -async fn thread_jobs_popup_keeps_selected_job_prompt_visible() { - let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; - - chat.open_thread_jobs_popup( - ThreadId::new(), - vec![ThreadJob { - id: "job-1".to_string(), - cron_expression: "@after-turn".to_string(), - prompt: "Give me a random animal name.".to_string(), - run_once: false, - created_at: 0, - next_run_at: None, - last_run_at: None, - }], - ); - - let popup = render_bottom_popup(&chat, /*width*/ 80); - assert_snapshot!("thread_jobs_popup_keeps_selected_job_prompt_visible", popup); -} - #[tokio::test] async fn app_server_mcp_startup_lag_settles_startup_and_ignores_late_updates() { let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; diff --git a/codex-rs/tui/src/chatwidget/tests/jobs.rs b/codex-rs/tui/src/chatwidget/tests/jobs.rs new file mode 100644 index 0000000000..7646f2c689 --- /dev/null +++ b/codex-rs/tui/src/chatwidget/tests/jobs.rs @@ -0,0 +1,51 @@ +use super::*; +use codex_app_server_protocol::ThreadJob; +use codex_app_server_protocol::ThreadJobFiredNotification; +use insta::assert_snapshot; + +#[tokio::test] +async fn thread_job_fired_renders_prompt_history() { + let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; + + chat.handle_server_notification( + ServerNotification::ThreadJobFired(ThreadJobFiredNotification { + thread_id: ThreadId::new().to_string(), + job: ThreadJob { + id: "job-1".to_string(), + cron_expression: "@after-turn".to_string(), + prompt: "Give me a random animal name.".to_string(), + run_once: false, + created_at: 0, + next_run_at: None, + last_run_at: None, + }, + }), + /*replay_kind*/ None, + ); + + let cells = drain_insert_history(&mut rx); + let rendered = lines_to_single_string(&cells[0]); + assert_snapshot!(rendered, @"• Give me a random animal name. Running thread job • @after-turn +"); +} + +#[tokio::test] +async fn thread_jobs_popup_keeps_selected_job_prompt_visible() { + let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await; + + chat.open_thread_jobs_popup( + ThreadId::new(), + vec![ThreadJob { + id: "job-1".to_string(), + cron_expression: "@after-turn".to_string(), + prompt: "Give me a random animal name.".to_string(), + run_once: false, + created_at: 0, + next_run_at: None, + last_run_at: None, + }], + ); + + let popup = render_bottom_popup(&chat, /*width*/ 80); + assert_snapshot!("thread_jobs_popup_keeps_selected_job_prompt_visible", popup); +} diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__thread_jobs_popup_keeps_selected_job_prompt_visible.snap b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__jobs__thread_jobs_popup_keeps_selected_job_prompt_visible.snap similarity index 84% rename from codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__thread_jobs_popup_keeps_selected_job_prompt_visible.snap rename to codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__jobs__thread_jobs_popup_keeps_selected_job_prompt_visible.snap index b29f19a871..9d7bccdd27 100644 --- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__thread_jobs_popup_keeps_selected_job_prompt_visible.snap +++ b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__jobs__thread_jobs_popup_keeps_selected_job_prompt_visible.snap @@ -1,5 +1,5 @@ --- -source: tui/src/chatwidget/tests.rs +source: tui/src/chatwidget/tests/jobs.rs expression: popup --- Thread jobs