aboutsummaryrefslogtreecommitdiff
path: root/src/client/shell/tests/mod.rs
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-09-13 20:17:42 +0400
committerGitHub <noreply@github.com>2026-09-13 18:17:42 +0200
commit5f26879bcd4190750c79cbff92454e400166ca98 (patch)
tree5843579cb70ad81b3dc102294496cdc6868e99da /src/client/shell/tests/mod.rs
parent981fe83ca2e23474255f4cacc4da2814f9de0744 (diff)
fix(ui): keep muted sidebar and tab labels readable (#4062)
refs #2692
Diffstat (limited to 'src/client/shell/tests/mod.rs')
-rw-r--r--src/client/shell/tests/mod.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/client/shell/tests/mod.rs b/src/client/shell/tests/mod.rs
index 497ce2c6..a308c1f9 100644
--- a/src/client/shell/tests/mod.rs
+++ b/src/client/shell/tests/mod.rs
@@ -133,6 +133,41 @@ fn surface() -> PaneSurfaceFrame {
}
}
+fn frame_rows(frame: &FrameData) -> Vec<String> {
+ frame
+ .cells
+ .chunks(frame.width as usize)
+ .map(|row| row.iter().map(|cell| cell.symbol.as_str()).collect())
+ .collect()
+}
+
+/// Absolute cell position of `needle` inside `area`, for style assertions.
+fn cell_symbol_position(frame: &FrameData, area: Rect, needle: &str) -> (u16, u16) {
+ let rows = frame_rows(frame);
+ for y in area.y..area.bottom().min(frame.height) {
+ let row = &rows[y as usize];
+ let slice = row
+ .chars()
+ .skip(area.x as usize)
+ .take(area.width as usize)
+ .collect::<String>();
+ if let Some(byte) = slice.find(needle) {
+ let column = slice[..byte].chars().count() as u16 + area.x;
+ return (column, y);
+ }
+ }
+ let visible = (area.y..area.bottom().min(frame.height))
+ .map(|y| {
+ rows[y as usize]
+ .chars()
+ .skip(area.x as usize)
+ .take(area.width as usize)
+ .collect::<String>()
+ })
+ .collect::<Vec<_>>();
+ panic!("symbol {needle:?} not found in {area:?}: {visible:?}");
+}
+
fn pane_scroll_result(
offset_from_bottom: u64,
max_offset_from_bottom: u64,