@@ -29,10 +29,20 @@ mod harness_snapshots {
2929 buffer_text ( & buf)
3030 }
3131
32+ fn dump_snapshot ( name : & str , text : & str ) {
33+ let Ok ( dir) = std:: env:: var ( "CORTEX_DUMP_SNAPSHOTS" ) else {
34+ return ;
35+ } ;
36+ let path = std:: path:: Path :: new ( & dir) ;
37+ let _ = std:: fs:: create_dir_all ( path) ;
38+ let _ = std:: fs:: write ( path. join ( format ! ( "{name}.txt" ) ) , text) ;
39+ }
40+
3241 #[ test]
3342 fn snapshot_home_empty_session ( ) {
3443 let state = AppState :: default ( ) ;
3544 let text = render ( & state, 80 , 24 ) ;
45+ dump_snapshot ( "home" , & text) ;
3646 assert ! ( !text. to_lowercase( ) . contains( "grok" ) ) ;
3747 assert ! (
3848 text. contains( "Cortex" ) || text. contains( "session" ) || !text. trim( ) . is_empty( ) ,
@@ -46,6 +56,7 @@ mod harness_snapshots {
4656 state. add_message ( cortex_core:: widgets:: Message :: user ( "List the files" ) ) ;
4757 state. add_message ( cortex_core:: widgets:: Message :: assistant ( "Hi" ) ) ;
4858 let text = render ( & state, 80 , 24 ) ;
59+ dump_snapshot ( "session" , & text) ;
4960 assert ! ( text. contains( "List the files" ) || text. contains( "Hi" ) ) ;
5061 assert ! ( !text. to_lowercase( ) . contains( "grok" ) ) ;
5162 }
@@ -64,6 +75,7 @@ mod harness_snapshots {
6475 call. append_output ( "reading src/main.rs" . into ( ) ) ;
6576 state. tool_calls . push ( call) ;
6677 let text = render ( & state, 80 , 24 ) ;
78+ dump_snapshot ( "tools_running" , & text) ;
6779 assert ! (
6880 text. contains( "Read" ) && text. contains( "main.rs" ) ,
6981 "tool row missing: {text}"
@@ -89,6 +101,7 @@ mod harness_snapshots {
89101 } ) ;
90102 state. tool_calls . push ( call) ;
91103 let text = render ( & state, 80 , 24 ) ;
104+ dump_snapshot ( "plan" , & text) ;
92105 assert ! (
93106 text. contains( "Plan" ) && ( text. contains( "mermaid" ) || text. contains( "device" ) ) ,
94107 "plan mermaid missing: {text}"
@@ -102,6 +115,7 @@ mod harness_snapshots {
102115 "The coding service is temporarily unavailable" ,
103116 ) ) ;
104117 let text = render ( & state, 80 , 24 ) ;
118+ dump_snapshot ( "error" , & text) ;
105119 assert ! ( text. contains( "temporarily unavailable" ) || text. contains( "coding service" ) ) ;
106120 assert ! ( !text. to_lowercase( ) . contains( "reqwest" ) ) ;
107121 assert ! ( !text. to_lowercase( ) . contains( "grok" ) ) ;
0 commit comments