[verified] feat(tui): drop unicode QR, share onionwire:v1 invite
Some checks failed
ci / test (push) Has been cancelled
Some checks failed
ci / test (push) Has been cancelled
F2 shows the invite string with fp/onion hints instead of a terminal QR. Keep encode/decode and F3 paste; drop the qrcode crate.
This commit is contained in:
parent
e902a9041d
commit
4fb47444d5
9 changed files with 64 additions and 55 deletions
13
tests/qr.rs
13
tests/qr.rs
|
|
@ -90,19 +90,6 @@ fn bad_sig_is_err() {
|
|||
assert!(qr::decode(&format!("{head}:sig={flipped}")).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unicode_qr_renders() {
|
||||
let _home = TempHome::new();
|
||||
let store = Store::open().expect("open");
|
||||
let me = store.self_identity().expect("self");
|
||||
let raw = qr::encode(&me.identity_sk, &v3onion("x"), &[1u8; 32]).expect("encode");
|
||||
let art = qr::render_unicode(&raw).expect("render");
|
||||
assert!(
|
||||
art.contains('█') || art.contains('▀') || art.contains('▄') || art.contains('▌'),
|
||||
"expected unicode blocks, got {art:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_k_rescan_updates_onion_not_duplicate() {
|
||||
let _home = TempHome::new();
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ fn rotate_prompt_text_matches_spec() {
|
|||
assert!(t.contains("Rotate onion address?"));
|
||||
assert!(t.contains("Your identity key stays the same."));
|
||||
assert!(t.contains("Online friends get a signed location update."));
|
||||
assert!(t.contains("Offline friends CANNOT find you until they rescan your QR."));
|
||||
assert!(t.contains("Offline friends CANNOT find you until they F3-paste your new invite."));
|
||||
assert!(t.contains("Type ROTATE to confirm"));
|
||||
assert!(t.contains("Esc to cancel"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
//! Main-screen chrome helpers: ASCII wordmark, compact fallback, help text.
|
||||
|
||||
use onionwire::qr;
|
||||
use onionwire::tui::{
|
||||
Pane, banner_for_width, compact_banner, help_overlay_text, main_footer_hints, onion_glyph,
|
||||
status_footer, wordmark_banner,
|
||||
banner_for_width, compact_banner, draw_share, help_overlay_text, main_footer_hints,
|
||||
onion_glyph, status_footer, wordmark_banner, Pane,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
@ -64,10 +65,10 @@ fn banner_for_width_collapses_when_narrow() {
|
|||
|
||||
#[test]
|
||||
fn chrome_renders_at_80x24_and_120x40() {
|
||||
use ratatui::Terminal;
|
||||
use ratatui::backend::TestBackend;
|
||||
use ratatui::layout::{Constraint, Layout};
|
||||
use ratatui::widgets::Paragraph;
|
||||
use ratatui::Terminal;
|
||||
|
||||
let fp = "abcdef0123456789";
|
||||
let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopq.onion";
|
||||
|
|
@ -162,3 +163,36 @@ fn pane_focus_cycles_roster_chat_composer() {
|
|||
fn restore_terminal_is_callable_without_panic() {
|
||||
onionwire::tui::restore_terminal();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn share_screen_shows_invite_not_qr_at_80x24() {
|
||||
use ratatui::backend::TestBackend;
|
||||
use ratatui::Terminal;
|
||||
|
||||
let sk = [7u8; 32];
|
||||
let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopq.onion";
|
||||
let payload = qr::encode(&sk, onion, &[1u8; 32]).expect("encode");
|
||||
assert!(payload.starts_with("onionwire:v1:"));
|
||||
|
||||
let backend = TestBackend::new(80, 24);
|
||||
let mut terminal = Terminal::new(backend).expect("terminal");
|
||||
terminal.draw(|f| draw_share(f, &payload)).expect("draw");
|
||||
let buf = terminal.backend().buffer();
|
||||
let mut screen = String::new();
|
||||
for y in 0..24u16 {
|
||||
for x in 0..80u16 {
|
||||
screen.push_str(buf[(x, y)].symbol());
|
||||
}
|
||||
screen.push('\n');
|
||||
}
|
||||
assert!(
|
||||
screen.contains("onionwire:v1:"),
|
||||
"share screen missing invite prefix:\n{screen}"
|
||||
);
|
||||
for ch in ['█', '▀', '▄'] {
|
||||
assert!(
|
||||
!screen.contains(ch),
|
||||
"share screen still has QR block {ch:?}:\n{screen}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue