fix(tui): replace emoji wallet badges with ASCII glyphs + word
- Badge now '[!] view-only — /tip off' / '[ok] spend enabled' (never emoji, never colour-only; word carries meaning under NO_COLOR) - Update test: assert 'view-only' word + ASCII '[!]' glyph present - Add wallet frame dumps to dump_audit_frames: receive-only, local synced, local syncing, remote unreachable, view-only badge, QR modal — at 80x24 and 120x40 - Add wallet_screen_no_line_exceeds_frame_at_80_and_120: asserts every rendered line stays within frame width (chars_count metric) - Add wallet_view_only_badge_renders_at_80_and_120: badge present and within width at both sizes Tests: 21 tui_frames, 19 tui_chrome, 23 tui_spec all green Clippy: clean --locked --all-targets -- -D warnings
This commit is contained in:
parent
310671785b
commit
b9f84e6f4b
2 changed files with 180 additions and 8 deletions
|
|
@ -3235,11 +3235,12 @@ pub fn draw_wallet(f: &mut Frame, view: &WalletView, modal: Option<&QrModal>, co
|
|||
view.receive_addr.clone()
|
||||
};
|
||||
|
||||
// View-only badge: glyph + word, never color-only (NO_COLOR degrades to ASCII).
|
||||
// View-only badge: glyph + word, never colour-only, never emoji, and the
|
||||
// same under NO_COLOR / ONIONWIRE_ASCII (the word carries the meaning).
|
||||
let badge = if view.no_spend {
|
||||
"🛑 view-only — /tip off"
|
||||
"[!] view-only — /tip off"
|
||||
} else {
|
||||
"🟢 spend enabled"
|
||||
"[ok] spend enabled"
|
||||
};
|
||||
|
||||
let primary_lines: Vec<String> = if view.receive_addr.is_empty() {
|
||||
|
|
|
|||
|
|
@ -440,6 +440,107 @@ fn dump_audit_frames() {
|
|||
draw_to(w, h, "who copy (no profile)", |f| {
|
||||
draw_overlay_screen(f, "/who", &who_empty);
|
||||
});
|
||||
|
||||
// --- Wallet screen frames (real draw_wallet) ---
|
||||
// receive-only
|
||||
let receive_only = chain_view(
|
||||
&ChainSource::None,
|
||||
WalletChildState::Off,
|
||||
&DaemonSync {
|
||||
reachable: false,
|
||||
height: 0,
|
||||
target_height: 0,
|
||||
note: Some("receive-only: no daemon".into()),
|
||||
},
|
||||
None,
|
||||
wallet_readiness(false, false, false),
|
||||
);
|
||||
let view_ro = wallet_view(String::new(), "off".to_string(), Vec::new(), receive_only, false);
|
||||
draw_to(w, h, "wallet receive-only", |f| {
|
||||
draw_wallet(f, &view_ro, None, None);
|
||||
});
|
||||
|
||||
// local synced
|
||||
let synced = chain_view(
|
||||
&local_source(),
|
||||
WalletChildState::Running,
|
||||
&DaemonSync {
|
||||
reachable: true,
|
||||
height: 3_210_000,
|
||||
target_height: 3_210_000,
|
||||
note: None,
|
||||
},
|
||||
Some(412),
|
||||
wallet_readiness(true, true, false),
|
||||
);
|
||||
let view_synced = wallet_view(address(), "12.5 XMR".to_string(), Vec::new(), synced, false);
|
||||
draw_to(w, h, "wallet local synced", |f| {
|
||||
draw_wallet(f, &view_synced, None, None);
|
||||
});
|
||||
|
||||
// local syncing
|
||||
let syncing = chain_view(
|
||||
&local_source(),
|
||||
WalletChildState::Running,
|
||||
&DaemonSync {
|
||||
reachable: true,
|
||||
height: 1_500_000,
|
||||
target_height: 3_210_000,
|
||||
note: None,
|
||||
},
|
||||
Some(412),
|
||||
wallet_readiness(true, true, false),
|
||||
);
|
||||
let view_syncing = wallet_view(address(), "12.5 XMR".to_string(), Vec::new(), syncing, false);
|
||||
draw_to(w, h, "wallet local syncing", |f| {
|
||||
draw_wallet(f, &view_syncing, None, None);
|
||||
});
|
||||
|
||||
// remote unreachable
|
||||
let unreachable = chain_view(
|
||||
&ChainSource::Remote {
|
||||
host: "node.example.com".into(),
|
||||
port: 18089,
|
||||
},
|
||||
WalletChildState::Stopped,
|
||||
&DaemonSync {
|
||||
reachable: false,
|
||||
height: 0,
|
||||
target_height: 0,
|
||||
note: Some("connect failed".into()),
|
||||
},
|
||||
None,
|
||||
wallet_readiness(true, false, false),
|
||||
);
|
||||
let view_ru = wallet_view(address(), "12.5 XMR".to_string(), Vec::new(), unreachable, false);
|
||||
draw_to(w, h, "wallet remote unreachable", |f| {
|
||||
draw_wallet(f, &view_ru, None, None);
|
||||
});
|
||||
|
||||
// view-only badge
|
||||
let vo = chain_view(
|
||||
&local_source(),
|
||||
WalletChildState::Running,
|
||||
&DaemonSync {
|
||||
reachable: true,
|
||||
height: 3_210_000,
|
||||
target_height: 3_210_000,
|
||||
note: None,
|
||||
},
|
||||
Some(412),
|
||||
wallet_readiness(true, true, true),
|
||||
);
|
||||
let view_vo = wallet_view(address(), "12.5 XMR".to_string(), Vec::new(), vo, true);
|
||||
draw_to(w, h, "wallet view-only badge", |f| {
|
||||
draw_wallet(f, &view_vo, None, None);
|
||||
});
|
||||
|
||||
// QR modal open
|
||||
let qr_rows: Vec<String> = (0..20).map(|_| "██".repeat(20)).collect();
|
||||
let modal = onionwire::tui::QrModal::test_new(false, qr_rows, address());
|
||||
draw_to(w, h, "wallet qr modal", |f| {
|
||||
draw_wallet(f, &view_synced, Some(&modal), None);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -750,11 +851,12 @@ fn wallet_view_only_badge_has_word_and_glyph() {
|
|||
screen.contains("view-only"),
|
||||
"view-only badge must say 'view-only' as a word: {screen}"
|
||||
);
|
||||
// In emoji mode the badge has a glyph; in NO_COLOR/ASCII we rely on the word.
|
||||
let glyph_ok = std::env::var_os("NO_COLOR").is_some()
|
||||
|| screen.contains("🛑")
|
||||
|| screen.contains("view-only");
|
||||
assert!(glyph_ok, "badge must have a glyph or word under NO_COLOR: {screen}");
|
||||
// Badge must be a glyph + word, never colour-only and never emoji.
|
||||
// Under NO_COLOR / ONIONWIRE_ASCII the glyph is still ASCII `[!]`.
|
||||
assert!(
|
||||
screen.contains("[!]"),
|
||||
"view-only badge must have an ASCII glyph: {screen}"
|
||||
);
|
||||
}
|
||||
|
||||
/// `no_spend=false` must NOT show the view-only badge — a spend-capable wallet
|
||||
|
|
@ -1005,3 +1107,72 @@ fn wallet_screen_remote_unreachable_says_sync_unknown() {
|
|||
"must name remote host:port: {screen}"
|
||||
);
|
||||
}
|
||||
|
||||
/// No line of the rendered wallet screen may exceed the frame width at
|
||||
/// either the 80x24 floor or the 120x40 target. Width is measured by
|
||||
/// `chars().count()` (the documented metric, see `chars_count_is_not_terminal_cells`).
|
||||
#[test]
|
||||
fn wallet_screen_no_line_exceeds_frame_at_80_and_120() {
|
||||
let chain_ready = chain_view(
|
||||
&local_source(),
|
||||
WalletChildState::Running,
|
||||
&DaemonSync {
|
||||
reachable: true,
|
||||
height: 3_210_000,
|
||||
target_height: 3_210_000,
|
||||
note: None,
|
||||
},
|
||||
Some(412),
|
||||
wallet_readiness(true, true, false),
|
||||
);
|
||||
let transfers: Vec<onionwire::wallet::TransferRow> = vec![
|
||||
onionwire::wallet::TransferRow {
|
||||
txid: "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".into(),
|
||||
amount: "5000000000".into(),
|
||||
address: "4AdYaG7wVQ3nHvWoXbN9dQkXj1uYcR2mS8pT5LzE6fK7gB3aD".into(),
|
||||
},
|
||||
];
|
||||
let view = wallet_view(address(), "12.5 XMR".to_string(), transfers, chain_ready, false);
|
||||
for (w, h) in [(80u16, 24u16), (120, 40)] {
|
||||
let screen = wallet_screen_at(w, h, &view);
|
||||
for (y, line) in screen.lines().enumerate() {
|
||||
assert!(
|
||||
line.chars().count() <= w as usize,
|
||||
"wallet screen {w}x{h} row {y} exceeds width: {} {line:?}",
|
||||
line.chars().count()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A view-only wallet renders its `[!]` badge at both sizes, never clipped.
|
||||
#[test]
|
||||
fn wallet_view_only_badge_renders_at_80_and_120() {
|
||||
let chain = chain_view(
|
||||
&local_source(),
|
||||
WalletChildState::Running,
|
||||
&DaemonSync {
|
||||
reachable: true,
|
||||
height: 3_210_000,
|
||||
target_height: 3_210_000,
|
||||
note: None,
|
||||
},
|
||||
Some(412),
|
||||
wallet_readiness(true, true, true),
|
||||
);
|
||||
let view = wallet_view(address(), "12.5 XMR".to_string(), Vec::new(), chain, true);
|
||||
for (w, h) in [(80u16, 24u16), (120, 40)] {
|
||||
let screen = wallet_screen_at(w, h, &view);
|
||||
assert!(
|
||||
screen.contains("[!] view-only"),
|
||||
"view-only badge missing at {w}x{h}: {screen}"
|
||||
);
|
||||
for (y, line) in screen.lines().enumerate() {
|
||||
assert!(
|
||||
line.chars().count() <= w as usize,
|
||||
"badge frame {w}x{h} row {y} too wide: {} {line:?}",
|
||||
line.chars().count()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue