@@ -2397,6 +2397,65 @@ describe('Availability Service Integration', () => {
23972397 config . resetTurn ( ) ;
23982398 expect ( spy ) . toHaveBeenCalled ( ) ;
23992399 } ) ;
2400+
2401+ it ( 'resetTurn does NOT reset billing state' , ( ) => {
2402+ const config = new Config ( {
2403+ ...baseParams ,
2404+ billing : { overageStrategy : 'ask' } ,
2405+ } ) ;
2406+
2407+ // Simulate accepting credits mid-turn
2408+ config . setOverageStrategy ( 'always' ) ;
2409+ config . setCreditsNotificationShown ( true ) ;
2410+
2411+ // resetTurn should leave billing state intact
2412+ config . resetTurn ( ) ;
2413+ expect ( config . getBillingSettings ( ) . overageStrategy ) . toBe ( 'always' ) ;
2414+ expect ( config . getCreditsNotificationShown ( ) ) . toBe ( true ) ;
2415+ } ) ;
2416+
2417+ it ( 'resetBillingTurnState resets overageStrategy to configured value' , ( ) => {
2418+ const config = new Config ( {
2419+ ...baseParams ,
2420+ billing : { overageStrategy : 'ask' } ,
2421+ } ) ;
2422+
2423+ config . setOverageStrategy ( 'always' ) ;
2424+ expect ( config . getBillingSettings ( ) . overageStrategy ) . toBe ( 'always' ) ;
2425+
2426+ config . resetBillingTurnState ( 'ask' ) ;
2427+ expect ( config . getBillingSettings ( ) . overageStrategy ) . toBe ( 'ask' ) ;
2428+ } ) ;
2429+
2430+ it ( 'resetBillingTurnState preserves overageStrategy when configured as always' , ( ) => {
2431+ const config = new Config ( {
2432+ ...baseParams ,
2433+ billing : { overageStrategy : 'always' } ,
2434+ } ) ;
2435+
2436+ config . resetBillingTurnState ( 'always' ) ;
2437+ expect ( config . getBillingSettings ( ) . overageStrategy ) . toBe ( 'always' ) ;
2438+ } ) ;
2439+
2440+ it ( 'resetBillingTurnState defaults to ask when no strategy provided' , ( ) => {
2441+ const config = new Config ( {
2442+ ...baseParams ,
2443+ billing : { overageStrategy : 'always' } ,
2444+ } ) ;
2445+
2446+ config . resetBillingTurnState ( ) ;
2447+ expect ( config . getBillingSettings ( ) . overageStrategy ) . toBe ( 'ask' ) ;
2448+ } ) ;
2449+
2450+ it ( 'resetBillingTurnState resets creditsNotificationShown' , ( ) => {
2451+ const config = new Config ( baseParams ) ;
2452+
2453+ config . setCreditsNotificationShown ( true ) ;
2454+ expect ( config . getCreditsNotificationShown ( ) ) . toBe ( true ) ;
2455+
2456+ config . resetBillingTurnState ( ) ;
2457+ expect ( config . getCreditsNotificationShown ( ) ) . toBe ( false ) ;
2458+ } ) ;
24002459} ) ;
24012460
24022461describe ( 'Hooks configuration' , ( ) => {
0 commit comments