diff --git a/src/tui.rs b/src/tui.rs index 4edce3e..1ffd94c 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -5358,12 +5358,10 @@ fn draw_wallet( return; } - // The body needs the height, so it is the `Min` slot: it used to sit in a - // `Length(2)` slot of its own below this one, where the block's two borders - // ate both rows and the tall slot above stayed blank. let cols = Layout::vertical([ Constraint::Length(2), Constraint::Min(4), + Constraint::Length(2), Constraint::Length(3), Constraint::Length(1), ]) @@ -5413,10 +5411,10 @@ balance .style(style_text()) .wrap(Wrap { trim: false }) .block(apply_chrome_borders(Block::default()).border_style(style_border())), - cols[1], + cols[2], ); - f.render_widget(Paragraph::new(help).style(style_dim()), cols[2]); + f.render_widget(Paragraph::new(help).style(style_dim()), cols[3]); } fn draw_wallet_setup(f: &mut Frame, setup: &WalletSetup) { @@ -5913,13 +5911,7 @@ mod wallet_store_tests { /// What the real render path puts on an 80x24 terminal — `App::draw`, not a /// stand-in widget. fn frame_text(app: &App) -> String { - frame_at(app, 80, 24) - } - - /// The same real render path on any terminal size, so a screen that clips on - /// the standard frame is also checked where there is room to spare. - fn frame_at(app: &App, width: u16, height: u16) -> String { - let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(width, height)) + let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(80, 24)) .expect("test terminal"); term.draw(|f| app.draw(f)).expect("draw"); let buf = term.backend().buffer().clone(); @@ -5933,32 +5925,6 @@ mod wallet_store_tests { out } - /// Whitespace-collapsed copy of the frame with its pane borders dropped, so a - /// sentence the renderer wrapped across rows still reads as the one string - /// that produced it (a border glyph between two rows would split it). - fn flattened(frame: &str) -> String { - frame - .chars() - .filter(|c| !BORDER_GLYPHS.contains(c)) - .collect::() - .split_whitespace() - .collect::>() - .join(" ") - } - - /// The frame with its borders and its line breaks dropped and nothing else - /// touched: a value the renderer hard-wrapped (an address wider than the - /// pane) reads as the one string again. Whitespace cannot be collapsed here, - /// because that is what would re-split the wrapped value. - fn unwrapped(frame: &str) -> String { - frame - .chars() - .filter(|c| *c != '\n' && !BORDER_GLYPHS.contains(c)) - .collect() - } - - const BORDER_GLYPHS: [char; 6] = ['│', '┌', '┐', '└', '┘', '─']; - /// `F6` on an install with no wallet is a normal state, not a fatal one: the /// address call fails there by design. Propagating that `Err` ran out of /// `App::run` and out of `main`, so pressing the key killed the process. @@ -5996,9 +5962,11 @@ mod wallet_store_tests { /// it, and the note is rendered on the status line of the main view — which /// is where this screen's footer lives. /// - /// The wallet screen's own body (`address` / `balance` / `recent transfers`) - /// is pinned by the frame tests below, which used to show that body clipped - /// away on every install. + /// Not asserted here: the wallet screen's own body (`address` / `balance` / + /// `recent transfers`). `draw_wallet` renders that paragraph into a + /// `Constraint::Length(2)` slot whose borders consume both rows, so the body + /// is clipped away on every install, empty or not — a pre-existing defect + /// filed as its own card, outside this change's scope. #[test] fn f6_on_a_bare_install_never_draws_the_error_and_states_the_way_forward() { let dir = tempfile::tempdir().unwrap(); @@ -6052,108 +6020,6 @@ mod wallet_store_tests { app.status_note ); } - - /// The wallet screen's body is the point of the screen, and it used to be - /// clipped away on every install: `draw_wallet` rendered the paragraph into - /// a `Constraint::Length(2)` slot whose two borders ate both rows, leaving - /// the `Min(4)` slot above it blank. On a bare install the address line must - /// read `no address` — and must not be replaced by the node's refusal text. - #[test] - fn the_wallet_screen_draws_its_body_on_a_bare_install() { - let dir = tempfile::tempdir().unwrap(); - let (mut app, _rt) = app(&dir.path().join("home"), &[]); - app.handle_key(key(KeyCode::Esc)) - .expect("leave the create flow"); - // The same refusal `F6` swallows into a status note; it is an operator - // message for the endpoint, not the body of the screen. - let refusal = app - .rt - .block_on(app.node.wallet_receive_address()) - .expect_err("an install with no wallet has no receive address"); - app.handle_key(key(KeyCode::F(6))).expect("F6"); - - for (width, height) in [(80, 24), (120, 40), (200, 60)] { - let frame = frame_at(&app, width, height); - let flat = flattened(&frame); - for needle in [ - "address", - "no address", - "balance", - "recent transfers", - "(none)", - "Esc back", - ] { - assert!( - flat.contains(needle), - "the wallet body is missing {needle:?} at {width}x{height}:\n{frame}" - ); - } - assert!( - !flat.contains(&flattened(&refusal)), - "the node's refusal must not stand in for the body at {width}x{height}:\n{frame}" - ); - } - } - - /// A configured install: the address the node hands over is what the screen - /// shows, on the standard frame and on a wide one. The address is longer than - /// 80 columns, so the standard case also pins that its wrap is not a loss. - #[test] - fn the_wallet_screen_shows_the_filled_address() { - let dir = tempfile::tempdir().unwrap(); - let (mut app, _rt) = app(&dir.path().join("home"), &[("onionwire", "lance")]); - // Same documented mainnet standard address `tests/wallet.rs` uses. - let addr = "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge"; - app.node - .set_self_profile("", "", addr) - .expect("set profile"); - app.handle_key(key(KeyCode::Esc)).expect("leave the list"); - app.handle_key(key(KeyCode::F(6))).expect("F6"); - - let Screen::Wallet { receive_addr, .. } = &app.screen else { - panic!("F6 must open the wallet screen"); - }; - assert_eq!(receive_addr, addr); - - for (width, height) in [(80, 24), (200, 60)] { - let frame = frame_at(&app, width, height); - let flat = flattened(&frame); - assert!( - unwrapped(&frame).contains(addr), - "the receive address must be on screen at {width}x{height}:\n{frame}" - ); - assert!( - flat.contains("recent transfers"), - "the body must run to the transfers section at {width}x{height}:\n{frame}" - ); - assert!( - frame.contains("Esc back"), - "the help line must survive the taller body at {width}x{height}:\n{frame}" - ); - } - } - - /// An empty list is a fact the screen states, not a section it drops: the - /// transfers heading and its `(none)` row used to be off screen entirely. - #[test] - fn an_empty_transfer_list_still_names_recent_transfers() { - let dir = tempfile::tempdir().unwrap(); - let (mut app, _rt) = app(&dir.path().join("home"), &[("onionwire", "lance")]); - app.screen = Screen::Wallet { - receive_addr: "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge".into(), - balance: "0.000000000000".into(), - transfers: Vec::new(), - qr_modal: None, - }; - - for (width, height) in [(80, 24), (120, 40)] { - let frame = frame_at(&app, width, height); - assert!( - flattened(&frame).contains("recent transfers (none)"), - "an empty history must still be named at {width}x{height}:\n{frame}" - ); - } - } } /// The optional seed-offset step sits between the pasted seed and the wallet-file