Merge origin/main into the peer-payments branch
main moved under this PR when #120 (clean-look chrome redesign) landed, which touched the same three files (src/tui.rs, tests/tui_spec.rs, docs/TUI.md) and left PR #121 unmergeable. - docs/TUI.md: both sections kept — the peer-payment-history section from this branch, then #120's chrome-redesign section. - tests/tui_spec.rs: #120's `fit_cells` flake relaxation kept (it is a superset of the one on this branch: same cut point plus the ellipsis assertion). - src/tui.rs merged cleanly; `cargo test --locked` 383 passed / 0 failed and `cargo clippy --locked --all-targets -- -D warnings` clean afterwards. The peer-payments frames are byte-identical after the merge, so the dumps in this PR body still hold.
This commit is contained in:
commit
cbe889024b
5 changed files with 1343 additions and 475 deletions
|
|
@ -1,9 +1,11 @@
|
|||
//! Main-screen chrome helpers: ASCII wordmark, compact fallback, help text.
|
||||
|
||||
use onionwire::hs::TorState;
|
||||
use onionwire::qr;
|
||||
use onionwire::tui::{
|
||||
Pane, banner_for_width, compact_banner, draw_share, help_overlay_text, main_footer_hints,
|
||||
onion_glyph, status_footer, wordmark_banner,
|
||||
Pane, TorPhase, banner_for_width, compact_banner, draw_share, help_overlay_text,
|
||||
main_footer_hints, onion_glyph, pane_footer_hints, status_footer, status_footer_compact,
|
||||
status_footer_phased, tor_token, wordmark_banner,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
@ -212,6 +214,102 @@ fn restore_terminal_is_callable_without_panic() {
|
|||
onionwire::tui::restore_terminal();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tor_phase_projects_every_tor_state() {
|
||||
assert_eq!(TorPhase::of(TorState::Bootstrapping), TorPhase::Connecting);
|
||||
assert_eq!(TorPhase::of(TorState::Published), TorPhase::Ready);
|
||||
assert_eq!(
|
||||
TorPhase::of(TorState::DegradedReachable),
|
||||
TorPhase::Degraded
|
||||
);
|
||||
assert_eq!(TorPhase::of(TorState::Stopped), TorPhase::Off);
|
||||
// The phase-free token is still the bare word the chrome tests lock.
|
||||
assert_eq!(tor_token(None), "TOR");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn footer_states_the_tor_phase_with_a_word_not_only_colour() {
|
||||
let fp = "abcdef0123456789deadbeef";
|
||||
let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion";
|
||||
for (phase, word) in [
|
||||
(TorPhase::Connecting, "connecting"),
|
||||
(TorPhase::Ready, "ready"),
|
||||
(TorPhase::Degraded, "degraded"),
|
||||
(TorPhase::Off, "off"),
|
||||
] {
|
||||
assert!(!phase.glyph().is_empty(), "{phase:?} has no glyph");
|
||||
for w in [80u16, 120, 200] {
|
||||
let line = status_footer_phased(w, fp, onion, Some(phase), None, main_footer_hints());
|
||||
assert!(
|
||||
line.contains(word),
|
||||
"{w} footer lacks phase word {word:?}: {line:?}"
|
||||
);
|
||||
assert!(line.contains("TOR"), "{w} footer lacks TOR: {line:?}");
|
||||
assert!(line.contains("me:"), "{w} footer lacks me:: {line:?}");
|
||||
assert!(
|
||||
line.chars().count() <= w as usize,
|
||||
"{w} footer wider than frame: {line:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
// A fail-closed note still wins over the hints, phase or not.
|
||||
let crowded = status_footer_phased(
|
||||
80,
|
||||
fp,
|
||||
onion,
|
||||
Some(TorPhase::Off),
|
||||
Some("send failed: peer onion down"),
|
||||
main_footer_hints(),
|
||||
);
|
||||
assert!(crowded.contains("send failed"), "{crowded:?}");
|
||||
assert!(crowded.contains("off"), "{crowded:?}");
|
||||
assert!(crowded.contains("? help"), "{crowded:?}");
|
||||
assert!(crowded.chars().count() <= 80, "{crowded:?}");
|
||||
}
|
||||
|
||||
/// The main footer has its own variant: the header already prints the identity,
|
||||
/// so the footer drops the onion and keeps `TOR` + `me:` + the hints.
|
||||
#[test]
|
||||
fn compact_footer_drops_the_onion_and_keeps_the_rest() {
|
||||
let fp = "abcdef0123456789deadbeef";
|
||||
let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion";
|
||||
let full = status_footer_phased(80, fp, onion, Some(TorPhase::Ready), None, main_footer_hints());
|
||||
let compact = status_footer_compact(80, fp, Some(TorPhase::Ready), None, main_footer_hints());
|
||||
assert!(full.contains("onion:"), "{full:?}");
|
||||
assert!(!compact.contains("onion:"), "{compact:?}");
|
||||
assert!(compact.contains("TOR"), "{compact:?}");
|
||||
assert!(compact.contains("me:"), "{compact:?}");
|
||||
assert!(compact.contains("? help"), "{compact:?}");
|
||||
assert!(compact.chars().count() <= 80, "{compact:?}");
|
||||
// The cells the onion gave up go to the hints.
|
||||
assert!(
|
||||
compact.chars().count() > 0 && compact.contains("F9"),
|
||||
"compact footer lost the menu key: {compact:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pane_footer_hints_keep_the_menu_and_help_on_every_pane() {
|
||||
let fp = "abcdef0123456789deadbeef";
|
||||
for pane in [Pane::Roster, Pane::Chat, Pane::Composer] {
|
||||
let hints = pane_footer_hints(pane);
|
||||
assert!(hints.contains("F9"), "{pane:?} lost the menu key: {hints:?}");
|
||||
assert!(hints.contains("? help"), "{pane:?} lost ? help: {hints:?}");
|
||||
for w in [80u16, 120, 200] {
|
||||
let line = status_footer_compact(w, fp, Some(TorPhase::Ready), None, hints);
|
||||
assert!(line.contains("F9"), "{pane:?} at {w} lost F9: {line:?}");
|
||||
assert!(
|
||||
line.contains("? help"),
|
||||
"{pane:?} at {w} lost ? help: {line:?}"
|
||||
);
|
||||
assert!(line.chars().count() <= w as usize, "{pane:?} at {w}: {line:?}");
|
||||
}
|
||||
}
|
||||
// The hints actually change with the pane — that is the point of the lever.
|
||||
assert_ne!(pane_footer_hints(Pane::Roster), pane_footer_hints(Pane::Composer));
|
||||
assert_ne!(pane_footer_hints(Pane::Chat), pane_footer_hints(Pane::Composer));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn share_screen_shows_invite_not_qr_at_80x24() {
|
||||
use ratatui::Terminal;
|
||||
|
|
|
|||
|
|
@ -1,55 +1,44 @@
|
|||
//! Visual audit dumps of the current OnionWire TUI.
|
||||
//!
|
||||
//! This crate cannot construct `App` (private, needs `Node` / Arti). Public
|
||||
//! draw path used where it exists (`draw_share`, chrome helpers, overlay copy).
|
||||
//! Main / profile / confirm screens labeled RECONSTRUCTED copy the layout
|
||||
//! constants and copy from `src/tui.rs` so a reviewer can see the shape.
|
||||
//! The main screen is the **real** render path: `draw_main_chrome` takes a
|
||||
//! `MainView` of plain data, so this test draws exactly what `App::draw_main`
|
||||
//! draws (no stand-in layout constants, no stub widget). Screens that are still
|
||||
//! private (`draw_paste`, `draw_rotate`, …) are labelled RECONSTRUCTED and copy
|
||||
//! the layout constants and copy from `src/tui.rs`.
|
||||
//!
|
||||
//! Print frames:
|
||||
//! cargo test --locked --test tui_frames -- --nocapture dump_audit_frames
|
||||
//!
|
||||
//! `chars().count()` width checks here match `tests/tui_chrome.rs` on purpose.
|
||||
//! They are the known-wrong metric (see `chars_count_is_not_terminal_cells`).
|
||||
//! Widths are asserted in terminal **cells** via `onionwire::tui::cell_width`
|
||||
//! (`Span::width`), never `chars().count()`.
|
||||
|
||||
use onionwire::outbox::{OutboxEntry, OutboxStatus};
|
||||
use onionwire::qr;
|
||||
use onionwire::tui::{
|
||||
backup_screen_text, banner_for_width, compact_banner, draw_share, fingerprint_mismatch_banner,
|
||||
help_overlay_text, main_footer_hints, onion_glyph, quit_screen_text, restore_screen_text,
|
||||
rotate_screen_text, status_footer, who_overlay_text, wipe_screen_text, wordmark_banner,
|
||||
ProfileEditor, WipeKind,
|
||||
ChatRowStyle, FriendRow, MainView, Pane, TorPhase, backup_screen_text, banner_for_width,
|
||||
cell_width, chat_no_friends_lines, chat_with_delivery, compact_banner, draw_main_chrome,
|
||||
draw_share, draw_text_overlay, fingerprint_mismatch_banner, help_overlay_text,
|
||||
main_footer_hints, onion_glyph, quit_screen_text, restore_screen_text, rotate_screen_text,
|
||||
status_footer, who_overlay_text, wipe_screen_text, wordmark_banner, ProfileEditor, WipeKind,
|
||||
};
|
||||
use onionwire::FriendProfile;
|
||||
use ratatui::backend::TestBackend;
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
use ratatui::widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Wrap};
|
||||
use onionwire::{FriendProfile, Message};
|
||||
use ratatui::Frame;
|
||||
use ratatui::Terminal;
|
||||
use ratatui::backend::TestBackend;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::{Constraint, Layout};
|
||||
use ratatui::widgets::{Block, Borders, Paragraph, Wrap};
|
||||
|
||||
const SIZES: [(u16, u16); 3] = [(80, 24), (120, 40), (200, 60)];
|
||||
const FP: &str = "abcdef0123456789deadbeefcafebabe";
|
||||
const ONION: &str = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion";
|
||||
const LONG_MSG: &str = "them: this is a very long chat line that should wrap inside the chat pane instead of running off the right edge of an 80-column terminal and colliding with the roster border";
|
||||
|
||||
struct FriendRow {
|
||||
name: &'static str,
|
||||
fp: &'static str,
|
||||
last_ok: bool,
|
||||
}
|
||||
const LONG_BODY: &str = "this is a very long chat line that should wrap inside the chat pane instead of running off the right edge of an 80-column terminal and colliding with the roster border";
|
||||
|
||||
fn fp8(s: &str) -> String {
|
||||
s.chars().take(8).collect()
|
||||
}
|
||||
|
||||
struct MainStandin<'a> {
|
||||
friends: &'a [FriendRow],
|
||||
selected: usize,
|
||||
chat_lines: &'a [&'a str],
|
||||
composer: &'a str,
|
||||
alert: Option<&'a str>,
|
||||
status_note: Option<&'a str>,
|
||||
}
|
||||
|
||||
fn dump_buffer(label: &str, w: u16, h: u16, buf: &ratatui::buffer::Buffer) {
|
||||
fn dump_buffer(label: &str, w: u16, h: u16, buf: &Buffer) {
|
||||
println!();
|
||||
println!("===== {label} {w}x{h} =====");
|
||||
for y in 0..h {
|
||||
|
|
@ -57,10 +46,10 @@ fn dump_buffer(label: &str, w: u16, h: u16, buf: &ratatui::buffer::Buffer) {
|
|||
for x in 0..w {
|
||||
row.push_str(buf[(x, y)].symbol());
|
||||
}
|
||||
let cells = row.chars().count();
|
||||
let cells = cell_width(&row);
|
||||
assert!(
|
||||
cells <= w as usize,
|
||||
"{label} row {y} chars().count()={cells} > {w}: {row:?}"
|
||||
"{label} row {y} width {cells} cells > {w}: {row:?}"
|
||||
);
|
||||
println!("{row}");
|
||||
}
|
||||
|
|
@ -73,158 +62,100 @@ fn draw_to(w: u16, h: u16, label: &str, render: impl FnOnce(&mut Frame)) {
|
|||
dump_buffer(label, w, h, terminal.backend().buffer());
|
||||
}
|
||||
|
||||
fn pane_block(title: &str) -> Block<'_> {
|
||||
// Real `App::pane_block` only changes border/title color. TestBackend
|
||||
// dumps are glyphs, so focused chat/composer look identical to unfocused.
|
||||
Block::default().borders(Borders::ALL).title(title)
|
||||
fn draw_frame(w: u16, h: u16, render: impl FnOnce(&mut Frame)) -> Buffer {
|
||||
let backend = TestBackend::new(w, h);
|
||||
let mut terminal = Terminal::new(backend).expect("terminal");
|
||||
terminal.draw(render).expect("draw");
|
||||
terminal.backend().buffer().clone()
|
||||
}
|
||||
|
||||
/// Layout constants copied from `App::draw_main` (`src/tui.rs`).
|
||||
impl MainStandin<'_> {
|
||||
fn draw(self, f: &mut Frame) {
|
||||
let friends = self.friends;
|
||||
let selected = self.selected;
|
||||
let chat_lines = self.chat_lines;
|
||||
let composer = self.composer;
|
||||
let alert = self.alert;
|
||||
let status_note = self.status_note;
|
||||
let area = f.area();
|
||||
let banner = banner_for_width(area.width);
|
||||
let banner_h = banner.lines().count() as u16;
|
||||
let alert_h = u16::from(alert.is_some());
|
||||
let cols = Layout::vertical([
|
||||
Constraint::Length(banner_h),
|
||||
Constraint::Length(alert_h),
|
||||
Constraint::Min(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(1),
|
||||
])
|
||||
.split(area);
|
||||
|
||||
f.render_widget(Paragraph::new(banner), cols[0]);
|
||||
if let Some(msg) = alert {
|
||||
f.render_widget(Paragraph::new(msg), cols[1]);
|
||||
fn screen_of(buf: &Buffer, w: u16, h: u16) -> String {
|
||||
let mut screen = String::new();
|
||||
for y in 0..h {
|
||||
for x in 0..w {
|
||||
screen.push_str(buf[(x, y)].symbol());
|
||||
}
|
||||
screen.push('\n');
|
||||
}
|
||||
screen
|
||||
}
|
||||
|
||||
let panes =
|
||||
Layout::horizontal([Constraint::Percentage(36), Constraint::Min(10)]).split(cols[2]);
|
||||
// ---------------------------------------------------------------------------
|
||||
// Real main-screen states
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
let stale_n = friends.iter().filter(|fr| !fr.last_ok).count();
|
||||
let roster_title = if stale_n > 0 {
|
||||
format!("roster {} {stale_n} stale", friends.len())
|
||||
} else {
|
||||
format!("roster {}", friends.len())
|
||||
};
|
||||
let items: Vec<ListItem> = friends
|
||||
.iter()
|
||||
.map(|friend| {
|
||||
let mut line = format!("{} {}…", friend.name, fp8(friend.fp));
|
||||
if !friend.last_ok {
|
||||
line.push_str(" stale");
|
||||
}
|
||||
ListItem::new(line)
|
||||
})
|
||||
.collect();
|
||||
let roster = List::new(items)
|
||||
.highlight_symbol("> ")
|
||||
.block(pane_block(&roster_title));
|
||||
let mut roster_state = ListState::default();
|
||||
if !friends.is_empty() {
|
||||
roster_state.select(Some(selected));
|
||||
}
|
||||
f.render_stateful_widget(roster, panes[0], &mut roster_state);
|
||||
fn friend_rows() -> Vec<FriendRow> {
|
||||
vec![
|
||||
FriendRow {
|
||||
label: "alice".into(),
|
||||
fingerprint: "aaaaaaaaaaaaaaaa".into(),
|
||||
stale: false,
|
||||
},
|
||||
FriendRow {
|
||||
label: "bob-the-stale-peer".into(),
|
||||
fingerprint: "bbbbbbbbbbbbbbbb".into(),
|
||||
stale: true,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
let inner_h = panes[1].height.saturating_sub(2);
|
||||
let nlines = chat_lines.len();
|
||||
let overflow = nlines > inner_h as usize && inner_h > 0;
|
||||
let chat_title = {
|
||||
let mut t = match friends.get(selected) {
|
||||
Some(fr) => format!("chat {}", fr.name),
|
||||
None => "chat".to_string(),
|
||||
};
|
||||
if overflow {
|
||||
let end = inner_h as usize;
|
||||
t.push_str(&format!(" 1-{end}/{nlines}"));
|
||||
}
|
||||
t
|
||||
};
|
||||
f.render_widget(
|
||||
Paragraph::new(chat_lines.join("\n"))
|
||||
.wrap(Wrap { trim: false })
|
||||
.block(pane_block(&chat_title)),
|
||||
panes[1],
|
||||
);
|
||||
|
||||
let cmd = if composer.is_empty() {
|
||||
"/wipe /wipe-all /profile /who /pay /tip /file".to_string()
|
||||
} else {
|
||||
composer.to_string()
|
||||
};
|
||||
f.render_widget(Paragraph::new(cmd).block(pane_block("composer")), cols[3]);
|
||||
|
||||
let footer = status_footer(area.width, FP, ONION, status_note, main_footer_hints());
|
||||
f.render_widget(Paragraph::new(footer), cols[4]);
|
||||
fn out_msg(id: i64, body: &str) -> Message {
|
||||
Message {
|
||||
id,
|
||||
dir: "out".into(),
|
||||
plaintext: body.as_bytes().to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Rect math copied from private `draw_text_overlay` (`src/tui.rs`).
|
||||
fn draw_text_overlay_standin(f: &mut Frame, title: &str, text: &str) {
|
||||
let area = f.area();
|
||||
let lines = text.lines().count() as u16 + 2;
|
||||
let text_w = text
|
||||
.lines()
|
||||
.map(|l| l.chars().count() as u16)
|
||||
.max()
|
||||
.unwrap_or(40)
|
||||
.saturating_add(4);
|
||||
let width = text_w.min(area.width.saturating_sub(2)).max(10);
|
||||
let height = lines.min(area.height.saturating_sub(2)).max(3);
|
||||
let popup = Rect {
|
||||
x: area.x + (area.width.saturating_sub(width)) / 2,
|
||||
y: area.y + (area.height.saturating_sub(height)) / 2,
|
||||
width,
|
||||
height,
|
||||
};
|
||||
f.render_widget(Clear, popup);
|
||||
f.render_widget(
|
||||
Paragraph::new(text).block(Block::default().borders(Borders::ALL).title(title)),
|
||||
popup,
|
||||
);
|
||||
fn in_msg(id: i64, body: &str) -> Message {
|
||||
Message {
|
||||
id,
|
||||
dir: "in".into(),
|
||||
plaintext: body.as_bytes().to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_overlay_screen(f: &mut Frame, title: &str, body: &str) {
|
||||
f.render_widget(
|
||||
Paragraph::new(body)
|
||||
.wrap(Wrap { trim: false })
|
||||
.block(Block::default().borders(Borders::ALL).title(title)),
|
||||
f.area(),
|
||||
);
|
||||
fn queued_row(message_id: i64, body: &str, attempts: u32, next_in: i64, now: i64) -> OutboxEntry {
|
||||
OutboxEntry {
|
||||
id: 1,
|
||||
friend_pk: vec![9u8; 32],
|
||||
message_id,
|
||||
body: body.as_bytes().to_vec(),
|
||||
payload: None,
|
||||
attempts,
|
||||
next_attempt_at: now + next_in,
|
||||
created_at: now,
|
||||
status: OutboxStatus::Queued,
|
||||
last_error: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn sample_invite() -> String {
|
||||
qr::encode(&[7u8; 32], ONION, &[1u8; 32]).expect("encode")
|
||||
/// Transcript rows through the real helper: markers included.
|
||||
fn chat_ok() -> Vec<String> {
|
||||
let msgs = [out_msg(1, "ping"), in_msg(2, "pong"), in_msg(3, LONG_BODY)];
|
||||
chat_with_delivery(&msgs, &[], 1000).0
|
||||
}
|
||||
|
||||
fn empty_chat_lines() -> &'static [&'static str] {
|
||||
&["no friends yet", "F3 paste an invite to add one"]
|
||||
/// Transcript with one row still held by the outbox, so the footer carries the
|
||||
/// reachability note instead of a bare `sent`.
|
||||
fn chat_queued() -> (Vec<String>, String) {
|
||||
let now = 1000;
|
||||
let msgs = [out_msg(1, "ping"), in_msg(2, "pong"), out_msg(3, "are you there?")];
|
||||
let pending = [queued_row(3, "are you there?", 1, 45, now)];
|
||||
let (lines, summary) = chat_with_delivery(&msgs, &pending, now);
|
||||
(lines, summary.note().unwrap_or_default())
|
||||
}
|
||||
|
||||
fn empty_chat(phase: TorPhase) -> Vec<String> {
|
||||
chat_no_friends_lines(Some(phase))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dump_audit_frames() {
|
||||
let invite = sample_invite();
|
||||
let friends = [
|
||||
FriendRow {
|
||||
name: "alice",
|
||||
fp: "aaaaaaaaaaaaaaaa",
|
||||
last_ok: true,
|
||||
},
|
||||
FriendRow {
|
||||
name: "bob-the-stale-peer",
|
||||
fp: "bbbbbbbbbbbbbbbb",
|
||||
last_ok: false,
|
||||
},
|
||||
];
|
||||
let chat_ok: [&str; 3] = ["you: ping", "them: pong", LONG_MSG];
|
||||
let invite = qr::encode(&[7u8; 32], ONION, &[1u8; 32]).expect("encode");
|
||||
let friends = friend_rows();
|
||||
let chat = chat_ok();
|
||||
let (queued_chat, queued_note) = chat_queued();
|
||||
let editor = ProfileEditor::new("lance", "tor messenger", "");
|
||||
let profile_body = {
|
||||
let labels = ["name", "bio", "xmr"];
|
||||
|
|
@ -248,7 +179,6 @@ fn dump_audit_frames() {
|
|||
updated_at: 0,
|
||||
}),
|
||||
);
|
||||
let who_empty = who_overlay_text(FP, ONION, None);
|
||||
|
||||
println!("invite payload length (chars) = {}", invite.chars().count());
|
||||
println!("wordmark:\n{}", wordmark_banner());
|
||||
|
|
@ -260,7 +190,7 @@ fn dump_audit_frames() {
|
|||
);
|
||||
|
||||
for (w, h) in SIZES {
|
||||
draw_to(w, h, "chrome banner+footer", |f| {
|
||||
draw_to(w, h, "chrome banner+footer (real helpers)", |f| {
|
||||
let banner = banner_for_width(f.area().width);
|
||||
let banner_h = banner.lines().count() as u16;
|
||||
let chunks = Layout::vertical([
|
||||
|
|
@ -274,100 +204,179 @@ fn dump_audit_frames() {
|
|||
f.render_widget(Paragraph::new(footer), chunks[2]);
|
||||
});
|
||||
|
||||
draw_to(w, h, "chrome long-onion + send-failed", |f| {
|
||||
let banner = banner_for_width(f.area().width);
|
||||
let banner_h = banner.lines().count() as u16;
|
||||
let chunks = Layout::vertical([
|
||||
Constraint::Length(banner_h),
|
||||
Constraint::Min(3),
|
||||
Constraint::Length(1),
|
||||
])
|
||||
.split(f.area());
|
||||
f.render_widget(Paragraph::new(banner), chunks[0]);
|
||||
let footer = status_footer(
|
||||
f.area().width,
|
||||
FP,
|
||||
ONION,
|
||||
Some("send failed: connection timed out"),
|
||||
main_footer_hints(),
|
||||
draw_to(w, h, "main: chat + stale roster, focus chat, tor ready", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Chat,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
);
|
||||
f.render_widget(Paragraph::new(footer), chunks[2]);
|
||||
});
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED main empty", |f| {
|
||||
MainStandin {
|
||||
friends: &[],
|
||||
selected: 0,
|
||||
chat_lines: empty_chat_lines(),
|
||||
composer: "",
|
||||
alert: None,
|
||||
status_note: None,
|
||||
}
|
||||
.draw(f);
|
||||
draw_to(w, h, "main: focus roster, tor connecting", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Connecting),
|
||||
friends: &friends,
|
||||
selected: 1,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("bob-the-stale-peer"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED main chat+stale", |f| {
|
||||
MainStandin {
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
chat_lines: &chat_ok,
|
||||
composer: "hello from composer",
|
||||
alert: Some("passphrases do not match"),
|
||||
status_note: Some("sent"),
|
||||
}
|
||||
.draw(f);
|
||||
draw_to(w, h, "main: focus composer, promoted identity", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Degraded),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Composer,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "hello from composer",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED main pay/file footer only", |f| {
|
||||
MainStandin {
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
chat_lines: &["you: /pay 0.1 coffee", "them: (no invoice pane exists)"],
|
||||
composer: "",
|
||||
alert: None,
|
||||
status_note: Some("invoice sent"),
|
||||
}
|
||||
.draw(f);
|
||||
draw_to(w, h, "main: EMPTY roster, tor connecting", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Connecting),
|
||||
friends: &[],
|
||||
selected: 0,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &empty_chat(TorPhase::Connecting),
|
||||
chat_style: ChatRowStyle::State,
|
||||
chat_name: None,
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED main file-send-failed", |f| {
|
||||
MainStandin {
|
||||
friends: &friends,
|
||||
selected: 1,
|
||||
chat_lines: &["no messages"],
|
||||
composer: "",
|
||||
alert: None,
|
||||
status_note: Some("send failed: peer onion down"),
|
||||
}
|
||||
.draw(f);
|
||||
draw_to(w, h, "main: EMPTY roster, tor off (disconnected)", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: "",
|
||||
phase: Some(TorPhase::Off),
|
||||
friends: &[],
|
||||
selected: 0,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &empty_chat(TorPhase::Off),
|
||||
chat_style: ChatRowStyle::State,
|
||||
chat_name: None,
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: Some("fingerprint mismatch"),
|
||||
note: None,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
draw_to(w, h, "main: ERROR alert + fail-closed note", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Degraded),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Composer,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: Some("send failed: peer onion down"),
|
||||
note: Some("send failed: peer onion down"),
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
draw_to(w, h, "main: outbox queued (peer unreachable)", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &queued_chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: Some(&queued_note),
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
draw_to(w, h, "draw_share (real)", |f| draw_share(f, &invite));
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED help overlay on empty main", |f| {
|
||||
MainStandin {
|
||||
friends: &[],
|
||||
selected: 0,
|
||||
chat_lines: empty_chat_lines(),
|
||||
composer: "",
|
||||
alert: None,
|
||||
status_note: None,
|
||||
}
|
||||
.draw(f);
|
||||
draw_text_overlay_standin(f, "? help", help_overlay_text());
|
||||
draw_to(w, h, "main + ? help overlay (real draw_text_overlay)", |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Chat,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
);
|
||||
draw_text_overlay(f, "? help", help_overlay_text());
|
||||
});
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED /who overlay", |f| {
|
||||
MainStandin {
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
chat_lines: &chat_ok,
|
||||
composer: "",
|
||||
alert: None,
|
||||
status_note: None,
|
||||
}
|
||||
.draw(f);
|
||||
draw_text_overlay_standin(f, "/who", &who);
|
||||
draw_to(w, h, "main + /who overlay (real draw_text_overlay)", |f| {
|
||||
draw_text_overlay(f, "/who", &who);
|
||||
});
|
||||
|
||||
draw_to(w, h, "RECONSTRUCTED profile", |f| {
|
||||
|
|
@ -407,13 +416,6 @@ fn dump_audit_frames() {
|
|||
&format!("{}\n\nWI", wipe_screen_text(WipeKind::Messages)),
|
||||
);
|
||||
});
|
||||
draw_to(w, h, "RECONSTRUCTED wipe-all", |f| {
|
||||
draw_overlay_screen(
|
||||
f,
|
||||
"(o) wipe all",
|
||||
&format!("{}\n\n", wipe_screen_text(WipeKind::All)),
|
||||
);
|
||||
});
|
||||
draw_to(w, h, "RECONSTRUCTED quit", |f| {
|
||||
draw_overlay_screen(f, "(o) quit", &format!("{}\n\nQUI", quit_screen_text()));
|
||||
});
|
||||
|
|
@ -427,19 +429,243 @@ fn dump_audit_frames() {
|
|||
draw_to(w, h, "RECONSTRUCTED restore", |f| {
|
||||
draw_overlay_screen(f, "(o) restore", &format!("{}\n\n", restore_screen_text()));
|
||||
});
|
||||
draw_to(w, h, "RECONSTRUCTED passphrase", |f| {
|
||||
draw_overlay_screen(
|
||||
f,
|
||||
"(o) passphrase",
|
||||
"Enter passphrase\n\n****\n\nEnter submit Esc cancel",
|
||||
);
|
||||
});
|
||||
draw_to(w, h, "who copy (no profile)", |f| {
|
||||
draw_overlay_screen(f, "/who", &who_empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_overlay_screen(f: &mut Frame, title: &str, body: &str) {
|
||||
f.render_widget(
|
||||
Paragraph::new(body)
|
||||
.wrap(Wrap { trim: false })
|
||||
.block(Block::default().borders(Borders::ALL).title(title)),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Every real main-screen state must fit every supported size in cells.
|
||||
#[test]
|
||||
fn main_chrome_fits_80x24_120x40_and_200x60() {
|
||||
let friends = friend_rows();
|
||||
let chat = chat_ok();
|
||||
let (queued_chat, queued_note) = chat_queued();
|
||||
let empty_connecting = empty_chat(TorPhase::Connecting);
|
||||
let states: Vec<(&str, MainView<'_>, Option<&str>)> = vec![ (
|
||||
"chat+stale",
|
||||
MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Chat,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
None,
|
||||
),
|
||||
(
|
||||
"empty+connecting",
|
||||
MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Connecting),
|
||||
friends: &[],
|
||||
selected: 0,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &empty_connecting,
|
||||
chat_style: ChatRowStyle::State,
|
||||
chat_name: None,
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
None,
|
||||
),
|
||||
(
|
||||
"error+alert",
|
||||
MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Degraded),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Composer,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: Some("send failed: peer onion down"),
|
||||
note: Some("send failed: peer onion down"),
|
||||
},
|
||||
None,
|
||||
),
|
||||
(
|
||||
"queued outbox",
|
||||
MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &queued_chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: Some(&queued_note),
|
||||
},
|
||||
None,
|
||||
),
|
||||
];
|
||||
for (name, view, _) in states {
|
||||
for (w, h) in SIZES {
|
||||
let buf = draw_frame(w, h, |f| draw_main_chrome(f, &view));
|
||||
let screen = screen_of(&buf, w, h);
|
||||
for (y, row) in screen.lines().enumerate() {
|
||||
assert!(
|
||||
cell_width(row) <= w as usize,
|
||||
"{name} at {w}x{h}: row {y} is {} cells: {row:?}",
|
||||
cell_width(row)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The frame dump must show the phase, and the phase must not be colour-only.
|
||||
#[test]
|
||||
fn main_frame_states_are_legible_without_colour() {
|
||||
let friends = friend_rows();
|
||||
let chat = chat_ok();
|
||||
for (phase, word) in [
|
||||
(TorPhase::Connecting, "connecting"),
|
||||
(TorPhase::Ready, "ready"),
|
||||
(TorPhase::Degraded, "degraded"),
|
||||
(TorPhase::Off, "off"),
|
||||
] {
|
||||
let buf = draw_frame(80, 24, |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(phase),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Chat,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
)
|
||||
});
|
||||
let screen = screen_of(&buf, 80, 24);
|
||||
let header = screen.lines().next().unwrap_or_default().to_string();
|
||||
let footer = screen.lines().last().unwrap_or_default().to_string();
|
||||
assert!(header.contains(word), "header lacks {word:?}: {header:?}");
|
||||
assert!(footer.contains(word), "footer lacks {word:?}: {footer:?}");
|
||||
assert!(header.contains("onionwire"), "{header:?}");
|
||||
assert!(footer.contains("TOR"), "{footer:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Focus must be visible with the colour stripped: a marker on the focused
|
||||
/// pane, not just a coloured border.
|
||||
#[test]
|
||||
fn focus_is_a_marker_not_only_colour() {
|
||||
let friends = friend_rows();
|
||||
let chat = chat_ok();
|
||||
let marker_of = |focus: Pane, w: u16| -> String {
|
||||
let buf = draw_frame(w, 24, |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
)
|
||||
});
|
||||
screen_of(&buf, w, 24)
|
||||
};
|
||||
for w in [80u16, 120] {
|
||||
let roster_focus = marker_of(Pane::Roster, w);
|
||||
let chat_focus = marker_of(Pane::Chat, w);
|
||||
assert!(
|
||||
roster_focus.contains("> alice"),
|
||||
"roster focus has no row marker at {w}: {roster_focus}"
|
||||
);
|
||||
assert!(
|
||||
chat_focus.contains("> chat"),
|
||||
"chat focus has no title marker at {w}"
|
||||
);
|
||||
assert!(
|
||||
!roster_focus.contains("> chat"),
|
||||
"chat title keeps the focus marker while roster is focused"
|
||||
);
|
||||
assert_eq!(
|
||||
roster_focus.lines().count(),
|
||||
24,
|
||||
"frame height changed with focus"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The empty roster is a state, not a blank box.
|
||||
#[test]
|
||||
fn empty_roster_and_empty_chat_are_designed_states() {
|
||||
let buf = draw_frame(80, 24, |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Connecting),
|
||||
friends: &[],
|
||||
selected: 0,
|
||||
focus: Pane::Roster,
|
||||
chat_lines: &empty_chat(TorPhase::Connecting),
|
||||
chat_style: ChatRowStyle::State,
|
||||
chat_name: None,
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
)
|
||||
});
|
||||
let screen = screen_of(&buf, 80, 24);
|
||||
assert!(screen.contains("no friends"), "{screen}");
|
||||
assert!(screen.contains("F3 adds one"), "{screen}");
|
||||
assert!(screen.contains("F3 paste an invite"), "{screen}");
|
||||
assert!(
|
||||
screen.contains("tor connecting"),
|
||||
"connecting state is not on screen:\n{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn public_copy_fits_80_by_chars_count() {
|
||||
for (name, text) in [
|
||||
|
|
@ -518,7 +744,7 @@ fn status_footer_drops_send_failed_when_crowded() {
|
|||
|
||||
#[test]
|
||||
fn share_invite_wraps_at_three_sizes() {
|
||||
let invite = sample_invite();
|
||||
let invite = qr::encode(&[7u8; 32], ONION, &[1u8; 32]).expect("encode");
|
||||
for (w, h) in SIZES {
|
||||
let backend = TestBackend::new(w, h);
|
||||
let mut terminal = Terminal::new(backend).expect("terminal");
|
||||
|
|
@ -536,6 +762,34 @@ fn share_invite_wraps_at_three_sizes() {
|
|||
}
|
||||
}
|
||||
|
||||
/// The help overlay is cleared underneath and never wider than the frame.
|
||||
#[test]
|
||||
fn help_overlay_keeps_a_margin_and_shows_the_tail() {
|
||||
for (w, h) in SIZES {
|
||||
let buf = draw_frame(w, h, |f| {
|
||||
f.render_widget(Paragraph::new("underlying frame junk"), f.area());
|
||||
draw_text_overlay(f, "? help", help_overlay_text());
|
||||
});
|
||||
let screen = screen_of(&buf, w, h);
|
||||
assert!(
|
||||
!screen.contains("underlying frame junk"),
|
||||
"{w}x{h} overlay punched through:\n{screen}"
|
||||
);
|
||||
assert!(
|
||||
screen.contains("Esc closes this overlay"),
|
||||
"{w}x{h} help tail clipped"
|
||||
);
|
||||
// A one-cell margin on each side: no border glyph in column 0.
|
||||
for line in screen.lines() {
|
||||
let first = line.chars().next().unwrap_or(' ');
|
||||
assert!(
|
||||
first != '┌' && first != '│',
|
||||
"{w}x{h} overlay is full-bleed: {line:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Documented defect in `tests/tui_chrome.rs`: `chars().count()` is not cells.
|
||||
/// Do not add `unicode-width` on this card.
|
||||
#[test]
|
||||
|
|
@ -553,3 +807,34 @@ fn chars_count_is_not_terminal_cells() {
|
|||
let ellipsis = "…";
|
||||
assert_eq!(ellipsis.chars().count(), 1);
|
||||
}
|
||||
|
||||
/// Sanity: the real main renderer is the one under test here.
|
||||
#[test]
|
||||
fn main_chrome_draws_the_same_frame_as_the_app_layout() {
|
||||
let friends = friend_rows();
|
||||
let chat = chat_ok();
|
||||
let buf = draw_frame(80, 24, |f| {
|
||||
draw_main_chrome(
|
||||
f,
|
||||
&MainView {
|
||||
me_fp: FP,
|
||||
me_onion: ONION,
|
||||
phase: Some(TorPhase::Ready),
|
||||
friends: &friends,
|
||||
selected: 0,
|
||||
focus: Pane::Chat,
|
||||
chat_lines: &chat,
|
||||
chat_style: ChatRowStyle::Text,
|
||||
chat_name: Some("alice"),
|
||||
chat_scroll: 0,
|
||||
composer: "",
|
||||
alert: None,
|
||||
note: None,
|
||||
},
|
||||
)
|
||||
});
|
||||
let screen = screen_of(&buf, 80, 24);
|
||||
assert!(screen.contains("roster 2 1 stale"), "{screen}");
|
||||
assert!(screen.contains("> chat alice"), "{screen}");
|
||||
assert!(screen.contains("message"), "composer placeholder: {screen}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,6 +259,13 @@ fn alert_line_truncates_to_frame_width() {
|
|||
!line.contains("roster on the next row"),
|
||||
"alert still has overflow tail: {line:?}"
|
||||
);
|
||||
// Cells, not chars: a double-width peer error must not overflow the row.
|
||||
let cjk = alert_line("接続がタイムアウトしました 接続がタイムアウトしました", 32);
|
||||
assert!(
|
||||
onionwire::tui::cell_width(&cjk) <= 32,
|
||||
"alert wider than 32 cells: {} {cjk:?}",
|
||||
onionwire::tui::cell_width(&cjk)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1148,14 +1155,19 @@ fn wallets_settings_menu_truncates_wide_values_in_cells() {
|
|||
"no ellipsis: {cut:?}"
|
||||
);
|
||||
// ASCII chrome swaps the ellipsis and the section rule, never the width
|
||||
// contract.
|
||||
// contract. Either ellipsis form is accepted, like the two assertions above:
|
||||
// `ONIONWIRE_ASCII` is process-wide, so this test cannot assume which form
|
||||
// is active while other tests run in parallel.
|
||||
let ascii = fit_cells("abcdefghij", 8);
|
||||
assert!(cell_width(&ascii) <= 8, "{ascii:?}");
|
||||
// Either chrome: ASCII cuts at 5 cells and closes with `...`, unicode cuts at
|
||||
// 6 and closes with `…`, and both are 8 cells. Asserting `"abcdef"` here made
|
||||
// this test depend on another test's in-flight `ONIONWIRE_ASCII` mutation
|
||||
// (the suite mutates env vars without a global lock), so it flaked.
|
||||
assert!(ascii.starts_with("abcde"), "{ascii:?}");
|
||||
assert!(
|
||||
ascii.starts_with("abcde") && ascii != "abcdefghij",
|
||||
"truncation kept the whole string or dropped too much: {ascii:?}"
|
||||
);
|
||||
assert!(
|
||||
ascii.ends_with('…') || ascii.ends_with("..."),
|
||||
"no ellipsis: {ascii:?}"
|
||||
);
|
||||
assert_eq!(cell_width("名"), 2);
|
||||
assert_eq!(cell_width("abc"), 3);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue