chore: delete chatwidget::tests::binary_size_transcript_snapshot tui test (#6759)
We're running into quite a bit of drag maintaining this test, since every time we add fields to an EventMsg that happened to be dumped into the `binary-size-log.jsonl` fixture, this test starts to fail. The fix is usually to either manually update the `binary-size-log.jsonl` fixture file, or update the `upgrade_event_payload_for_tests` function to map the data in that file into something workable. Eason says it's fine to delete this test, so let's just delete it
This commit is contained in:
parent
a941ae7632
commit
ae2a084fae
2 changed files with 0 additions and 24362 deletions
|
|
@ -12,7 +12,6 @@ use codex_core::CodexAuth;
|
|||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigOverrides;
|
||||
use codex_core::config::ConfigToml;
|
||||
use codex_core::config::OPENAI_DEFAULT_MODEL;
|
||||
use codex_core::protocol::AgentMessageDeltaEvent;
|
||||
use codex_core::protocol::AgentMessageEvent;
|
||||
use codex_core::protocol::AgentReasoningDeltaEvent;
|
||||
|
|
@ -53,9 +52,6 @@ use crossterm::event::KeyEvent;
|
|||
use crossterm::event::KeyModifiers;
|
||||
use insta::assert_snapshot;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::fs::File;
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::path::PathBuf;
|
||||
use tempfile::NamedTempFile;
|
||||
use tempfile::tempdir;
|
||||
|
|
@ -74,70 +70,6 @@ fn test_config() -> Config {
|
|||
.expect("config")
|
||||
}
|
||||
|
||||
// Backward-compat shim for older session logs that predate the
|
||||
// `formatted_output` field on ExecCommandEnd events.
|
||||
fn upgrade_event_payload_for_tests(mut payload: serde_json::Value) -> serde_json::Value {
|
||||
if let Some(obj) = payload.as_object_mut()
|
||||
&& let Some(msg) = obj.get_mut("msg")
|
||||
&& let Some(m) = msg.as_object_mut()
|
||||
{
|
||||
let ty = m.get("type").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if ty == "exec_command_end" {
|
||||
let stdout = m.get("stdout").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let stderr = m.get("stderr").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let aggregated = if stderr.is_empty() {
|
||||
stdout.to_string()
|
||||
} else {
|
||||
format!("{stdout}{stderr}")
|
||||
};
|
||||
if !m.contains_key("formatted_output") {
|
||||
m.insert(
|
||||
"formatted_output".to_string(),
|
||||
serde_json::Value::String(aggregated.clone()),
|
||||
);
|
||||
}
|
||||
if !m.contains_key("aggregated_output") {
|
||||
m.insert(
|
||||
"aggregated_output".to_string(),
|
||||
serde_json::Value::String(aggregated),
|
||||
);
|
||||
}
|
||||
} else if ty == "patch_apply_begin"
|
||||
&& let Some(changes) = m.get_mut("changes").and_then(|v| v.as_object_mut())
|
||||
{
|
||||
for change in changes.values_mut() {
|
||||
if change.get("type").is_some() {
|
||||
continue;
|
||||
}
|
||||
if let Some(change_obj) = change.as_object_mut()
|
||||
&& change_obj.len() == 1
|
||||
&& let Some((legacy_kind, legacy_value)) = change_obj
|
||||
.iter()
|
||||
.next()
|
||||
.map(|(k, v)| (k.clone(), v.clone()))
|
||||
{
|
||||
change_obj.clear();
|
||||
change_obj.insert(
|
||||
"type".to_string(),
|
||||
serde_json::Value::String(legacy_kind.clone()),
|
||||
);
|
||||
match legacy_value {
|
||||
serde_json::Value::Object(payload) => {
|
||||
for (k, v) in payload {
|
||||
change_obj.insert(k, v);
|
||||
}
|
||||
}
|
||||
other => {
|
||||
change_obj.insert("content".to_string(), other);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
payload
|
||||
}
|
||||
|
||||
fn snapshot(percent: f64) -> RateLimitSnapshot {
|
||||
RateLimitSnapshot {
|
||||
primary: Some(RateLimitWindow {
|
||||
|
|
@ -718,30 +650,6 @@ fn active_blob(chat: &ChatWidget) -> String {
|
|||
lines_to_single_string(&lines)
|
||||
}
|
||||
|
||||
fn open_fixture(name: &str) -> File {
|
||||
// 1) Prefer fixtures within this crate
|
||||
{
|
||||
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
p.push("tests");
|
||||
p.push("fixtures");
|
||||
p.push(name);
|
||||
if let Ok(f) = File::open(&p) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
// 2) Fallback to parent (workspace root)
|
||||
{
|
||||
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
p.push("..");
|
||||
p.push(name);
|
||||
if let Ok(f) = File::open(&p) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
// 3) Last resort: CWD
|
||||
File::open(name).expect("open fixture file")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_enter_during_task_does_not_queue() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual();
|
||||
|
|
@ -1726,167 +1634,6 @@ fn disabled_slash_command_while_task_running_snapshot() {
|
|||
assert_snapshot!(blob);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn binary_size_transcript_snapshot() {
|
||||
// the snapshot in this test depends on gpt-5-codex. Skip for now. We will consider
|
||||
// creating snapshots for other models in the future.
|
||||
if OPENAI_DEFAULT_MODEL != "gpt-5-codex" {
|
||||
return;
|
||||
}
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
|
||||
|
||||
// Set up a VT100 test terminal to capture ANSI visual output
|
||||
let width: u16 = 80;
|
||||
let height: u16 = 2000;
|
||||
let viewport = Rect::new(0, height - 1, width, 1);
|
||||
let backend = VT100Backend::new(width, height);
|
||||
let mut terminal = crate::custom_terminal::Terminal::with_options(backend)
|
||||
.expect("failed to construct terminal");
|
||||
terminal.set_viewport_area(viewport);
|
||||
|
||||
// Replay the recorded session into the widget and collect transcript
|
||||
let file = open_fixture("binary-size-log.jsonl");
|
||||
let reader = BufReader::new(file);
|
||||
let mut transcript = String::new();
|
||||
let mut has_emitted_history = false;
|
||||
|
||||
for line in reader.lines() {
|
||||
let line = line.expect("read line");
|
||||
if line.trim().is_empty() || line.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
let Ok(v): Result<serde_json::Value, _> = serde_json::from_str(&line) else {
|
||||
continue;
|
||||
};
|
||||
let Some(dir) = v.get("dir").and_then(|d| d.as_str()) else {
|
||||
continue;
|
||||
};
|
||||
if dir != "to_tui" {
|
||||
continue;
|
||||
}
|
||||
let Some(kind) = v.get("kind").and_then(|k| k.as_str()) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
match kind {
|
||||
"codex_event" => {
|
||||
if let Some(payload) = v.get("payload") {
|
||||
let ev: Event =
|
||||
serde_json::from_value(upgrade_event_payload_for_tests(payload.clone()))
|
||||
.expect("parse");
|
||||
let ev = match ev {
|
||||
Event {
|
||||
msg: EventMsg::ExecCommandBegin(e),
|
||||
..
|
||||
} => {
|
||||
// Re-parse the command
|
||||
let parsed_cmd = codex_core::parse_command::parse_command(&e.command);
|
||||
Event {
|
||||
id: ev.id,
|
||||
msg: EventMsg::ExecCommandBegin(ExecCommandBeginEvent {
|
||||
call_id: e.call_id.clone(),
|
||||
command: e.command,
|
||||
cwd: e.cwd,
|
||||
parsed_cmd,
|
||||
source: ExecCommandSource::Agent,
|
||||
interaction_input: e.interaction_input.clone(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
_ => ev,
|
||||
};
|
||||
chat.handle_codex_event(ev);
|
||||
while let Ok(app_ev) = rx.try_recv() {
|
||||
if let AppEvent::InsertHistoryCell(cell) = app_ev {
|
||||
let mut lines = cell.display_lines(width);
|
||||
if has_emitted_history
|
||||
&& !cell.is_stream_continuation()
|
||||
&& !lines.is_empty()
|
||||
{
|
||||
lines.insert(0, "".into());
|
||||
}
|
||||
has_emitted_history = true;
|
||||
transcript.push_str(&lines_to_single_string(&lines));
|
||||
crate::insert_history::insert_history_lines(&mut terminal, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"app_event" => {
|
||||
if let Some(variant) = v.get("variant").and_then(|s| s.as_str())
|
||||
&& variant == "CommitTick"
|
||||
{
|
||||
chat.on_commit_tick();
|
||||
while let Ok(app_ev) = rx.try_recv() {
|
||||
if let AppEvent::InsertHistoryCell(cell) = app_ev {
|
||||
let mut lines = cell.display_lines(width);
|
||||
if has_emitted_history
|
||||
&& !cell.is_stream_continuation()
|
||||
&& !lines.is_empty()
|
||||
{
|
||||
lines.insert(0, "".into());
|
||||
}
|
||||
has_emitted_history = true;
|
||||
transcript.push_str(&lines_to_single_string(&lines));
|
||||
crate::insert_history::insert_history_lines(&mut terminal, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the final VT100 visual by parsing the ANSI stream. Trim trailing spaces per line
|
||||
// and drop trailing empty lines so the shape matches the ideal fixture exactly.
|
||||
let screen = terminal.backend().vt100().screen();
|
||||
let mut lines: Vec<String> = Vec::with_capacity(height as usize);
|
||||
for row in 0..height {
|
||||
let mut s = String::with_capacity(width as usize);
|
||||
for col in 0..width {
|
||||
if let Some(cell) = screen.cell(row, col) {
|
||||
if let Some(ch) = cell.contents().chars().next() {
|
||||
s.push(ch);
|
||||
} else {
|
||||
s.push(' ');
|
||||
}
|
||||
} else {
|
||||
s.push(' ');
|
||||
}
|
||||
}
|
||||
// Trim trailing spaces to match plain text fixture
|
||||
lines.push(s.trim_end().to_string());
|
||||
}
|
||||
while lines.last().is_some_and(std::string::String::is_empty) {
|
||||
lines.pop();
|
||||
}
|
||||
// Consider content only after the last session banner marker. Skip the transient
|
||||
// 'thinking' header if present, and start from the first non-empty content line
|
||||
// that follows. This keeps the snapshot stable across sessions.
|
||||
const MARKER_PREFIX: &str = "To get started, describe a task or try one of these commands:";
|
||||
let last_marker_line_idx = lines
|
||||
.iter()
|
||||
.rposition(|l| l.trim_start().starts_with(MARKER_PREFIX))
|
||||
.expect("marker not found in visible output");
|
||||
// Prefer the first assistant content line (blockquote '>' prefix) after the marker;
|
||||
// fallback to the first non-empty, non-'thinking' line.
|
||||
let start_idx = (last_marker_line_idx + 1..lines.len())
|
||||
.find(|&idx| lines[idx].trim_start().starts_with('•'))
|
||||
.unwrap_or_else(|| {
|
||||
(last_marker_line_idx + 1..lines.len())
|
||||
.find(|&idx| {
|
||||
let t = lines[idx].trim_start();
|
||||
!t.is_empty() && t != "thinking"
|
||||
})
|
||||
.expect("no content line found after marker")
|
||||
});
|
||||
|
||||
// Snapshot the normalized visible transcript following the banner.
|
||||
assert_snapshot!("binary_size_ideal_response", lines[start_idx..].join("\n"));
|
||||
}
|
||||
|
||||
//
|
||||
// Snapshot test: command approval modal
|
||||
//
|
||||
|
|
|
|||
24109
codex-rs/tui/tests/fixtures/binary-size-log.jsonl
vendored
24109
codex-rs/tui/tests/fixtures/binary-size-log.jsonl
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue