@@ -241,10 +241,16 @@ test("prompt footer shows the session's goal without its objective and opens it
241241 }
242242} )
243243
244- test . each ( [
245- { sessionID : "session" , expected : "≈ $12.60" } ,
246- { sessionID : "child" , expected : "≈ $1.50" } ,
247- ] ) ( "prompt footer estimates $sessionID spend" , async ( { sessionID, expected } ) => {
244+ test . each (
245+ [
246+ { sessionID : "session" , expected : "≈ $12.60" } ,
247+ { sessionID : "child" , expected : "≈ $1.50" } ,
248+ { sessionID : "session" , scale : 0.0001 , expected : "≈ <$0.01" } ,
249+ { sessionID : "session" , cost : 1 , expected : "$1.00" } ,
250+ { sessionID : "session" , experiment : false , expected : undefined } ,
251+ { sessionID : "session" , unpriced : true , expected : undefined } ,
252+ ] . map ( ( options ) => ( { cost : 0 , experiment : true , scale : 1 , unpriced : false , ...options } ) ) ,
253+ ) ( "prompt footer spend: $expected ($sessionID)" , async ( { sessionID, expected, cost, experiment, scale, unpriced } ) => {
248254 const color = RGBA . fromInts ( 200 , 200 , 200 )
249255 const context = {
250256 location : { directory : "/workspace" } ,
@@ -256,18 +262,31 @@ test.each([
256262 session : {
257263 family : ( ) => [ "session" , "child" , "sibling" ] ,
258264 status : ( ) => "idle" ,
259- get : ( id : string ) => ( {
260- id,
261- parentID : id === "session" ? undefined : "session" ,
262- location : { directory : "/workspace" } ,
263- model : { providerID : "provider" , id : "model" } ,
264- tokens :
265- id === "session"
266- ? { input : 1_000_000 , output : 100_000 , reasoning : 0 , cache : { read : 2_000_000 , write : 0 } }
267- : { input : id === "child" ? 500_000 : 2_000_000 , output : 0 , reasoning : 0 , cache : { read : 0 , write : 0 } } ,
268- cost : 0 ,
269- } ) ,
270- cost : ( ) => 0 ,
265+ get : ( id : string ) => {
266+ if ( id !== sessionID && ( cost > 0 || ! experiment ) ) throw new Error ( "Unused estimate reads family sessions" )
267+ return {
268+ id,
269+ parentID : id === "session" ? undefined : "session" ,
270+ location : { directory : "/workspace" } ,
271+ model : { providerID : "provider" , id : unpriced && id === "child" ? "removed" : "model" } ,
272+ tokens :
273+ id === "session"
274+ ? {
275+ input : 1_000_000 * scale ,
276+ output : 100_000 * scale ,
277+ reasoning : 0 ,
278+ cache : { read : 2_000_000 * scale , write : 0 } ,
279+ }
280+ : {
281+ input : ( id === "child" ? 500_000 : 2_000_000 ) * scale ,
282+ output : 0 ,
283+ reasoning : 0 ,
284+ cache : { read : 0 , write : 0 } ,
285+ } ,
286+ cost : 0 ,
287+ }
288+ } ,
289+ cost : ( ) => cost ,
271290 message : { list : ( ) => [ ] } ,
272291 } ,
273292 shell : { list : ( ) => [ ] } ,
@@ -286,7 +305,7 @@ test.each([
286305 } as unknown as Context
287306 const app = await testRender (
288307 ( ) => (
289- < ConfigProvider config = { createTuiResolvedConfig ( { experimental : { "cost-estimate" : true } } ) } >
308+ < ConfigProvider config = { createTuiResolvedConfig ( { experimental : { "cost-estimate" : experiment } } ) } >
290309 < PromptFooter context = { context } sessionID = { sessionID } mode = "normal" showDetails = { true } />
291310 </ ConfigProvider >
292311 ) ,
@@ -298,7 +317,10 @@ test.each([
298317
299318 try {
300319 await app . renderOnce ( )
301- expect ( app . captureCharFrame ( ) ) . toContain ( expected )
320+ const frame = app . captureCharFrame ( )
321+ if ( expected ) expect ( frame ) . toContain ( expected )
322+ if ( ! expected ) expect ( frame ) . not . toContain ( "$" )
323+ if ( cost > 0 ) expect ( frame ) . not . toContain ( "≈" )
302324 } finally {
303325 app . renderer . destroy ( )
304326 }
0 commit comments