File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,23 @@ fn fake_image(mime: &str, base64_len: usize) -> ImageData {
1313 }
1414}
1515
16+ fn strip_ansi ( input : & str ) -> String {
17+ let mut output = String :: with_capacity ( input. len ( ) ) ;
18+ let mut chars = input. chars ( ) ;
19+ while let Some ( char) = chars. next ( ) {
20+ if char == '\x1b' {
21+ for inner in chars. by_ref ( ) {
22+ if inner. is_ascii_alphabetic ( ) {
23+ break ;
24+ }
25+ }
26+ } else {
27+ output. push ( char) ;
28+ }
29+ }
30+ output
31+ }
32+
1633#[ tokio:: test]
1734async fn update_plan_dispatcher_returns_compact_model_result_and_styled_display ( ) {
1835 let workspace = tempdir ( ) . unwrap ( ) ;
@@ -45,13 +62,14 @@ async fn update_plan_dispatcher_returns_compact_model_result_and_styled_display(
4562 result. text( ) ,
4663 "Plan updated: 3 steps, 1 completed, 1 in progress, 1 pending. Current step: Add tool."
4764 ) ;
48- assert ! ( result. display_text( ) . contains( "Plan updated" ) ) ;
49- assert ! ( result. display_text( ) . contains( "Add tool" ) ) ;
5065 assert ! (
51- result
52- . display_text( )
53- . contains( "1 completed · 1 in progress · 1 pending" )
66+ !result. text( ) . contains( '\x1b' ) ,
67+ "the summary sent to the model must be free of ANSI escapes"
5468 ) ;
69+ let display = strip_ansi ( result. display_text ( ) ) ;
70+ assert ! ( display. contains( "Plan updated" ) ) ;
71+ assert ! ( display. contains( "Add tool" ) ) ;
72+ assert ! ( display. contains( "1 completed · 1 in progress · 1 pending" ) ) ;
5573}
5674
5775#[ test]
You can’t perform that action at this time.
0 commit comments