From 33abe01cc3843adcdf5ada65cbb751e12f74c479 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Sat, 30 May 2026 17:25:26 -0300 Subject: [PATCH] test(tui): preserve normalized snapshot newlines --- codex-rs/tui/src/chatwidget/tests/helpers.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/codex-rs/tui/src/chatwidget/tests/helpers.rs b/codex-rs/tui/src/chatwidget/tests/helpers.rs index e77e050a16..19f605b87b 100644 --- a/codex-rs/tui/src/chatwidget/tests/helpers.rs +++ b/codex-rs/tui/src/chatwidget/tests/helpers.rs @@ -65,7 +65,8 @@ pub(super) fn normalize_snapshot_paths(text: impl Into) -> String { /// Normalizes platform-specific test paths without collapsing box alignment. pub(super) fn normalize_box_snapshot_paths(text: &str) -> String { - text.lines() + let mut normalized = text + .lines() .map(|rendered| { let normalized = normalize_snapshot_paths(rendered); let padding = rendered @@ -79,7 +80,11 @@ pub(super) fn normalize_box_snapshot_paths(text: &str) -> String { } }) .collect::>() - .join("\n") + .join("\n"); + if text.ends_with('\n') { + normalized.push('\n'); + } + normalized } pub(super) fn normalized_backend_snapshot(value: &T) -> String { @@ -90,7 +95,7 @@ pub(super) fn normalized_backend_snapshot(value: &T) -> St return rendered; } - rendered + let mut normalized = rendered .lines() .map(|line| { if let Some(content) = line @@ -105,7 +110,11 @@ pub(super) fn normalized_backend_snapshot(value: &T) -> St } }) .collect::>() - .join("\n") + .join("\n"); + if rendered.ends_with('\n') { + normalized.push('\n'); + } + normalized } pub(super) fn invalid_value(