@@ -1607,9 +1607,8 @@ fn compact_page_height_matches_for_cost_based_usage() {
16071607
16081608/// Visual gallery: draws every text widget through the real
16091609/// `render_single_widget` path. Run with
1610- /// `cargo test -p jcode-tui --lib widget_gallery -- --ignored --nocapture`.
1610+ /// `justrust test -p jcode-tui --lib widget_gallery -- --nocapture`.
16111611#[ test]
1612- #[ ignore]
16131612fn widget_gallery ( ) {
16141613 use super :: {
16151614 AmbientWidgetData , CompactionInfo , DirtyFile , GitInfo , Side , WidgetPlacement ,
@@ -1874,35 +1873,103 @@ fn widget_gallery() {
18741873 WidgetKind :: Commits ,
18751874 WidgetKind :: Overview ,
18761875 ] ;
1877- let width = 44u16 ;
1878- for kind in kinds {
1879- let cap = if kind == WidgetKind :: Overview { 40 } else { 12 } ;
1880- let mut h = calculate_widget_height ( kind, & data, width, cap) ;
1881- if h <= 2 {
1882- // Ambient/Tips are gated off in layout; draw them anyway.
1883- h = 8 ;
1876+ for width in [ 12u16 , 24 , 44 ] {
1877+ for kind in kinds {
1878+ let cap = if kind == WidgetKind :: Overview { 40 } else { 12 } ;
1879+ let mut h = calculate_widget_height ( kind, & data, width, cap) ;
1880+ if h <= 2 {
1881+ // Ambient/Tips are gated off in layout; draw them anyway.
1882+ h = 8 ;
1883+ }
1884+ let backend = ratatui:: backend:: TestBackend :: new ( width, h) ;
1885+ let mut terminal = ratatui:: Terminal :: new ( backend) . unwrap ( ) ;
1886+ terminal
1887+ . draw ( |f| {
1888+ let placement = WidgetPlacement {
1889+ kind,
1890+ rect : f. area ( ) ,
1891+ side : Side :: Left ,
1892+ } ;
1893+ render_single_widget ( f, & placement, & data) ;
1894+ } )
1895+ . unwrap ( ) ;
1896+ let buf = terminal. backend ( ) . buffer ( ) . clone ( ) ;
1897+ let bottom = ( 0 ..h)
1898+ . find ( |& y| buf[ ( 0 , y) ] . symbol ( ) == "╰" )
1899+ . unwrap_or_else ( || panic ! ( "{kind:?} at width {width} has no bottom border" ) ) ;
1900+ let footer: String = ( 1 ..width - 1 ) . map ( |x| buf[ ( x, bottom) ] . symbol ( ) ) . collect ( ) ;
1901+ assert ! (
1902+ footer. chars( ) . any( |ch| ch != '─' && !ch. is_whitespace( ) ) ,
1903+ "{kind:?} at width {width} has an empty footer: {footer}"
1904+ ) ;
1905+ println ! ( "{kind:?}" ) ;
1906+ for y in 0 ..h {
1907+ let row: String = ( 0 ..width)
1908+ . map ( |x| buf[ ( x, y) ] . symbol ( ) . to_string ( ) )
1909+ . collect ( ) ;
1910+ println ! ( "{}" , row. trim_end( ) ) ;
1911+ }
1912+ println ! ( ) ;
18841913 }
1885- let backend = ratatui:: backend:: TestBackend :: new ( width, h) ;
1886- let mut terminal = ratatui:: Terminal :: new ( backend) . unwrap ( ) ;
1887- terminal
1888- . draw ( |f| {
1889- let placement = WidgetPlacement {
1890- kind,
1891- rect : f. area ( ) ,
1892- side : Side :: Left ,
1893- } ;
1894- render_single_widget ( f, & placement, & data) ;
1895- } )
1896- . unwrap ( ) ;
1897- let buf = terminal. backend ( ) . buffer ( ) . clone ( ) ;
1898- println ! ( "{kind:?}" ) ;
1899- for y in 0 ..h {
1900- let row: String = ( 0 ..width)
1901- . map ( |x| buf[ ( x, y) ] . symbol ( ) . to_string ( ) )
1902- . collect ( ) ;
1903- println ! ( "{}" , row. trim_end( ) ) ;
1914+ }
1915+ }
1916+
1917+ #[ test]
1918+ fn special_widgets_have_bottom_border_text ( ) {
1919+ use super :: { CloudProbeState , CloudStatusInfo , Side , WidgetPlacement } ;
1920+ use ratatui:: { Terminal , backend:: TestBackend } ;
1921+ let data = InfoWidgetData {
1922+ workspace_rows : vec ! [ crate :: tui:: workspace_map:: VisibleWorkspaceRow {
1923+ workspace: 0 ,
1924+ is_current: true ,
1925+ focused_index: Some ( 0 ) ,
1926+ sessions: vec![ crate :: tui:: workspace_map:: WorkspaceSessionTile :: new( "fox" ) ] ,
1927+ } ] ,
1928+ cloud_info : Some ( CloudStatusInfo {
1929+ host : "test-host" . into ( ) ,
1930+ remote_dir : "/workspace" . into ( ) ,
1931+ local_dir : None ,
1932+ local_is_source : false ,
1933+ started_at : std:: time:: SystemTime :: now ( ) ,
1934+ last_success : None ,
1935+ probe_duration_ms : None ,
1936+ state : CloudProbeState :: Loading ,
1937+ machine : None ,
1938+ last_transfer_at : None ,
1939+ } ) ,
1940+ ..Default :: default ( )
1941+ } ;
1942+ // The diagram branch must retain its footer even while image data is absent.
1943+ for kind in [
1944+ WidgetKind :: Diagrams ,
1945+ WidgetKind :: WorkspaceMap ,
1946+ WidgetKind :: CloudVm ,
1947+ ] {
1948+ for width in [ 12u16 , 24 , 44 ] {
1949+ let mut terminal = Terminal :: new ( TestBackend :: new ( width, 12 ) ) . unwrap ( ) ;
1950+ terminal
1951+ . draw ( |f| {
1952+ super :: render_all (
1953+ f,
1954+ & [ WidgetPlacement {
1955+ kind,
1956+ rect : f. area ( ) ,
1957+ side : Side :: Right ,
1958+ } ] ,
1959+ & data,
1960+ ) ;
1961+ } )
1962+ . unwrap ( ) ;
1963+ let buf = terminal. backend ( ) . buffer ( ) ;
1964+ let bottom = ( 0 ..12 )
1965+ . find ( |& y| buf[ ( 0 , y) ] . symbol ( ) == "╰" )
1966+ . expect ( "rendered widget must have a bottom border" ) ;
1967+ let footer: String = ( 1 ..width - 1 ) . map ( |x| buf[ ( x, bottom) ] . symbol ( ) ) . collect ( ) ;
1968+ assert ! (
1969+ footer. chars( ) . any( char :: is_alphabetic) ,
1970+ "{kind:?}: {footer}"
1971+ ) ;
19041972 }
1905- println ! ( ) ;
19061973 }
19071974}
19081975
0 commit comments