diff --git a/src/tui.rs b/src/tui.rs index 06fefd9..2cdb850 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -3162,7 +3162,7 @@ match screen { } Screen::WalletSetup(WalletSetup::CreateSeed { .. }) => "type SEEN Esc cancel ? help", Screen::WalletSetup(WalletSetup::ImportSeed { .. }) => "paste seed Enter Esc ? help", - Screen::WalletsSettings { .. } => "Esc back c copy ? help", + Screen::WalletsSettings { .. } => wallets_settings_footer_hint(), Screen::PeerPayments { .. } => peer_payments_footer_hint(), Screen::Quit { .. } => "CLEAR or QUIT then Enter Esc cancel ? help", } @@ -3177,6 +3177,16 @@ pub fn peer_payments_footer_hint() -> &'static str { const PEER_PAYMENTS_FOOTER_HINT: &str = "Esc back up/down select F9 menu ? help"; +/// The hint line the WALLETS & SETTINGS menu prints, single-sourced for the +/// same reason as [`peer_payments_footer_hint`]: the menu's frame-dump fixture +/// must not hand-copy it (and must not pair it with the phase-free footer the +/// app stopped using when the chrome redesign landed). +pub fn wallets_settings_footer_hint() -> &'static str { + WALLETS_SETTINGS_FOOTER_HINT +} + +const WALLETS_SETTINGS_FOOTER_HINT: &str = "Esc back c copy ? help"; + fn apply_chrome_borders(block: Block<'_>) -> Block<'_> { let block = block.borders(Borders::ALL); if ascii_chrome() { diff --git a/tests/tui_spec.rs b/tests/tui_spec.rs index 0d810f8..8a13603 100644 --- a/tests/tui_spec.rs +++ b/tests/tui_spec.rs @@ -5,12 +5,13 @@ use onionwire::Message; use onionwire::outbox::{OutboxEntry, OutboxStatus}; use onionwire::qr; use onionwire::tui::{ - OutboxSummary, SlashCmd, WalletMenuState, alert_line, ascii_chrome, cell_width, + OutboxSummary, SlashCmd, TorPhase, WalletMenuState, alert_line, ascii_chrome, cell_width, chat_with_delivery, delivery_tag, draw_chat, draw_share, draw_text_overlay, draw_wallets_settings, empty_friend_chat_text, fit_cells, help_overlay_text, main_footer_hints, main_header_line, osc52_copy_sequence, parse_cmd, paste_screen_text, retry_in_text, - roster_col_width, short_send_reason, status_footer, wallets_settings_menu_lines, - wallets_settings_menu_text, wrap_invite, + roster_col_width, short_send_reason, status_footer, status_footer_phased, + wallets_settings_footer_hint, wallets_settings_menu_lines, wallets_settings_menu_text, + wrap_invite, }; use ratatui::Frame; use ratatui::Terminal; @@ -954,13 +955,46 @@ fn menu_state() -> WalletMenuState { fn render_menu(w: u16, h: u16, st: &WalletMenuState) -> String { let backend = TestBackend::new(w, h); let mut terminal = Terminal::new(backend).expect("terminal"); - let footer = status_footer(w, FP, ONION, None, "Esc back c copy ? help"); + // The app's own two calls for this screen (see `App::draw`): the phased + // footer with the hint `footer_hints` returns. A phase-free footer here + // would be a footer the app never renders. + let footer = status_footer_phased( + w, + FP, + ONION, + Some(TorPhase::Ready), + None, + wallets_settings_footer_hint(), + ); terminal .draw(|f| draw_wallets_settings(f, st, &footer)) .expect("draw"); screen_from(terminal.backend().buffer(), w, h) } +#[test] +fn wallets_settings_menu_frame_shows_the_shipped_footer() { + // The app renders this screen's one status line with `status_footer_phased` + // (the chrome redesign put the Tor phase in it) and the hint from + // `footer_hints`; the fixture has to do the same or every menu frame in the + // PR is a frame the app never draws. + let shipped = status_footer_phased( + 80, + FP, + ONION, + Some(TorPhase::Ready), + None, + wallets_settings_footer_hint(), + ); + let frame = render_menu(80, 24, &menu_state()); + let last = frame.lines().nth(23).unwrap_or_default(); + assert_eq!( + last.trim_end(), + shipped.trim_end(), + "the dumped menu frame's footer is not the one the app renders" + ); +} + #[test] fn wallets_settings_menu_lists_both_groups_and_every_key() { let body = wallets_settings_menu_text(78, &menu_state());